Closed jonmmease closed 10 months ago
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
This turned out to be pretty straightforward, so I opened a PR at https://github.com/vega/vl-convert/pull/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())
Inspired by @NickCrews's idea in https://github.com/altair-viz/altair/issues/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.