How should I refer to the chart in a vue chart instance and destroy it? I've tried:
var chartVue = new Vue({
el: '#chart',
extends: VueChartJs.Line,
data: {
chartData: {...},
options: {...}
},
mounted() {
this.renderMyChart()
},
methods: {
renderMyChart: function() {
this.renderChart(
this.chartData,
this.options
);
}
},
watch: {
chartData: function() {
this._chart.destroy();
this.renderMyChart();
}
}
});
But it complains
TypeError: Cannot read property 'destroy' of undefined
So it seems this._chart
is not the right way to refer to the current chart, anybody knows what is the right way to do this? The idea comes from this stack overflow answer.