[Chartjs]-How can I add new data points to an existing chart with chart.js?

1👍

You are updating your original variables, this does not work. You have to update chart.js its internal data like so:

function nextDay() {
  randNum = Math.random() * (max - min) + min;
  myChart.data.datasets[0].data.push(randNum);
  myChart.data.labels.push('Week ' + (startingCount + 1));
  myChart.update();
}

Leave a comment