Chartjs-How to dynamically update data of line chart used with chart Js?

0👍

In your fiddle there are a couple of things that need to be corrected:

First – you’re declaring a new set of data in your if statement and then not assigning it to the chart.

Second – you’re not updating the chart.

Try this code:

let revisedViewsdata = "4,3,2,1,0,1,2";
myChart.data.datasets[0].data = revisedViewsdata;
myChart.update();

Leave a comment