flekschas / regl-scatterplot

Scalable WebGL-based scatter plot library build with Regl
https://flekschas.github.io/regl-scatterplot/
MIT License
191 stars 24 forks source link

Can the canvas be re-used to draw other objects ? #177

Closed rpadmanabhan closed 4 months ago

rpadmanabhan commented 4 months ago

Hi,

Thanks much for developing such an excellent library, it is really useful for visualizing large single-cell RNA-seq dimensional reduction plots.

Do you know if the canvas element can be re-used to draw other objects (for e.g. a legend) ? I could not see any objects that I drew on the canvas after the scatterplot has been rendered so just wondering if this was possible. The motivation for this is to make it easy to save both the plot and the legend together as a png image.

Thanks for any insight.

flekschas commented 4 months ago

I don't think that's really possible because on every draw call the canvas is repainted and so you'd have to repaint the legend as well.

What I usually do is render the legend above the canvas using either SVG or standard HTML+CSS. Then during export, you can convert the legend to a bitmap using https://www.npmjs.com/package/html-to-image. Finally all you have to do is to blend the scatterplot and legend ImageDatas together.

rpadmanabhan commented 4 months ago

Thanks I will give that a try.