-
Notifications
You must be signed in to change notification settings - Fork 33
Support HTML rendering with bundled assets (vs. CDN) #62
Comments
No, inline mode in the renderer is currently disabled in altair_saver, primarily because I wanted to prevent inadvertently creating huge notebooks (because inline mode would embed vega.js, vega-lite.js, and vega-embed.js in the output of every cell that contains a chart). Do you have a use-case that would benefit from this? |
Not inline, no — but bundling might be a nice option for both offline use and from a long-term reproducibility POV (eg notebook will work as long as we can run docker, even if the cdn ceases to exist). |
To clarify — by “bundling”, I mean serving from a local bundle vs embedding. |
Oh, that's really the domain of altair_viewer. I haven't really considered crossover between altair_saver output and altair_viewer output, but I could see where that might be useful. |
It’d be nice to be able to use both — I imagine this may come with their further integration into Altair down the line? |
I'll think about how to provide this functionality. In the meantime you could do this with a custom renderer, something like: import altair as alt
import altair_saver
import altair_viewer
def custom_renderer(spec):
bundle = altair_saver.render(spec, 'png')
bundle.update(altair_viewer.render(spec, inline=True))
return bundle
alt.renderers.register('custom', custom_renderer)
alt.renderers.enable('custom') |
Since Altair 5.2, the functionality of Altair Saver is now available in Altair via the vl-convert package. Most of the functionality has been available since 5.0, and the main addition in 5.2 was PDF export. See the docs on how to save charts for more details. We are going to archive this repo, so I'm closing all the open issues and PRs before doing so. Try out the new options for saving charts mentioned above and if you run into issues, please open an issue directly in the altair or vl-convert repo. |
It appears that it's only possible to use bundled assets with the
HTMLSaver
instandalone
mode. It would be useful to support being able to use local assets to support, e.g., Jupyter notebooks in an offline environment without a disk cache of the CDN assets.I know this is possible with
alt.renderers.enable("altair_viewer", inline=True)
, but is there a way currently to do this withaltair_saver
that I'm missing?The text was updated successfully, but these errors were encountered: