Repository navigation
fix(echarts): reserve grid room for Gantt category names - #43189
Conversation
Code Review Agent Run #1dc4fbActionable 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #43189 +/- ##
=======================================
Coverage 81.07% 81.07%
=======================================
Files 2955 2955
Lines 178364 178363 -1
Branches 41319 41317 -2
=======================================
+ Hits 144610 144612 +2
+ Misses 31044 31041 -3
Partials 2710 2710
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:
|
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Fixes Gantt chart category names being clipped on the left by reserving grid space for markLine-rendered labels (which grid.containLabel does not account for).
Changes:
- Measure the widest Gantt category name and add that width (capped) to
grid.left. - Truncate category
markLinelabels past the cap viaoverflow: 'truncate'+ fixedwidth. - Generalize and export text measurement helper (
measureLegendTextWidth→measureTextWidth) and add/adjust tests.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| superset-frontend/plugins/plugin-chart-echarts/src/Gantt/transformProps.ts | Computes capped category label width, applies it to markLine label + grid left padding. |
| superset-frontend/plugins/plugin-chart-echarts/src/Gantt/constants.ts | Adds constants controlling category-label padding and width cap ratio. |
| superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts | Renames/exports text width measurer and reuses it for legend + other callers. |
| superset-frontend/plugins/plugin-chart-echarts/test/Gantt/transformProps.test.ts | Updates existing expectation and adds a regression test for reserved grid space + truncation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Nice approach on the cap + truncation, @bikash-barnwal.
Also, |
|
Fixed both:
All tests pass locally (both files). |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Code Review Agent Run #f5dc82Actionable 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 |
rusackas
left a comment
There was a problem hiding this comment.
Thanks for tightening those up, @bikash-barnwal, the fontSize match and the LRU cache look right to me now.
This has picked up a conflict with master though, needs a rebase before it can move forward. Attempting that now...
Gantt renders its category names as markLine labels anchored to the start of the grid. `grid.containLabel` only accounts for axis labels, so a name wider than the default left padding was drawn into the plot area and clipped. Measure the widest category name and add that to the grid's left padding, capped at a quarter of the chart width so one long category cannot eat the plot, and give the label that same width with `overflow: 'truncate'` so anything past the cap ends in an ellipsis rather than overflowing. The text measurement already existed for legend layout; it is renamed from measureLegendTextWidth to measureTextWidth and exported, since it is no longer legend-specific. Its cache is renamed to match. Fixes apache#38844 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…h cache Two issues flagged in review: - The reserved grid width for category names was computed with measureTextWidth() at theme.fontSizeSM, but the markLine label that actually renders the name only set `color`, no `fontSize`, so ECharts fell back to its own default. If that default ever diverges from fontSizeSM the reserved width silently stops matching what's drawn. Set fontSize explicitly so the two always agree. - TEXT_WIDTH_CACHE is shared with plain legend labels and had no bound; Gantt now also keys it on category names, which can be much higher-cardinality than legend labels over a long session. Cap it and evict the least-recently-used entry once full. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
186ed38 to
944058a
Compare
Code Review Agent Run #875bfbActionable 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 |
Another already-merged PR independently added grid-space reservation for Gantt category labels (`maxCategoryLabelWidth`, canvas-measured, uncapped, +10px gap) since this branch opened -- the same problem this PR's `categoryLabelWidth` (capped via MAX_CATEGORY_LABEL_WIDTH_RATIO, computed with the shared `measureTextWidth` helper so it stays consistent with what's actually rendered) already solves more completely. Took this PR's side for the grid.left conflict and removed the now-fully-unused `maxCategoryLabelWidth`/manual-canvas-measureContext block from the series-building loop (only consumer was the replaced line; `categoryLines`/`borderLines` built by the same loop are still needed and untouched). Fixed one pre-existing gap surfaced by actually running the tests, not introduced by this merge: `should transform chart props` in transformProps.test.ts asserted the category markLine's label object without the `fontSize: theme.fontSizeSM` field this PR's source already sets (a separate, newer test in the same file already covers that field in isolation, but this older full-object assertion was never updated to match). This was the CI failure already showing on the PR (sharded-jest-tests) before any rebase. Verified for real: ran the full Gantt test directory (8 tests) after the fix, all green; oxlint and oxfmt --check pass on both touched files. Co-Authored-By: Evan Rusackas <[email protected]> Co-Authored-By: Claude Sonnet 5 <[email protected]>
Co-authored-by: bikashJMV <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]> Co-authored-by: Evan Rusackas <[email protected]> Co-authored-by: SBIN2010 <[email protected]> (cherry picked from commit a374f84)
SUMMARY
Gantt chart category names are cut off on the left.
They are not axis labels — they are rendered as
markLinelabels anchored to the start of the grid (Gantt/transformProps.ts,position: 'start',formatter: '{b}').grid.containLabelonly reserves space for axis labels, so a category name wider than the default left padding gets drawn into the plot area and clipped by the chart edge.The fix measures the widest category name and adds it to the grid's left padding, capped at a quarter of the chart width so one very long category cannot eat the plot. The label is given that same width with
overflow: 'truncate', so anything past the cap ends in an ellipsis instead of overflowing whatever was reserved.The text measurement already existed for legend layout, canvas-based with a cache and a character-width fallback when there is no
document. It is renamedmeasureLegendTextWidth→measureTextWidthand exported, since it is no longer legend-specific; the cache constant is renamed to match. No behavior change for the legend.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before: long category names truncated by the plot edge with no ellipsis, some unreadable.
After: the grid shifts right to fit the names; names beyond 25% of chart width end in an ellipsis.
TESTING INSTRUCTIONS
773 tests across 69 suites pass (the whole echarts plugin, since the shared measurement helper was touched). The new test asserts that a long category reserves more left padding than a short one, that the label truncates, and that the reserved width stays within the 25% cap.
One existing expectation in
Gantt/transformProps.test.tswas updated: its exhaustivetoEqualon the categorymarkLineseries now includes the newwidth/overflowlabel fields.Manually: build a Gantt chart whose y-axis dimension has long values and confirm the names render fully rather than clipped.
ADDITIONAL INFORMATION
🤖 Generated with Claude Code