From 896cfd6222e7cdb72254460b2c51908e575dd192 Mon Sep 17 00:00:00 2001 From: Jakub Juszczak Date: Mon, 16 Jul 2018 12:43:39 +0200 Subject: [PATCH 1/2] feat(events): Add events to reactiveMixins This will resolve #382 --- src/mixins/index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mixins/index.js b/src/mixins/index.js index a1863d63..b4849fed 100644 --- a/src/mixins/index.js +++ b/src/mixins/index.js @@ -42,25 +42,33 @@ function dataHandler (newData, oldData) { if (newData.hasOwnProperty('labels')) { chart.data.labels = newData.labels + this.$emit('labels:update') } if (newData.hasOwnProperty('xLabels')) { chart.data.xLabels = newData.xLabels + this.$emit('xlabels:update') } if (newData.hasOwnProperty('yLabels')) { chart.data.yLabels = newData.yLabels + this.$emit('ylabels:update') } chart.update() + this.$emit('chart:update') } else { if (chart) { chart.destroy() + this.$emit('chart:destroy') } this.renderChart(this.chartData, this.options) + this.$emit('chart:render') } } else { if (this.$data._chart) { this.$data._chart.destroy() + this.$emit('chart:destroy') } this.renderChart(this.chartData, this.options) + this.$emit('chart:render') } } From 3875703d18e2ed9bb8f42edca806fda2d3c13730 Mon Sep 17 00:00:00 2001 From: Jakub Juszczak Date: Sat, 4 Aug 2018 12:02:48 +0200 Subject: [PATCH 2/2] docs(reactive): Add events section to docs --- docs/README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/README.md b/docs/README.md index 0b78fc62..ff10f386 100644 --- a/docs/README.md +++ b/docs/README.md @@ -190,6 +190,18 @@ data () { } ``` +### Events + +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: + +- `chart:render` - if the mixin performs a complete rerender +- `chart:destroy` - if the mixin deletes the chart object instance +- `chart:update` - if the mixin performs an update instead of a re-render +- `labels:update` - if new labels were set +- `xlabels:update` if new xLabels were set +- `ylabels:update` - if new yLabels were set + + ### Example **LineChart.js**