score:1

you can use the api method getchart to see if it exists. if it does not exist it will return undefined, if it does exist it will return that chart.

so you would get:

const tmpchart = chart.getchart('canvasid');
if (tmpchart) {
  tmpchart.destroy()
}

Related Query

More Query from same tag