fix(gantt): prevent y-axis category labels from being clipped - #44321
aminghadersohi wants to merge 1 commit into
Conversation
The Gantt Y-axis category labels are markLine annotations whose reserved grid width was computed from measureText's advance width and a font string that never matched the rendered label's actual font (which inherited zrender's default). Glyphs that paint past their advance width (e.g. descenders, italics) were left clipped by a few pixels. Measure using the same font the label is rendered in, and take the larger of the advance width and the canvas ink bounding box (actualBoundingBoxLeft/Right) when computing the reserved space.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #44321 +/- ##
==========================================
- Coverage 80.26% 80.25% -0.01%
==========================================
Files 2927 2927
Lines 173238 173244 +6
Branches 40169 40171 +2
==========================================
Hits 139045 139045
- Misses 31601 31607 +6
Partials 2592 2592
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
The flagged issue is correct. When category labels are long, they can exceed the reserved grid space, causing clipping or pushing the plotting area out of view. The current PR already implements a robust fix for this by:
Since this PR already contains the fix for the reported issue, no further action is required for this specific comment. superset-frontend/plugins/plugin-chart-echarts/src/Gantt/transformProps.ts |
Code Review Agent Run #92732bActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
SUMMARY
The Gantt chart's Y-axis category labels are custom text annotations (drawn via an ECharts
markLinelabel rather than a normal axis label), and the chart reserves horizontal space for them by measuring their text width on an offscreen canvas. That measurement usedcanvas.measureText(...).width(the glyph advance width) with a font string built from theme tokens that never actually matched the font the label was rendered with. Two issues compounded:font, while the rendered label had nofontSize/fontFamilyof its own.Either gap could leave the reserved left margin a few pixels too narrow, clipping part of the label.
This PR:
fontSize/fontFamilytokens to both the measurement canvas and the rendered label, so they can no longer diverge.actualBoundingBoxLeft+actualBoundingBoxRight) when computing the reserved width, falling back to the advance width when bounding-box metrics aren't available.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — this is a sub-pixel text-measurement fix; the visual difference is a few pixels of margin on the Y-axis and isn't meaningfully capturable in a screenshot.
TESTING INSTRUCTIONS
npm run test -- plugins/plugin-chart-echarts/test/Gantt— includes new regression tests asserting the reserved label width uses the canvas ink extent (not just the advance width) and that the measurement font matches the rendered label's font.ADDITIONAL INFORMATION