-
Notifications
You must be signed in to change notification settings - Fork 12k
Description
I have to manually destroy my chart instance by calling this.chart.destroy(); My problem is that I have a custom plugin which has event listeners. When a chart is destroyed, it notifies the plugins, and in the plugin's destroy call I call chart.canvas.removeEventListener(). But this works only for the automatic destroy, and when I call destroy manually, the canvas stops existing before the plugins are notified. As far as I could find, there are no events that are run before destroy, according to the documents stop and uninstall are also called after destroy.
I managed to make a workaround by placing event listener removers to reset, and calling chart.notifyPlugins('reset') before destroying the chart. However, this way the event listener removing is entirely manual, have to be remembered each time the plugin is used in different contexts, and there's no way to ensure the event listeners were removed when chart is destroyed. There has to be a way to do a beforeDestroy call for a custom plugin.
Chart.js version: 3.6.1