Growing chart value – chart.js

0👍

Check out this chart.js documention and chart.js update documention.
You need to use the chart.update method as so:

var options = //chart.js option object
var ctx = document.getElementById('chartJSContainer').getContext('2d');
var chart = new Chart(ctx, options);

var somefunc = function(chart){
var chartDatasetLength = chart.data.datasets[0].data.length;
    for(var i = 0; i < chartDatasetLength; i++){
    chart.data.datasets[0].data[i] += 1;
  }
  chart.update();
}

setInterval(somefunc, 1000, chart);

A working jsfiddle demo.

Leave a comment