Working with the Chart.js library. Everytime I make an AJAX call and update the chart with the new data the chart gets larger (feels like its now resizing properly or zooming in).
I've tried to destroy the chart every time I redraw it, however I get a "Cannot read property 'destroy' of undefined" error. Here's my bit of code.
myLine.destroy();
var myLine = new Chart(document.getElementById("canvas").getContext("2d")).Bar(barChartData);
myLine.canvas.width = 800;
myLine.canvas.height = 500;
I've also tried to fix this through the CSS, but the chart gets smaller instead in the canvas
canvas {
width: 100% !important;
max-width: 800px;
height: auto !important;
}
Thanks!
Aucun commentaire:
Enregistrer un commentaire