visx icon indicating copy to clipboard operation
visx copied to clipboard

Rendering to canvas

Open Miz85 opened this issue 6 years ago • 12 comments

Hi,

I'm a Big fan of vx, I think it's an amazing take on how to build reusable graphs. As far as I know it doesn't allow rendering to canvas instead of svg and I was wondering if it was ruled out or if it is on the table for some day in the future?

Thanks!

Miz85 avatar Jul 31 '19 06:07 Miz85

Canvas support is still on the table. Here's a proof-of-concept prototype I did back in February: https://codesandbox.io/s/xorr68vzqz (final API subject to change, this was just an idea sketch).

I hope/plan to add canvas support in the future.

hshoff avatar Jul 31 '19 15:07 hshoff

Canvas is more low level thinks and act directly to the pixels. The svg works fine so far. Did you find any performance issue to share it with us?

xargr avatar Aug 02 '19 11:08 xargr

Hey @xargr, I had to make some research to decide on which to choose, and the answer is that SVG provides better performance with a larger surface or a smaller number of objects. Canvas provides better performance with a smaller surface or a large number of objects.

So depending on the amount of data you wanna put on a chart, it really has some performance improvements.

pedroapfilho avatar Aug 27 '19 11:08 pedroapfilho

Hey @xargr, sorry for the late answer. On my side I really find vx awesome to use and we have some existing canvas visualisations. I was just wondering if porting them to vx could be an option. No particular performance issue with vx itself.

Miz85 avatar Sep 05 '19 21:09 Miz85

This would really be useful for calendar components, is there any movement on this?

spences10 avatar Jun 12 '20 18:06 spences10

No material updates on this, but I think it's definitely still on the table. Probably need to flesh out the implementation a bit more, likely could be implemented per-package (e.g., shape could export svg + canvas components)

williaster avatar Sep 16 '20 20:09 williaster

Hey @williaster! Any update on this? Just tried to create a scatter plot using Visx and ran into some performance issues when using more than 1000 datapoints. I think I'll implement it using D3 instead but just wanted to check if you knew if someone is working on adding canvas support.

sebastianpantin avatar Aug 19 '21 09:08 sebastianpantin

Still no updates that I know of

williaster avatar Aug 28 '21 00:08 williaster

I made a POC of drawing the generated SVG into a canvas, and then swapping the SVG element for the canvas element. Seems to work fine. Used the following for the svg-to-canvas conversion: https://stackoverflow.com/a/45334496/3425536. So this is one possibility.

emillaine avatar Jun 21 '22 10:06 emillaine

Any updates on this? D3 can be rendered to canvas, put handling interactions like mouse overs and clicks needs some customizations. Is this what is slowing down it being implemented in visx also?

Frazer avatar Apr 26 '23 19:04 Frazer