amcharts / amcharts5

The newest, fastest, and most advanced amCharts charting library for JavaScript and TypeScript apps.
321 stars 90 forks source link

Are there plans for OffscreenCanvas support? #1562

Open tobiu opened 4 weeks ago

tobiu commented 4 weeks ago

Hi team,

I am the author of the neo.mjs frontend framework. I added an integration layer for your chart library v4 as a main thread addon.

It would be very nice, if we could create an example app of directly communicating charts which live in different browser windows (without using local storage or a backend connection).

We already have the web workers setup in place and transfer the ownership of canvas nodes into workers.

Looking at the v5 docs root logic, it seems to be limited to getting a div node and creating a canvas child node on its own. Except for canvas nodes, workers do not have access to the DOM, so this part can not work. In case it is not there yet, the ability to create a root based on an existing canvas node is needed.

It would also be nice, to run the "dev" mode directly inside the browser. For an ES6+ version, we do need import statements with relative paths. Import maps for workers will take quite some time (not sure if even the specs are finalised yet).

Cross reference neo ticket: https://github.com/neomjs/neo/issues/5411

Looking forward to your thoughts, since multi window support can win you new clients.

Best regards, Tobias

Pauan commented 4 weeks ago

@tobiu amCharts relies on a lot of browser APIs, for example it needs to use getBoundingClientRect to get the size of various elements, it uses event listeners, it uses requestAnimationFrame, etc.

It also creates extra DOM elements in addition to the canvas. So it's unlikely that it will ever be possible to run amCharts in a Worker.

It would also be nice, to run the "dev" mode directly inside the browser. For an ES6+ version, we do need import statements with relative paths. Import maps for workers will take quite some time (not sure if even the specs are finalised yet).

amCharts already uses relative paths, but it also uses npm packages, which cannot work directly in the browser, at least not without import maps.