Chartjs-Using react js to create a website that could read .csv file and show in chartjs

0👍

I’ve been running into this too. First I upgraded to the latest version of Chart.js and that didn’t fix it but it did provide the "remove()" function to delete the canvas.

What I’ve done to get past it is first delete the canvas:

<div id="fullReport1">
    <canvas id="myChart1"></canvas>
</div>

and then create a new canvas like so and use jQuery to append it to the div I have the canvas in:

var old_canvas = $('#myChart1');
if(old_canvas) old_canvas.remove();

var newCanvas = $('<canvas/>',{
                   'class':'chart1',
                    id: 'myChart1'                   
                });
$('#fullReport1').append(newCanvas);

After that I create the chart and fill the canvas.

(I don’t recall for sure where I found that solution so someone else here deserves the credit because I think I did find it here on stackoverflow)

Leave a comment