Reputation: 946
How can I create interactive charts that can be shared to others with limited internet connection?
My situation is such that I can generate and view the interactive charts I want, but due to VPN restrictions, my colleagues are not able to open the html charts that I generate. From the error message below, it seems like they are not able to render due to inability to connect to the web.
(error loading script https //cdn.jsdelivr.net/npm//vega@5 noext)
Upvotes: 4
Views: 980
Reputation: 86463
Interactive Altair/Vega-Lite charts require several javascript libraries to render the charts; in most cases these libraries are loaded from an external CDN, and so the chart will not be viewable without an internet connection.
You can get around this using the altair_saver package, which is able to save HTML charts in "inline" mode, where the required javascript libraries are embedded directly in the chart output.
For example:
import altair_saver
chart = alt.Chart(df).mark_point() #...
altair_saver.save(chart, 'chart.html', inline=True)
The resulting file can be viewed in a javascript-enabled web browser, and should work even without an internet connection.
Upvotes: 5