Chartjs side effects for * some * customers only

I worked on several Chart.js charts and found strange behavior.

In this script: http://jsfiddle.net/h42tv3xv/ people have various side effects when they click the Day, Week, or Month buttons.

What it should do: Just refresh the chart with potentially new information (the pie and donut actually have nothing new)

What he should not do: As a side effect for some, he increases the size <canvas>with each press. He does it for me. But this does not do this for many other people accessing this violin. Here is a screenshot:

enter image description here

, ? ? , - , .

- , /?

, , , , :

// Assign and Create all canvas contexts 
    var ctx = $("#graph1").get(0).getContext("2d");
    var ctx2 =  $("#graph2").get(0).getContext("2d");
    var ctx3 =  $("#graph3").get(0).getContext("2d");

// Instantiate new charts and pass in generated data
    var myChart = new Chart(ctx).Line(graph1Generator("day"));
    var myDoughnutChart = new Chart(ctx2).Doughnut(graph2Generator("day"));
    var myPieChart = new Chart(ctx3).Pie(graph3Generator("day"));

( ) , . "":

weekButton.addEventListener("click", function(){

    myChart.destroy();
    myChart = new Chart(ctx).Line(graph2Generator("Week"));

    myDoughnutChart.destroy();
    myDoughnutChart = new Chart(ctx2).Doughnut(graph2Generator("week"));

    myPieChart.destroy();
    myPieChart = new Chart(ctx3).Pie(graph3Generator("week"));


});
+4
2

80% .

.

fiddle , .

<div class="wrapper">
    <canvas id="graph1" width="300" height="300"></canvas>

    <canvas id="graph2" width="250" height="250"></canvas>

    <canvas id="graph3" width="250" height="250"></canvas>  
</div>


.wrapper {
   max-width: 80%;
}
0

, padding canvas. padding, .

0

All Articles