Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Support HTML rendering with bundled assets (vs. CDN) #62

Closed
boydgreenfield opened this issue Apr 2, 2020 · 7 comments
Closed

Support HTML rendering with bundled assets (vs. CDN) #62

boydgreenfield opened this issue Apr 2, 2020 · 7 comments

Comments

@boydgreenfield
Copy link
Contributor

It appears that it's only possible to use bundled assets with the HTMLSaver in standalone 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 with altair_saver that I'm missing?

@jakevdp
Copy link
Member

jakevdp commented Apr 3, 2020

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?

@boydgreenfield
Copy link
Contributor Author

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).

@boydgreenfield
Copy link
Contributor Author

To clarify — by “bundling”, I mean serving from a local bundle vs embedding.

@jakevdp
Copy link
Member

jakevdp commented Apr 3, 2020

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.

@boydgreenfield
Copy link
Contributor Author

It’d be nice to be able to use both — I imagine this may come with their further integration into Altair down the line?

@jakevdp
Copy link
Member

jakevdp commented Apr 3, 2020

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')

@joelostblom
Copy link
Member

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.

@joelostblom joelostblom closed this as not planned Won't fix, can't repro, duplicate, stale Mar 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants