-
Notifications
You must be signed in to change notification settings - Fork 4k
Closed
Labels
feature:st.altair_chartRelated to the `st.altair_chart` elementRelated to the `st.altair_chart` elementpriority:P3Medium priorityMedium prioritystatus:confirmedBug has been confirmed by the Streamlit teamBug has been confirmed by the Streamlit teamtype:bugSomething isn't working as expectedSomething isn't working as expected
Description
Checklist
- I have searched the existing issues for similar issues.
- I added a very descriptive title to this issue.
- I have provided sufficient information below to help reproduce this issue.
Summary
When an altair line or scatter chart is first rendered, if there is a legend on the bottom instead of the default on the right side, than the chart is initially shown with the Y axis label and Y numbers partially cut off. If you trigger a rerender, either once or twice, than the full chart shows up.
Reproducible Code Example
import streamlit as st
import pandas as pd
import altair as alt
st.title("Altair Chart cut-off bug")
df = pd.DataFrame(
{"x": [1, 2, 3, 4], "y": [1, 2, 3, 4], "category": ["A", "B", "C", "D"]}
)
chart = (
alt.Chart(df)
.mark_line(point=True)
.encode(
x=alt.X("x", title="Date"),
y=alt.Y("y:Q", title="Legend Value"),
color=alt.Color("category:N", title="Category").legend(
orient="bottom", title=None
),
)
)
st.write("use_container_width=True")
st.altair_chart(chart, use_container_width=True)
# THE REST OF THIS JUST SHOWS MORE EXAMPLES
st.write("use_container_width=False")
st.altair_chart(chart, use_container_width=False)
st.write("No bottom legend")
# This one renders properly initially
chart = (
alt.Chart(df)
.mark_line(point=True)
.encode(
x=alt.X("x", title="Date"),
y=alt.Y("y:Q", title="Legend Value"),
color=alt.Color("category:N", title="Category"),
)
)
st.altair_chart(chart, use_container_width=True)
st.button("Rerender")Steps To Reproduce
- Load the app, and see that the y axis is cut off
- Hit the rerender button twice to see it fully show the chart
Expected Behavior
The chart should show fully on the initial load
Current Behavior
No response
Is this a regression?
- Yes, this used to work in a previous version.
Debug info
- Streamlit version: 1.37.1
- Python version: 3.10.3
- Operating System: OSX
- Browser: Chrome
Additional Information
Tested also on 1.35 on Streamlit-in-Snowflake, same behavior
github-actions, sfc-gh-maliu, aumisb, mateusamp and apomohaci-ness
Metadata
Metadata
Assignees
Labels
feature:st.altair_chartRelated to the `st.altair_chart` elementRelated to the `st.altair_chart` elementpriority:P3Medium priorityMedium prioritystatus:confirmedBug has been confirmed by the Streamlit teamBug has been confirmed by the Streamlit teamtype:bugSomething isn't working as expectedSomething isn't working as expected
