Skip to content

Commit 959d998

Browse files
committed
Add gh-13974
1 parent 9352b3e commit 959d998

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

issues/gh-13974/app.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import altair as alt
2+
import streamlit as st
3+
import pandas as pd
4+
from numpy.random import default_rng
5+
6+
df = pd.DataFrame(default_rng(0).standard_normal((60, 2)), columns=["a", "b"])
7+
base = alt.Chart(df).mark_circle().encode(x="a", y="b").properties(width=400, height=200)
8+
text = base.mark_text(dy=-10).encode(text=alt.Text("b:Q", format=".1f"))
9+
10+
with st.echo():
11+
st.header('original issue #13410 (VConcat & HConcat)')
12+
st.caption('With lines 161-168 commented out, it renders exactly the same as is')
13+
chart = base & (base | base)
14+
st.altair_chart(chart, width='stretch')
15+
16+
with st.echo():
17+
# PR #13423 ensures that vega-lite spec defaults to
18+
# "autosize": {"type": "pad", "contains": "padding"}.
19+
# The overrun issue persists...
20+
st.header('My issue (Layered & VConcat) without autosize=fit-x')
21+
st.caption('As is, the top (layered) chart reverts to 400 width and the bottom chart flows out the container')
22+
st.caption('With lines 161-168 commented out, it renders but the charts flow out of the container')
23+
chart = (base + text) & base
24+
st.altair_chart(chart, width='stretch')
25+
26+
with st.echo():
27+
# Manually controlling the "autosize" spec produced the desired behavior up
28+
# until streamlit version 1.52.2 (until PR #13423 was introduced).
29+
# Commenting out lines 161-168 in
30+
# `frontend/lib/src/components/elements/ArrowVegaLiteChart/useVegaElementPreprocessor.ts`
31+
# Fixes this issue when I build `streamlit` on my system runing the React development server
32+
st.header('My issue (Layered & VConcat) with autosize=fit-x')
33+
st.caption('As is, the chart does not render')
34+
st.caption('With lines 161-168 commented out, it produces the desired chart')
35+
chart = (base + text) & base
36+
chart = chart.properties(autosize='fit-x')
37+
st.altair_chart(chart, width='stretch')

0 commit comments

Comments
 (0)