Chartjs-Real-time line chart with ChartJS using Ajax data

0๐Ÿ‘

โœ…

By using pop I think you are removing the last element in the list and not the oldest one. So after 60 seconds, only the last element will be updated and the older data will remain.

Use splice to remove the first element of the array in the removeChart

   function removeData( chart, callback ) {
        chart.data.labels.splice(0, 1);
        chart.data.datasets.forEach((dataset) => {
            dataset.data.splice(0, 1);
        });
        chart.update();
    }

Leave a comment