Chart resize on redraw

Hi
I got the same issue as in 713 and 759

But the quick fix ( comment out the line helpers.retinaScale(this); ) doesnt work me (even on chrome or firefox).

My line Chart still increase his own size each time i redraw it (on browser resize or on data change).

Any idea of how to fix that?

Thanks

Author: Fantashit

1 thought on “Chart resize on redraw

  1. I had the same issue of a resizing canvas with Chart.js/2.7.1/Chart.bundle.js when redrawing a chart after changing its type using :

    function changeChartType(type) {
            var ctx = $("#chart1").get(0).getContext("2d");
            var temp = jQuery.extend(true, {}, chart1.config);
            temp.type = type;
            chart1.destroy();
            chart1 = new Chart(ctx, temp);
    }
    

    I could only solve it by adding a div around the canvas and setting Chart.defaults.global.maintainAspectRatio = false;

      <div style="width: 600px; height: 300px;">
        <canvas id="chart1" style="width: 600px; height: 300px;"></canvas>
      </div> 
    

Comments are closed.