chartjs-plugin-zoom icon indicating copy to clipboard operation
chartjs-plugin-zoom copied to clipboard

When i use Web Worker, i get 'window is not defined'.

Open Quska45 opened this issue 2 years ago • 4 comments

Hi. i really enjoy your work in chartjs zoom plugin. Thank you.

But i have some ploblem use web worker.

When i use Web Worker, i get 'window is not defined'.

You have some idea this situation?

I use vite.

Quska45 avatar Mar 03 '23 09:03 Quska45

~~This is correct, the window object is not available in web workers, which version of chart.js and zoom plugin are you using?~~

This is correct, the window object is not available in web workers, rendering the chart in an offscreen canvas will return a static image of the chart and not an interactable chart. So the zoom plugin has 0 added value in this case. You can disable the zoom plugin by providing false for the zoom section in the plugins options.

LeeLenaleee avatar Mar 06 '23 12:03 LeeLenaleee

Thank you for reply. I think that you mean zoom plugin not available In web worker and offscreen both. If I tried to use only offscreen, but even then, zoom plugin will not work? I want to handle huge data, so i really need web worker and offscreen. If you dont mind, please give some advice for this.

Quska45 avatar Mar 06 '23 22:03 Quska45

If you want to use offscreen canvas API (which you need in webworkers) you can't use the zoom plugin, so you will have to choose which one you want.

You can take a look at this page for some performance tips: https://www.chartjs.org/docs/master/general/performance.html

LeeLenaleee avatar Mar 06 '23 23:03 LeeLenaleee

Disabling the zoom plugin via 'options.plugins.zoom = false' does not prevent the error from happening. Dito for options.plugin.zoom.zoom.

pjaleeuwen avatar May 19 '23 07:05 pjaleeuwen