Is it possible to embed Streamlit charts to a third party app?

I think the charts visualised in Streamlit are great, so is there a way to embed just the interactive charts from Streamlit apps to a third party web app?

1 Like

Hi @nittin-shankar, welcome to the Streamlit community!

The answer depends on what you mean by “embedding”. There is no way to export Streamlit widgets, so that the code runs somewhere, meaning, there always has to be a Streamlit server running somewhere. However, if you have an Streamlit app running somewhere, using an iframe to embed that app into another page is possible.

If you only want the charts to be embedded somewhere else, you can generate a standalone version using steps specific to your graphing library, some examples,

Altair: https://altair-viz.github.io/user_guide/saving_charts.html

( Just plot the chart and do chart.save(‘chart.html’) and use the generated HTML wherever you want )

Bokeh: https://docs.bokeh.org/en/latest/docs/user_guide/embed.html#userguide-embed-standalone

( Just use output_file )

Haven’t tried for all libs but it should be fairly possible for any charting library you are using.
If you want to have the same charts as in streamlit you should use altair charts, check this out it might help, https://github.com/streamlit/streamlit/blob/8ba51e45d5133efb623b81ee0225976e920e9874/lib/streamlit/elements/altair.py

1 Like