Chartjs-Cannot read properties of undefined (reading 'notifyPlugins') โ€“ chart.js

0๐Ÿ‘

โœ…

You could try this patch of a solution: in add-chart.ts instead of

return new Chart(node, {
.....
});

use

const chart = new Chart(node, {
    .....
});
chart.destroy = chart.destroy.bind(chart);
return chart; 

A more svelte-idiomatic way might be

return {
   ...chart,
   destroy(){
      chart.destroy();
   }
}

but that would probably need some typescript acrobatics to pass type-checking.

Leave a comment