javascript - Chart.js replace all data -


im having issue chart.js.

firts, set data, , when parameter change, want rebind entire chart. work, chart old data still behind new one.

first ->

chart.line(data, options); 

in event ->

  chart.line(newdata, options); 

i saw solution chart.js load totally new data

but dont way. im in angular directive context, it's not best aproach.

i tried without results

.update( ), .removedata( ), .clear(), .destroy(), etc

here current directive

http://plnkr.co/edit/qn2uuyznonkm6zgei8fw?p=catalogue

any idea ?

you creating new chart, that's why end old chart behind new one.

one simple option i've used: remove old chart canvas using chart:

$('#canvas').replacewith('<canvas id="canvas"></canvas>'); 

and create chart new data in same canvas

var ctxchart = document.getelementbyid("canvas").getcontext("2d"); window.mychart = new chart(ctxchart).line(newdata, options); 

hope helps!


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -