I have a function in my vue applications that creates a chart.This is the chart function:
startChart: function (canvas, type) {
// init chart.js
var ctx = document.getElementById("myChart");
var myDoughnut = new Chart(ctx, {
type: 'doughnut',
data: {
labels: this.getAnalyticList[this.getRowIndex].chartNames,
datasets: [{
data: this.getAnalyticList[this.getRowIndex].chartData,
backgroundColor: [
'rgba(255, 99, 132, 0.6)',
'rgba(54, 162, 235, 0.6)',
'rgba(255, 206, 86, 0.6)',
'rgba(75, 192, 192, 0.6)',
'rgba(153, 102, 255, 0.6)',
'red',
'yellow',
'blue',
'green',
'orange',
'teal',
'violet',
'pink',
'purple'
]
}]
},
options: {
responsive: true,
defaultFontColor: '#ffffff',
}
})
}
and i then started it in the vue mounted hook using this line
this.startChart(this.$refs.canvas, 'Doughnut');
What i want to do is take the row index of a table loaded above the chart and that would then be passed into the getAnalyticList value that loads the charts so i can grab different arrays from the same list. I was working on creating an update function i got off this js fiddle from this stack article. I've been trying to adapt the function he created into vue but am having no luck here is the function:
changeData: function () {
var myChart = Chart.doughnut(this.$refs.canvas, {
data: data,
});
myChart.data.datasets.data = this.getAnalyticList[this.getRowIndex].chartData;
myChart.data.labels = this.getAnalyticList[this.getRowIndex].chartNames;
myChart.update();
}
Any suggestions would be appreciated.