Skip to content
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

Expose "Export to PNG" to @finos/perspective_viewer #2836

Open
tobilg opened this issue Nov 7, 2024 · 3 comments
Open

Expose "Export to PNG" to @finos/perspective_viewer #2836

tobilg opened this issue Nov 7, 2024 · 3 comments

Comments

@tobilg
Copy link

tobilg commented Nov 7, 2024

Feature Request

Description of Problem:

I had a look at the current implementation, and as it seems (I'm not a Rust expert), the export as PNG is not exposed to the JavaScript API. Whereas JSON, CSV and Arrow are (e.g. https://docs.rs/perspective-js/latest/perspective_js/struct.View.html#method.to_json).

export_screenshot

Ideally, also the export to HTML would be possible. The programatic PNG export would avoid having to do a screenshot of the component if one would like to store it etc.

Potential Solutions:

If possible, add the export to PNG (and HTML) to the JS API.

@tobilg
Copy link
Author

tobilg commented Nov 27, 2024

If someone could give me a hint on where to start, I'd also be open to submit a PR... Thanks!

@texodus
Copy link
Member

texodus commented Jan 6, 2025

Can you clarify the use case for this? There is already a prominent button (as you note), and if this were to be added it would still require the entire UI code to be loaded, attached to the DOM and visible to work.

@tobilg
Copy link
Author

tobilg commented Jan 6, 2025

Thanks for the response @texodus. The use case is for my project https://sql-workbench.com which uses Perspective v3 in a React app.

I provide the possibility of passing SQL queries and visualization configuration via the URL, so that users can share their work with others.

I‘d like to trigger those generations programatically, e.g. via a cron schedule on a server, that call a specific route only rendering the Graph result instead of the whole page.

Also, I could automatically start downloading the Graph as PNG if this would be exposed as API once the rendering is complete, w/o user interaction. Currently the user would need multiple clicks.

Additionally, this would also enable browser automation e.g. with Puppeteer. I haven’t found a way to simulate the clicks on the Perspective component to trigger the PNG saving.

Thanks for your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants