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

Support converting Vega specs to Vega-editor compatible URLs #103

Closed
jonmmease opened this issue Sep 13, 2023 · 2 comments · Fixed by #104
Closed

Support converting Vega specs to Vega-editor compatible URLs #103

jonmmease opened this issue Sep 13, 2023 · 2 comments · Fixed by #104

Comments

@jonmmease
Copy link
Collaborator

Inspired by @NickCrews's idea in vega/altair#3188, vl-convert could potentially support converting Vega/Vega-Lite specifications to share URLs that are compatible with the Vega editor.

I haven't looked into the details, but @NickCrews mentioned that the editor is using the lz-string JavaScript library for URL-compatible compression. There is a Rust port of this library at https://docs.rs/lz-str/latest/lz_str/. If this library is compatible with the what the Vega editor needs, this might be a pretty easy and useful addition to vl-convert.

@NickCrews
Copy link

I don't really understand how all the vega parts fit together, if this is added here, would it be accessible from altair?

Specifically, vega editor uses the LZstring.decompressFromEncodedURIComponent method. The python port I mentioned in the above issue did not have this flavor. But the rust port you linked does! So it might just work out of the box! I would just try passing some json to the rust lib and see if it works as a 10 minute prototype

@jonmmease
Copy link
Collaborator Author

This turned out to be pretty straightforward, so I opened a PR at #104. Regardless of what else happens with the Vega editor, this is a nice feature to have in VlConvert.

I don't really understand how all the vega parts fit together, if this is added here, would it be accessible from altair?

vl-convert-python is an optional dependency of Altair that we already use for PNG and SVG image export. We would probably want to have Altair provide a convenience chart.to_url() method, but it will be usable with vl-convert directly like this:

import vl_convert as vlc
vlc.vegalite_to_url(chart.to_json())

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

Successfully merging a pull request may close this issue.

2 participants