Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

how to erase old graph before new dra

Open kiga01 opened this issue 12 years ago • 2 comments

hi guys, anyone knows how i can clear the canvas bejore y draw new graph? this is how i create new graphs

var lineChartData = { labels : mname, datasets : [ { label: "Ventas año "+ year, fillColor : "rgba(220,220,220,0.2)", strokeColor : "rgba(220,220,220,1)", pointColor : "rgba(220,220,220,1)", pointStrokeColor : "#fff", pointHighlightFill : "#fff", pointHighlightStroke : "rgba(220,220,220,1)", data : array }, ] }

var ctx = document.getElementById("myChart").getContext("2d");
var myLineChart = new Chart(ctx).Line(lineChartData, {
    responsive: true,
    //bezierCurve : false,
     bezierCurveTension : 0.1,
});

and how can i add another curve to the existing canvas?

kiga01 avatar Aug 20 '14 19:08 kiga01

As mentioned in #559, you'd call myLineChart.destroy().

Not sure I understand what you mean by adding another curve? Do you mean point?

nnnick avatar Aug 20 '14 21:08 nnnick

sorry, i didnt explain myself well, but alredy solve it, i just erase the canvas and make new one before each draw

kiga01 avatar Aug 21 '14 19:08 kiga01