Adding parameters to altair chart crashes chart

With the above dataset (both dates treated as strings), I am trying to create a heatmap chart altair. It needs to have interactivity, but when I add it via .add_params() the chart stops working, showing nothing at all.

Code:

selection_point = alt.selection_point(name="selected-point") 
heatmap = alt.Chart(heatmap_data).mark_rect().encode(
    x=alt.X('departureTime_Inbound:O', title='Inbound Date'),
    y=alt.Y('departureTime_Outbound:O', title='Outbound Date'),
    color=alt.Color('Number of Flights:Q', scale=alt.Scale(scheme='blues')),
    tooltip=['departureTime_Outbound', 'departureTime_Inbound', 'Number of Flights']
).properties(
    width=800,
    height=600,
    title="Flight Prices Heatmap"
).add_params(selection_point)

# Display the heatmap in Streamlit
data = st.altair_chart(heatmap, on_select="rerun")
st.write(data)

With selection parameter, the chart is as below

Without it (and without on_select argument on st.altair_chart())

Probably had to do with name="selected-point" attribute of the selection point. The dash seems to cause issues, solved by using an underscore.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.