Skip to content

png/svg download to include legend? #541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ijlyttle opened this issue Feb 20, 2023 · 5 comments
Closed

png/svg download to include legend? #541

ijlyttle opened this issue Feb 20, 2023 · 5 comments

Comments

@ijlyttle
Copy link

I don't know if this is a Plot question or an observablehq.com question, but I thought I'd start here.

On any of the charts with legends here: https://observablehq.com/@observablehq/plot-legends, if I click "Download PNG" or "Download SVG", I get an image of the chart that does not include the legend. I imagine this follows from the legend being an add-on to the chart.

Could there be a convenient way to get them both in an image download?

Thanks!

@Fil
Copy link

Fil commented Feb 20, 2023

It's mostly an observablehq question, but it's also a Plot question, since Plot returns an HTML figure. Either way we'll need to find a good solution!

For PNG downloads, I've started experimenting with the image-to-html library here: https://observablehq.com/@fil/hello-html-to-image ; one could also try with html2canvas https://observablehq.com/@fil/hello-html2canvas

For SVG, I haven't found how to generically convert HTML to SVG, but I have a heap of code that 99% works. https://observablehq.com/@fil/plot-figure-to-svg

@mbostock
Copy link
Member

Please file this in the Observable feedback repository:

https://github.com/observablehq/feedback

I would transfer it but for some reason GitHub isn’t letting me.

@Fil Fil transferred this issue from observablehq/plot Feb 20, 2023
@Fil

This comment was marked as off-topic.

@Fil Fil reopened this Feb 20, 2023
@ijlyttle
Copy link
Author

@Fil Thanks! The html-to-image tool will let me do what I need to, looking forward to an update in observablehq :)

@CobusT
Copy link
Collaborator

CobusT commented Sep 1, 2023

This now works! Try it out and let us know if you run into other issues.

@CobusT CobusT closed this as completed Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants