Hi Streamlit Team and Community,
I’ve been encountering an issue when using Altair charts with a dropdown to select the data for the X-axis. The problem arises when running Streamlit versions higher than 1.34.0. Here’s the situation:
- The code works perfectly fine with Streamlit 1.34.0, regardless of the Altair version (even Altair 5.x.x).
- When I upgrade Streamlit to any version beyond 1.34.0 (e.g., 1.37.0), the chart fails to render, and I get the following error:
Error: Unrecognized signal name: "param_5"
at l (http://localhost:8501/static/js/7483.64f23be7.chunk.js:2:361646)
at pq.getSignal (http://localhost:8501/static/js/7483.64f23be7.chunk.js:2:931034)
at http://localhost:8501/static/js/7483.64f23be7.chunk.js:2:868309
at Array.forEach (<anonymous>)
at xL (http://localhost:8501/static/js/7483.64f23be7.chunk.js:2:868265)
at pU (http://localhost:8501/static/js/7483.64f23be7.chunk.js:2:902461)
at hU (http://localhost:8501/static/js/7483.64f23be7.chunk.js:2:902086)
at dU (http://localhost:8501/static/js/7483.64f23be7.chunk.js:2:901575)
at fU (http://localhost:8501/static/js/7483.64f23be7.chunk.js:2:901387)
at http://localhost:8501/static/js/7483.64f23be7.chunk.js:2:912655
Code Example:
Here’s a simplified example of my code:
import altair as alt
import pandas as pd
import streamlit as st
data = {
'Score': [0.85, 0.9, 0.95],
'Gene': ['Gene1', 'Gene2', 'Gene3'],
'Species': ['Human', 'Mouse', 'Rat'],
'Region': ['Exon', 'Intron', 'Promoter'],
'Position A': [100, 200, 300],
'Position B': [50, -100, 150]
}
df = pd.DataFrame(data)
source = df.copy()
source['Gene_Region'] = source['Gene'] + " " + source['Species'] + " " + source['Region']
score_range = source['Score'].astype(float)
ystart = score_range.min() - 0.02
ystop = score_range.max() + 0.02
scale = alt.Scale(scheme='category10')
color_scale = alt.Color("Gene_Region:N", scale=scale)
gene_region_selection = alt.selection_point(fields=['Gene_Region'], on='click', bind='legend')
# X Axis dropdown selection
dropdown = alt.binding_select(
options=["Position A", "Position B"],
name='(X-axis) Position: '
)
xcol_param = alt.param(value='Position A', bind=dropdown)
chart = alt.Chart(source).mark_circle().encode(
x=alt.X('x:Q', title='Position (bp)'),
y=alt.Y('Score:Q', axis=alt.Axis(title='Relative Score'),
scale=alt.Scale(domain=[source['Score'].astype(float).min() - 0.02, source['Score'].astype(float).max() + 0.02])),
color=alt.condition(gene_region_selection, color_scale, alt.value('lightgray')),
tooltip=['Score', 'Gene', 'Species', 'Region', 'Position A', 'Position B'],
opacity=alt.condition(gene_region_selection, alt.value(0.8), alt.value(0.2))
).transform_calculate(
x=f"datum[{xcol_param.name}]"
).properties(width=600, height=400
).interactive().add_params(gene_region_selection, xcol_param)
st.altair_chart(chart, theme=None, use_container_width=True)
What I Observed:
- The issue appears specifically related to the Altair parameter binding for the X-axis using
alt.param()
,alt.binding_select()
and.transform_calculate()
- The chart fails to render in Streamlit versions > 1.34.0, when you display it for the first time it is empty then if you reload the page or something else then the error
Unrecognized signal name
. - Reverting Streamlit to version 1.34.0 resolves the problem entirely, while newer Streamlit versions consistently break this functionality.
- The error only shows in Streamlit but not in the cmd. Even with a try-except
- The error does not come from my PCs. On Streamlit Cloud it’s the same problem
- The issue isn’t caused by Altair, as the same code works fine with Altair 5.x.x on Streamlit 1.34.0.
Thank you for your support! I can provide more details or examples if needed.
Streamlit 1.34.0
Streamlit > 1.34.0