[Chartjs]-Add Time Scaling to linechart (Chart.js)

1👍

see below updated method from your jsFiddle code:
add below 2 lines:

chartdata.data.labels.shift();
chartdata.data.labels.push(Math.random().toFixed(2));


$.each(data, function() {
    var tmp = chartdata.data.datasets[0].data;
    tmp.shift();
    tmp.push(this['avg_c_p_u'][0]*100);
    chartdata.data.datasets[0].data = tmp;
    chartdata.data.labels.shift(); //new line
    chartdata.data.labels.push(Math.random().toFixed(2));//new line
    chartdata.update();
  });

Leave a comment