How to clear a chart from a canvas so that hover events cannot be triggered?

后端 未结 21 1816
不思量自难忘°
不思量自难忘° 2020-11-28 20:07

I\'m using Chartjs to display a Line Chart and this works fine:

// get line chart canvas
var targetCanvas = document.getElementById(\'chartCanvas\').getConte         


        
21条回答
  •  没有蜡笔的小新
    2020-11-28 20:43

    What we did is, before initialization of new chart, remove/destroy the previews Chart instance, if exist already, then create a new chart, for example

    if(myGraf != undefined)
        myGraf.destroy();
        myGraf= new Chart(document.getElementById("CanvasID"),
        { 
          ...
        }
    

    Hope this helps.

提交回复
热议问题