2👍
✅
Seems to have been a couple of issues:
- The variable
somechart
doesn’t exist, you named itchart
- If you log out chart, you’ll see
chart.config.data.datasets.data[2] = 5000;
will not work because datasets is an array, so you can access it like this:chart.config.data.datasets[0].data[2] = 5000;
Heres a new fiddle with the fixes above added: https://jsfiddle.net/8whzsLgp/
1👍
Your chart variable is named chart
but you’re trying to access it via somechart
, which does not exist. Change the variable somechart
to chart
.
1👍
you are using the wrong variable for updating content replace your somechart to chart as you have initialize chart variable
var chart = new Chart
https://drive.google.com/uc?id=1QTdQsZqGMnmNZ2LrCed_yIWUQbg4hO5s
Updated your code as below
chart.options.title.text = 'new title';
chart.config.data.datasets[0].data[2] = 5000;
chart.update();
you need to specify the index of the dataset in order to update the data.
Source:stackexchange.com