score:4

Accepted answer

the update() handles adding data too. just push your new data / labels into the config object that you passed when creating the chart and then call update()

for instance,

var config = {
  type: 'line',
  data: {
    labels: ["january", "february", "march", "april", "may", "june", "july"],
    datasets: [{
      label: "my first dataset",
      data: [65, 0, 80, 81, 56, 85, 40],
      fill: false
    }]
  }
};

var ctx = document.getelementbyid("mychart").getcontext("2d");
var mychart = new chart(ctx, config);

settimeout(function(){
    config.data.labels.push('test');
    config.data.datasets[0].data.push(3);
    mychart.update();
}, 1000);

fiddle - http://jsfiddle.net/zpnx8ppb/


Related Query

More Query from same tag