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

Use vl-convert for offline html export #3251

Merged
merged 6 commits into from
Nov 9, 2023

Conversation

jonmmease
Copy link
Contributor

This PR takes advantage of HTML bundling support in vl-convert 1.0 to replace the dependency on altair_viewer when calling chart.save('chart.html', inline=True) to create an HTML file with inline JavaScript dependencies.

The vl-convert javascript_bundle() function returns a bundle with Vega, Vega-Lite, and Vega-Embed which can be included in a <script> tag. This function actually performs bundling and minification and takes 1-2s the first time it's called. The result is cached and subsequent calls are much faster.

I had to update the vl-convert minimum dependency to 1.0.1 because I discovered a bundling bug during integration.

@mattijn
Copy link
Contributor

mattijn commented Nov 7, 2023

Thanks @jonmmease!
Would it be possible to update the allowed arguments and docstrings here, for chart.save(), using the complete arguments and docstrings from here (save function within altair.utils.save)?

Maybe this, for chart.to_html(), is incomplete too?

I noticed this when there was no insight on the new argument in the tool tip when trying to save a chart:
image

@jonmmease
Copy link
Contributor Author

Thanks for the review @mattijn, this is ready for another look

Copy link
Contributor

@mattijn mattijn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now! This is great @jonmmease!

@mattijn mattijn merged commit aa77828 into main Nov 9, 2023
20 checks passed
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 this pull request may close these issues.

2 participants