[fix] Clip chart overflow in narrow columns#15505
Draft
sfc-gh-lwilby-1 wants to merge 3 commits into
Draft
Conversation
Co-authored-by: Laura Wilby <[email protected]>
Co-authored-by: Laura Wilby <[email protected]>
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Co-authored-by: Laura Wilby <[email protected]>
Contributor
✅ PR preview is ready!
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes
Vega-Lite/Altair charts that size via
autosize: pad(facet charts and nested compositions likevconcat+hconcat) render an SVG whose total width is driven by the plotting area plus axes, facet panels, and padding. Vega-Lite'swidthonly controls the plotting area, so the rendered SVG can be wider than its wrapper. In a narrowst.columnscell the chart then spilled out of its column/card and overlapped neighboring elements.Clip the rendered chart to the wrapper bounds (
max-width: 100%+overflow: hidden) only for these pad-sized charts. Simplefit/fit-xcharts already match the wrapper exactly, so they are left untouched — clipping them would crop edge axis labels and is unnecessary.isFacet || hasNestedComp, the same conditions the backend uses to chooseautosize: pad..chart-wrapper, so it is not affected by the clip.Screenshot or video (only for visual changes)
Faceted line charts inside cards in narrow columns.
Before (charts overflow and overlap neighboring cards):
Before fix - facet charts overflow narrow columns
After (charts are clipped to their card bounds):
After fix - facet charts clipped to card bounds
GitHub Issue Link (if applicable)
N/A
Testing Plan
st_vega_lite_chart_test.pyandst_vega_charts_height_test.pypass unchanged. Inst_vega_charts_width_test.pythe facet/nested charts share a page with simple charts; clipping the faceted charts produces an imperceptible (~1.8%) sub-pixel shift of the sibling simple charts on that page, so the four affected width snapshots (width_content[chromium],width_content/width_stretch/width_400px[firefox]) were regenerated. Local Linux rendering reproduced CI's pixel diffs exactly; webkit/chromium-stretch/400px were unaffected.ArrowVegaLiteChartsuite passes (127 tests).Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.
To show artifacts inline, enable in settings.