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

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

    When you create one new chart.js canvas, this generate one new iframe hidden, you need delete the canvas and the olds iframes.

    $('#canvasChart').remove(); 
    $('iframe.chartjs-hidden-iframe').remove(); 
    $('#graph-container').append(''); 
    var ctx = document.getElementById("canvasChart"); 
    var myChart = new Chart(ctx, { blablabla });
    

    reference: https://github.com/zebus3d/javascript/blob/master/chartJS_filtering_with_checkboxs.html

提交回复
热议问题