What happens, Chart.js multiplies the size of the canvas when it is called, and then tries to scale it back using CSS, the purpose of which is to provide higher-resolution charts for high-resolution devices per inch.
The problem is that he does not understand that he has already done this, therefore, when he is called sequential time, he multiplies the already (doubled or any) AGAIN size until everything starts to break. (What actually happens is to check if it should add more pixels to the canvas by changing the DOM attribute for width and height, if it should, by multiplying it by some factor, usually 2, and then changing it and then changing the style css to keep the same size per page.)
For example, when you run it once, and the width and height of the canvas is 300, it sets them to 600, and then changes the style attribute to 300 ... but if you run it again, it will see that the DOM is width and height - 600 (check another answer to this question to see why) and then sets the value of 1200 and the width and height of the css to 600.
Not the most elegant solution, but I solved this problem by preserving the expanded resolution for the retina devices, simply setting the width and height of the canvas manually before each subsequent call to Chart.js
var ctx = document.getElementById("canvas").getContext("2d"); ctx.canvas.width = 300; ctx.canvas.height = 300; var myDoughnut = new Chart(ctx).Doughnut(doughnutData);
jcmiller11 Feb 15 '14 at 13:00 2014-02-15 13:00
source share