File tree Expand file tree Collapse file tree 1 file changed +17
-16
lines changed Expand file tree Collapse file tree 1 file changed +17
-16
lines changed Original file line number Diff line number Diff line change @@ -25,15 +25,15 @@ export default {
2525 options: {
2626 type: Object ,
2727 default : () => ({})
28+ },
29+ plugins: {
30+ type: [Object , Array ],
31+ default : () => ({})
2832 }
2933 },
3034
3135 mounted () {
32- this .chart = new Chart (this .$el , {
33- type: this .type ,
34- data: this .data ,
35- options: this .options
36- })
36+ this .resetChart ()
3737 },
3838
3939 data () {
@@ -44,33 +44,34 @@ export default {
4444
4545 methods: {
4646 resetChart () {
47- this .$nextTick (() => {
47+ if ( this .chart )
4848 this .chart .destroy ()
49- this .chart = new Chart (this .$el , {
50- type: this .type ,
51- data: this .data ,
52- options: this .options
53- })
49+
50+ this .chart = new Chart (this .$el , {
51+ type: this .type ,
52+ data: this .data ,
53+ options: this .options ,
54+ plugins: this .plugins
5455 })
5556 }
5657 },
5758
5859 watch: {
5960 type () {
60- this .resetChart ()
61+ this .$nextTick (() => this . resetChart () )
6162 },
6263 data () {
6364 this .chart .update ()
6465 },
6566 options () {
66- this .resetChart ()
67+ this .$nextTick (() => this . resetChart () )
6768 }
6869 }
6970}
7071 </script >
7172
7273<style lang="scss">
73- canvas .chartjs {
74- max-width : 100% ;
75- }
74+ canvas .chartjs {
75+ max-width : 100% ;
76+ }
7677 </style >
You can’t perform that action at this time.
0 commit comments