File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,18 @@ data () {
190
190
}
191
191
```
192
192
193
+ ### Events
194
+
195
+ The reactive mixins will emit events if the data changes. You can listen to them with ` v:on ` on the chart component. Following events are available:
196
+
197
+ - ` chart:render ` - if the mixin performs a complete rerender
198
+ - ` chart:destroy ` - if the mixin deletes the chart object instance
199
+ - ` chart:update ` - if the mixin performs an update instead of a re-render
200
+ - ` labels:update ` - if new labels were set
201
+ - ` xlabels:update ` if new xLabels were set
202
+ - ` ylabels:update ` - if new yLabels were set
203
+
204
+
193
205
### Example
194
206
195
207
** LineChart.js**
Original file line number Diff line number Diff line change @@ -42,25 +42,33 @@ function dataHandler (newData, oldData) {
42
42
43
43
if ( newData . hasOwnProperty ( 'labels' ) ) {
44
44
chart . data . labels = newData . labels
45
+ this . $emit ( 'labels:update' )
45
46
}
46
47
if ( newData . hasOwnProperty ( 'xLabels' ) ) {
47
48
chart . data . xLabels = newData . xLabels
49
+ this . $emit ( 'xlabels:update' )
48
50
}
49
51
if ( newData . hasOwnProperty ( 'yLabels' ) ) {
50
52
chart . data . yLabels = newData . yLabels
53
+ this . $emit ( 'ylabels:update' )
51
54
}
52
55
chart . update ( )
56
+ this . $emit ( 'chart:update' )
53
57
} else {
54
58
if ( chart ) {
55
59
chart . destroy ( )
60
+ this . $emit ( 'chart:destroy' )
56
61
}
57
62
this . renderChart ( this . chartData , this . options )
63
+ this . $emit ( 'chart:render' )
58
64
}
59
65
} else {
60
66
if ( this . $data . _chart ) {
61
67
this . $data . _chart . destroy ( )
68
+ this . $emit ( 'chart:destroy' )
62
69
}
63
70
this . renderChart ( this . chartData , this . options )
71
+ this . $emit ( 'chart:render' )
64
72
}
65
73
}
66
74
You can’t perform that action at this time.
0 commit comments