Uncaught Error Canvas is already in use Chart with ID 0 must be destroyed before the canvas reuse

preview_player
Показать описание
Join this channel to get access to perks:

My Gear



My Youtube Channels


My Wife's Channel

Websites

Connect with me
Рекомендации по теме
Комментарии
Автор

In case it is not working for you, Try this code (here myChart is the id of canvas) -> if (Chart.getChart("myChart")){

}

Sagarclips
Автор

Thank you! It's so obvious now I see the error but your last comment about the myChart variable needing to be global was what fixed it for me.

BobD
Автор

This was very helpful. I could not find this simple fix anywhere else despite spending a whole day. Thank you so much Mr. Sagar

vamsinvizag
Автор

Thank you so much brother! This worked perfectly for the site that I am building. You are the man!!

SkreenGG
Автор

Hi @Sagar S, the getchart method worked thank you

darknights
Автор

thanks, alot sir I was stuck in this for days.

yashrajwanshi
Автор

I get this error after I try your solution
Uncaught (in promise ) RefenrenceError: can't access lexical declaration 'myChart' before initialization
Please help me 🙏🙏

rinsyarifuddin
Автор

Thanks it helped i did it that way

function generateChart(i) {
loadStats(i)


if (myChart != null) {

myChart.destroy()
myChart=null
generateChart(i)
}else let ctx =

myChart = new Chart(ctx, {
😄

ThisIsDanielSan
Автор

is there any method to destroy it by canvas element, for example

muhamedqasim