plot icon indicating copy to clipboard operation
plot copied to clipboard

A raster/2d function plot mark

Open Fil opened this issue 3 years ago • 2 comments

https://observablehq.com/@observablehq/plot-heatmap-984

see comment in https://observablehq.com/@observablehq/javascript-replacements-for-python-data-science-tools#comment-7873045d922f909f

Fil avatar Jul 13 '22 08:07 Fil

I like it. I think we should use foreignObject instead of toDataURL though (even if it currently breaks downloads on Observable; we could add a fix for that to downloading if we want to).

I wonder if using fillRect would be faster or slower than putImageData.

I think we’ll want a different option than resolution, but I’m not sure exactly what… For the current functionality I would rename the option to devicePixelRatio (or maybe pixelRatio) but I wonder if it should feel more like Plot.density where there’s an underlying grid of some resolution (that’s not necessarily 1:1 with pixels). But maybe starting with pixelRatio is fine and I’m overthinking.

It’s also interesting to think how a WebGL shader mark might function.

mbostock avatar Jul 13 '22 13:07 mbostock

A while ago while playing around with my own density mark (with liberal help from Fil) I ran into an Safari bug where the foreignObject would not scale properly with the SVG.

You can see an example here – open it in Safari and increase the font size. Performance should be better than toDataURL, but I never figured out a workaround for the bug.

yurivish avatar Jul 15 '22 21:07 yurivish

Fixed in #1196.

mbostock avatar Jan 14 '23 22:01 mbostock