Chartjs-Getting nice chart.js animation when adding data with unshift()?

0👍

You can read this doc https://www.chartjs.org/docs/latest/developers/updates.html

update data via this function

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();
}

Leave a comment