1

I have a Line chart for which data is contineously gets updated in batch of 5000 records.
But at some random point I want to stop the currently in progress drawing and redraw the chart from very bigining.

I have below code to clear the chart.

function resetChart() {
   chart.stop();
   chart.clear();
   chart.reset();

   chart.data.datasets[0].data = [];
   chart.update();
}

I am pushing data to chart in below code:

function updateData(myarray) { 
   for (var i=0;i < myarray.length;i++) {
     if (stopRender) {
        stopRender = false;
        resetChart();
        break; 
     }

     chart.data.datasets[0].data.push(myarray[i]);
   }
   chart.update();
}

If I receive stop render, then I stop and clear the chart.
But soemtimes data displayed on the chart is not getting cleared and it start to draw new data again which mess up the chart. There is a delay of around 1 seconds between stop and redraw new data.

I want to clear all the data from the chart and start redrawing new data, without creating new chart or canvas.

User7723337
  • 11,857
  • 27
  • 101
  • 182

0 Answers0