Chartjs-Updating in chart.js

0👍

There are problems in your reload function where you access renderChart.data.datasets.
Please note that renderChart.data.datasets is an array. Therefore, you need to make the following changes:

reload: function() {
    // renderChart.data.datasets.data = []; // old
    renderChart.data.datasets[0].data = []; // new
    for (subject in classes) {
        console.log('adding: ' + classes[subject].count)
        // renderChart.data.datasets.data.push(classes[subject].count); // old
        renderChart.data.datasets[0].data.push(classes[subject].count); // new
    }
    renderChart.update();
}

Leave a comment