javascript - chart resizes everytime it is rendered -


i have chart rendered in same canvas repeatedly. canvas not recreated. using chart.js rendering? find chart resizes everytime rendered. have 2 questions.

  1. can chart stopped resizing?
  2. can canvas cleared before next chart rendered?

the code have far:

js:

var productslength =  payeraccarr[index].productsused.length;   if (productslength > 5){     productslength = 5   }    var colorarray = ["#f7464a","#46bfbd","#fdb45c","#949fb1","#4d5360"];   var highlightarr=["#ff5a5e","#5ad3d1","#ffc870","#a8b3c5","#616774"];   var doughnutdata=[];   for(indexer=0;indexer<productslength;indexer++){     var dataobj = {       value: payeraccarr[index].productsused[indexer].totalcost,       color:colorarray[indexer],       highlight: highlightarr[indexer],       label: payeraccarr[index].productsused[indexer].productcode     };      doughnutdata.push(dataobj);   }       // window.onload = function(){         var ctx = document.getelementbyid("chart-area").getcontext("2d");         ctx.canvas.width = 268;         ctx.canvas.height = 259;         window.mydoughnut = new chart(ctx).doughnut(doughnutdata, {responsive : true, maintainaspectratio: false}); 

html:

<div id="canvas-holder" class='hide'>                 <span id='spend'>month-to-date spend service</span>                 <canvas id="chart-area" style='width: 268px; height:259px;'/> 

i apologize if have repeated question asked on forum.

well, answer q #2, use ctx.clearrect(0,0,<width>,<height>).


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -