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

后端 未结 21 1811
不思量自难忘°
不思量自难忘° 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:46

    I had the same problem here... I tried to use destroy() and clear() method, but without success.

    I resolved it the next way:

    HTML:

    Javascript:

    var pieChartContent = document.getElementById('pieChartContent');
    pieChartContent.innerHTML = ' ';
    $('#pieChartContent').append('');
    
    ctx = $("#pieChart").get(0).getContext("2d");        
    var myPieChart = new Chart(ctx).Pie(data, options);
    

    It works perfect to me... I hope that It helps.

提交回复
热议问题