Skip to content

[AdvancedLayouts] Add width to st.pydeck_chart#12576

Merged
sfc-gh-lwilby merged 5 commits intodevelopfrom
feature/add-width-to-pydeck-chart
Sep 22, 2025
Merged

[AdvancedLayouts] Add width to st.pydeck_chart#12576
sfc-gh-lwilby merged 5 commits intodevelopfrom
feature/add-width-to-pydeck-chart

Conversation

@sfc-gh-lwilby
Copy link
Copy Markdown
Collaborator

@sfc-gh-lwilby sfc-gh-lwilby commented Sep 19, 2025

Describe your changes

Modernizes st.pydeck_chart width parameter to use the new Width type system ("stretch" or pixel values) and deprecates the use_container_width parameter for consistency with other chart elements.

This PR also begins the process of deprecating use_container_width. The default is updated to None, and width will be used instead. If the user explicitly passes a value for use_container_width then that will take precedence. use_container_width=True is equivalent to width="stretch" and setting the width to an integer can be done without setting use_container_width. The user will be given a warning and suggestion to use width instead. We will remove use_container_width after 12-31-2025.

Changes Made:

  • Updated parameter signature: Changed width: int | None = None to width: WidthWithoutContent = "stretch"
  • Deprecated use_container_width: Changed from bool = True to bool | None = None with deprecation warnings
  • Preserved backward compatibility: Existing integer width values and use_container_width behavior still work
  • Updated layout system: Uses LayoutConfig(width=width) instead of direct proto field assignment
  • Enhanced parameter validation: Validates width parameter with appropriate error messages

Key Implementation Details:

Width Parameter Modernization:

  • Breaking change: Default changes from width=None to width="stretch"
  • Intelligent fallback: When use_container_width=False, preserves existing integer width values instead of converting to "content"

Backward Compatibility & Deprecation:

Deprecation Timeline: use_container_width will be removed after 12-31-2025.

Parameter Precedence: If user explicitly passes use_container_width, it takes precedence over width:

  • use_container_width=Truewidth="stretch" (overrides width parameter)
  • use_container_width=Falsewidth="content" (overrides width parameter)

Intelligent Fallback: When use_container_width=False with existing integer widths:

  • use_container_width=False + width=400width=400 (preserves integer)
  • use_container_width=False + width="content"width="content"
  • use_container_width=False + width="stretch"width="content" (fallback)

User Experience: Users receive deprecation warnings with suggestions to use width parameter instead.

GitHub Issue Link (if applicable)

Testing Plan

  • Unit Tests (Python) - New width parameter functionality
  • Unit Tests (Python) - use_container_width backward compatibility with deprecation warnings
  • Unit Tests (Python) - Native chart width extraction
  • E2E Tests - Visual width behavior across different values (width="content", width="stretch", width=400)
  • Manual testing completed for all width scenarios
Screenshot 2025-09-19 at 2 12 27 PM

Additional Notes:
This follows the established pattern from st.vega_lite_chart, st.line_chart, and st.plotly_chart. Part of the broader AdvancedLayouts initiative to provide consistent width APIs across all chart elements.


Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@sfc-gh-lwilby sfc-gh-lwilby requested a review from a team as a code owner September 19, 2025 12:47
@sfc-gh-lwilby sfc-gh-lwilby added security-assessment-completed change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users labels Sep 19, 2025
@snyk-io
Copy link
Copy Markdown
Contributor

snyk-io bot commented Sep 19, 2025

🎉 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)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 19, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-12576/streamlit-1.49.1-py3-none-any.whl
🕹️ Preview app pr-12576.streamlit.app (☁️ Deploy here if not accessible)

@sfc-gh-lwilby sfc-gh-lwilby changed the title [AdvancedLayouts] Add width to st.pydeck_chart [WIP][AdvancedLayouts] Add width to st.pydeck_chart Sep 19, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 19, 2025

📈 Frontend coverage change detected

The frontend unit test (vitest) coverage has increased by 0.0300%

  • Current PR: 84.9500% (47579 lines, 7160 missed)
  • Latest develop: 84.9200% (47596 lines, 7174 missed)

🎉 Great job on improving test coverage!

📊 View detailed coverage comparison

@sfc-gh-lwilby sfc-gh-lwilby changed the title [WIP][AdvancedLayouts] Add width to st.pydeck_chart [AdvancedLayouts] Add width to st.pydeck_chart Sep 19, 2025
@sfc-gh-lwilby sfc-gh-lwilby merged commit 58e2fea into develop Sep 22, 2025
38 checks passed
@sfc-gh-lwilby sfc-gh-lwilby deleted the feature/add-width-to-pydeck-chart branch September 22, 2025 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants