Interacting with the chart above widget?

Hi,
Is there a way to display altair chart before the st.slider widget but still interact with it using the slider.
Something like a placeholder for charts?

Many thanks

Hello @DeWa, welcome to the forums :slight_smile:

The streamlit empty placeholder works well with altair chart, here is an example for using a radio button to change the color of chart under the chart

st.header("Demo placeholder altair chart")

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

chart_placeholder = st.empty()

color = st.radio("select color", ("blue", 'red', 'green'))

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

chart_placeholder.altair_chart(c)

streamlit-app-2020-03-24-11-03-6

1 Like

Thats so helpful. Many thanks.