[Chartjs]-Chart Js flickering or switching as i move mouse on canvas

4👍

There is no need to literally clear the canvas. But you need to destroy the chartjs object before you reinitialize it. So, it’s like re-creating a chartjs object on the same canvas.
All you need to do is check if the instance already exists before creating the object in drawChart method.

function drawChart(cdiv, ctype){
      if(chartx){
            chartx.destroy();
      }
      chartx = new Chart(.....
      ...... 
}

Leave a comment