[AdvancedLayouts] Add width to st.altair_chart#12608
Conversation
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) |
✅ PR preview is ready!
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new width parameter to st.altair_chart that follows the standardized Width type system ("stretch", "content", or pixel values), while also beginning the deprecation process for the existing use_container_width parameter.
Key changes include:
- Addition of the new
widthparameter with automatic defaults based on chart type - Deprecation warnings and migration logic for
use_container_width - Comprehensive test coverage for the new width functionality
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
lib/streamlit/elements/vega_charts.py |
Adds width parameter, deprecation handling, and documentation for st.altair_chart |
lib/tests/streamlit/elements/vega_charts_test.py |
Comprehensive test suite for width parameter functionality and deprecation behavior |
e2e_playwright/st_vega_charts_width.py |
Adds E2E test case for altair chart with fixed width |
e2e_playwright/st_vega_charts_width_test.py |
Updates test expectations to include new altair chart test case |
e2e_playwright/st_altair_chart_title.py |
Migrates from use_container_width to new width parameter |
e2e_playwright/st_altair_chart_basic_select.py |
Migrates from use_container_width to new width parameter |
e2e_playwright/st_altair_chart.py |
Migrates from use_container_width to new width parameter |
.gitignore
Outdated
| **/uber-raw-data-sep14.csv | ||
|
|
||
| # Prompts directory | ||
| Prompts/ |
There was a problem hiding this comment.
nit: can this better match the existing naming convention of our folders?
There was a problem hiding this comment.
Also out of curiosity, what is going in here?
There was a problem hiding this comment.
This wasn't supposed to be included in this PR. This is just a folder I have been keeping some prompt files in locally. Separate from this PR I agree we should align on a directory structure for this kind of thing. I don't have anything I want to check in currently, but we should have the folder with a .gitignore rule.
Describe your changes
Adds a new
widthparameter tost.altair_chartusing theWidthtype system ("stretch","content", or pixel values) for consistency with other chart elements.Changes Made:
width: Width | None = Noneparameterstretchin most cases, but for certain charts (e.g. facet) the default iscontentGitHub Issue Link (if applicable)
Testing Plan
Screenshots/Demos:
Additional Notes:
This extends the AdvancedLayouts initiative by adding width support to
st.altair_chart, bringing it in line with other chart elements that support theWidthtype system.This PR also begins the process of deprecating
use_container_width. The default is updated toNone, andwidthwill be used instead. If the user explicitly passes a value foruse_container_widththen that will take precedence.use_container_width=Trueis equivalent towidth="stretch"anduse_container_width=Falseis equivalent towidth="content". The user will be given a warning and suggestion to usewidthinstead. We will removeuse_container_widthafter 12-31-2025.Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.