1👍
Figured it out. I was using the example documentation for the update.chart() method which shows:
function addData(chart, data) {
chart.data.datasets.forEach((dataset) => {
dataset.data.push(data);
});
chart.update();
}
However, chartjs renders to the foreground the data that is declared first in the array. So, to make the data thats inserted into the chart using the chart.update() method, I replaced the push() method with an unshift() method. For example:
function addData(chart, data) {
chart.data.datasets.forEach((dataset) => {
dataset.data.unshift(data);
});
chart.update();
}
- [Chartjs]-Ng2-charts crosshair plugin not working in Angular
- [Chartjs]-Display Doughnut Pie Chart As Circle Progress Chart.js
Source:stackexchange.com