Does altair's `set_embed_options` work with Streamlit?

By default, charts from altair have an icon you can click on to save the chart in various formats (the “…” in the upper right).

In this notebook, alt.renderers.set_embed_options(actions=False) succeeds in hiding that:

But doing the same in Streamlit doesn’t seem to have any effect.

I guess Streamlit is probably rendering the plots in some way that doesn’t use these settings. Is there another way to have settings like this applied for Altair charts in Streamlit?

2 Likes

Hey @dchudz,

Yes, you are right currently there’s no possible way to do that. But in the meantime you could do something like this:

import pandas as pd
import numpy as np
import altair as alt

df = pd.DataFrame(
    np.random.randn(200, 3),
    columns=['a', 'b', 'c'])

c = alt.Chart(df).mark_circle().encode(
    x='a', y='b', size='c', color='c')

st.markdown("""
    <style type='text/css'>
        details {
            display: none;
        }
    </style>
""", unsafe_allow_html=True)

st.altair_chart(c)

Good point, thanks.