Chartjs-How to Update 2 dataset for 2 lines in a CharJS line graph?

0👍

According to the documentation (https://www.chartjs.org/docs/latest/developers/updates.html#adding-or-removing-data) after you add your data to the array you will have to call the update method on your chart to update it like this:

             updateChart = (dataset) =>{
                chart.data.datasets.forEach((dataset) => {
                    dataset.data.push(chartParam1Value);
                });

                chart.data.datasets.forEach((dataset) => {
                    dataset.data.push(chartParam2Value);
                });
                chart.update()
             }

Leave a comment