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?


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

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


Good point, thanks.

This CSS hack is very handy. Thanks!

Is there an easy additional workaround to get the chart rendered to the full width of its container?

Currently the chart width isn’t as wide as the container because at render time it leaves some space for the (gone) button.