1๐
I think this is what you need:
function addData(chart, label, data) {
chart.data.labels.push(label);
chart.data.datasets.forEach((dataset) => {
dataset.data.push(data);
});
chart.update();}
function removeData(chart) {
chart.data.labels.pop();
chart.data.datasets.forEach((dataset) => {
dataset.data.pop();
});
chart.update();}
0๐
You need to call the object method .update(), every time you change the data, in order to update the graph visualisation.
Take a look at the documentation of the Chartjs library: https://www.chartjs.org/docs/latest/developers/updates.html.
- [Chartjs]-UnitStepSize for regular time interval with Chartjs
- [Chartjs]-PrimeFaces PolarArea Chart โ GridLine Color Change
0๐
Original Docs: https://www.chartjs.org/docs/latest/developers/api.html#updateconfig
Sample:
$('#1').click(function () {
spins15 = [15, 25, 35];
someChart.data.datasets[0] = spin;
someChart.update();
});
Source:stackexchange.com