Skip to content

[AdvancedLayouts] Add height to st.altair_chart#12630

Merged
sfc-gh-lwilby merged 3 commits intodevelopfrom
feature/vega-height
Sep 25, 2025
Merged

[AdvancedLayouts] Add height to st.altair_chart#12630
sfc-gh-lwilby merged 3 commits intodevelopfrom
feature/vega-height

Conversation

@sfc-gh-lwilby
Copy link
Copy Markdown
Collaborator

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

Describe your changes

Adds a new height parameter to st.altair_chart using the Height type system ("stretch", "content", or pixel values) for consistency with other chart elements.

Changes Made:

  • Added new parameter: Added height: Height = "content" parameter to st.altair_chart
  • Added comprehensive height support:
    • height="content" (default): Respects Altair chart's native height if specified in chart properties
    • height="stretch": Expands to fill the parent container's height
    • height=<integer>: Sets fixed pixel height
  • Enhanced parameter validation: Validates height parameter with appropriate error messages for invalid values
  • Comprehensive test coverage: Added E2E tests and unit tests covering all height scenarios

Key Implementation Details:

Height Parameter Addition:

  • New functionality: Adds height parameter with default height="content"
  • Native height support: height="content" extracts height from native Altair chart object if available
  • Container-based sizing: height="stretch" properly fills parent containers (tested in 500px container)
  • Flexible sizing: Supports integer values for fixed pixel heights

GitHub Issue Link (if applicable)

Part of the AdvancedLayouts initiative

Testing Plan

  • Unit Tests (Python) - New height parameter functionality with parameterized tests
  • Unit Tests (Python) - Parameter validation and error handling
  • Unit Tests (Python) - Default behavior verification (height="content")
  • Unit Tests (Python) - Compatibility with chart selections
  • E2E Tests - Visual height behavior validation across all scenarios:
    • Fixed height values (height=250)
    • Content-based sizing (height="content" with chart spec height=180)
    • Container-based sizing (height="stretch" in 500px container)
  • Manual testing completed for all height scenarios

Screenshots/Demos:
(E2E test snapshots show visual differences for all height behaviors: fixed pixels, content-based, and container stretching)

Screenshot 2025-09-25 at 1 21 31 PM

Additional Notes:

This extends the AdvancedLayouts initiative by adding height support to st.altair_chart, bringing it in line with other chart elements that support the Height type system. The default of height="content" ensures backward compatibility while enabling users to override with "stretch" for responsive designs or specific pixel values for fixed layouts.


Contribution License Agreement

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

- Adds height parameter using Height type system for consistency
- Includes E2E tests for visual height behavior validation
- Updates backend implementation with native chart height support
- Adds comprehensive unit tests for height parameter functionality
@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 25, 2025
@snyk-io
Copy link
Copy Markdown
Contributor

snyk-io bot commented Sep 25, 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 25, 2025

✅ PR preview is ready!

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

@sfc-gh-lwilby sfc-gh-lwilby marked this pull request as ready for review September 25, 2025 12:05
@sfc-gh-lwilby sfc-gh-lwilby changed the title [WIP][AdvancedLayouts] Add height to st.altair_chart [AdvancedLayouts] Add height to st.altair_chart Sep 25, 2025
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
@sfc-gh-lwilby sfc-gh-lwilby merged commit 517eba6 into develop Sep 25, 2025
38 checks passed
@sfc-gh-lwilby sfc-gh-lwilby deleted the feature/vega-height branch September 25, 2025 17:40
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