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 {
25
25
options: {
26
26
type: Object ,
27
27
default : () => ({})
28
+ },
29
+ plugins: {
30
+ type: [Object , Array ],
31
+ default : () => ({})
28
32
}
29
33
},
30
34
31
35
mounted () {
32
- this .chart = new Chart (this .$el , {
33
- type: this .type ,
34
- data: this .data ,
35
- options: this .options
36
- })
36
+ this .resetChart ()
37
37
},
38
38
39
39
data () {
@@ -44,33 +44,34 @@ export default {
44
44
45
45
methods: {
46
46
resetChart () {
47
- this .$nextTick (() => {
47
+ if ( this .chart )
48
48
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
54
55
})
55
56
}
56
57
},
57
58
58
59
watch: {
59
60
type () {
60
- this .resetChart ()
61
+ this .$nextTick (() => this . resetChart () )
61
62
},
62
63
data () {
63
64
this .chart .update ()
64
65
},
65
66
options () {
66
- this .resetChart ()
67
+ this .$nextTick (() => this . resetChart () )
67
68
}
68
69
}
69
70
}
70
71
</script >
71
72
72
73
<style lang="scss">
73
- canvas .chartjs {
74
- max-width : 100% ;
75
- }
74
+ canvas .chartjs {
75
+ max-width : 100% ;
76
+ }
76
77
</style >
You can’t perform that action at this time.
0 commit comments