score:1

i've had similar issues with .clear() and .destroy()

what worked for me:

completely remove and replace the <canvas> element

score:2

destroy() works fine for me, check this code.

 if (window.mydoughnut)
     window.mydoughnut.destroy();

 var ctx = $elm.getcontext("2d");
 window.mydoughnut = new chart(ctx).doughnutalt(value, {showscale: true, scaleshowlabels: true, animation: false});

score:6

try this:

before binding data , remove the canvas too ;)

html:

<div id="divchartcontainer"></div>

script:

        $('#divchartcontainer').empty();
        $('#divchartcontainer').append('<canvas id="canvas"></canvas>');
        var ctx = document.getelementbyid("canvas").getcontext("2d");
        var mylinechart = new chart(ctx).bar(barchartdata, {
            responsive: true,
            barvaluespacing: 10,
            barstrokewidth: 0,
            scaleshowlabels: true,
            scaleshowgridlines: true,
            scalegridlinecolor: "rgba(0,0,0,.05)",
            scalegridlinewidth: 1,
        });

issue solved !!


Related Query

More Query from same tag