chart.js load totally new data

前端 未结 20 1374
有刺的猬
有刺的猬 2020-11-28 21:12

The API for chart.js allows one to edit points of the datasets loaded into it, for example:

.update( )

Calling update() on

20条回答
  •  遥遥无期
    2020-11-28 21:43

    I answered this here see How to clear a chart from a canvas so that hover events cannot be triggered?

    But here is the solution:

    var myPieChart=null;
    
    function drawChart(objChart,data){
        if(myPieChart!=null){
            myPieChart.destroy();
        }
        // Get the context of the canvas element we want to select
        var ctx = objChart.getContext("2d");
        myPieChart = new Chart(ctx).Pie(data, {animateScale: true});
    }
    

提交回复
热议问题