Skip to content

fix(echarts): reserve grid room for Gantt category names - #43189

Merged
rusackas merged 4 commits into
apache:masterfrom
bikash-barnwal:fix/gantt-yaxis-label-truncation
Sep 29, 2026
Merged

rusackas merged 4 commits into
apache:masterfrom
bikash-barnwal:fix/gantt-yaxis-label-truncation

Conversation

@bikash-barnwal

Copy link
Copy Markdown
Contributor

SUMMARY

Gantt chart category names are cut off on the left.

They are not axis labels — they are rendered as markLine labels anchored to the start of the grid (Gantt/transformProps.ts, position: 'start', formatter: '{b}'). grid.containLabel only 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 renamed measureLegendTextWidth → measureTextWidth and 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

cd superset-frontend
npm run test -- plugins/plugin-chart-echarts/test

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.ts was updated: its exhaustive toEqual on the category markLine series now includes the new width / overflow label fields.

Manually: build a Gantt chart whose y-axis dimension has long values and confirm the names render fully rather than clipped.

ADDITIONAL INFORMATION

  • Has associated issue: Fixes Gantt chart y axis labels are cut off #38844
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

🤖 Generated with Claude Code

@dosubot dosubot Bot added change:frontend Requires changing the frontend viz:charts:echarts Related to Echarts labels Aug 14, 2026
@bito-code-review

bito-code-review Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #1dc4fb

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: ef92916..ef92916
    • superset-frontend/plugins/plugin-chart-echarts/src/Gantt/constants.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Gantt/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Gantt/transformProps.test.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@codecov

codecov Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.07%. Comparing base (9ad6917) to head (5b23e13).

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           
Flag Coverage Δ
javascript 76.43% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 markLine labels past the cap via overflow: 'truncate' + fixed width.
  • 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.

@rusackas

rusackas commented Sep 4, 2026

Copy link
Copy Markdown
Member

Nice approach on the cap + truncation, @bikash-barnwal.

measureTextWidth measures at theme.fontSizeSM (series.ts), but the markLine label in transformProps.ts only sets color, no fontSize. If it renders at a different size than fontSizeSM, the reserved width won't match the real label and we could still clip (or over-truncate) for some themes. Can you confirm those line up, or pass the label's actual font size into the measurement?

Also, TEXT_WIDTH_CACHE is unbounded and now keyed on Gantt category names instead of just legend labels, which could be much higher cardinality over a long session, worth capping while you're in there.

@pull-request-size pull-request-size Bot added size/L and removed size/M labels Sep 5, 2026
@bikash-barnwal

Copy link
Copy Markdown
Contributor Author

Fixed both:

  • Set fontSize: theme.fontSizeSM on the markLine label so it always matches what measureTextWidth assumed. Added an assertion pinning that in the existing grid-room test.
  • Capped TEXT_WIDTH_CACHE at 2000 entries with LRU eviction (re-insert on hit to track recency, evict the oldest on overflow). Added dedicated cache tests: hit/miss by cache key, and eviction of the least-recently-used entry once full.

All tests pass locally (both files).

@netlify

netlify Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 5b23e13
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6ab57f6a2c35ca0007f4b645
😎 Deploy Preview https://deploy-preview-43189--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Sep 5, 2026
@bito-code-review

bito-code-review Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #f5dc82

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: ef92916..186ed38
    • superset-frontend/plugins/plugin-chart-echarts/src/Gantt/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Gantt/transformProps.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/series.test.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas rusackas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

bikashJMV and others added 2 commits September 8, 2026 20:36
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]>
@rusackas
rusackas force-pushed the fix/gantt-yaxis-label-truncation branch from 186ed38 to 944058a Compare September 9, 2026 03:38
@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Sep 9, 2026
@bito-code-review

bito-code-review Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #875bfb

Actionable Suggestions - 0
Review Details
  • Files reviewed - 5 · Commit Range: 8f42ab0..944058a
    • superset-frontend/plugins/plugin-chart-echarts/src/Gantt/constants.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Gantt/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Gantt/transformProps.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/series.test.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Sep 12, 2026
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]>
@github-actions github-actions Bot added risk:chart-metadata and removed requires:rebase Requires rebasing on top of current master labels Sep 22, 2026
@rusackas
rusackas merged commit a374f84 into apache:master Sep 29, 2026
83 checks passed
villebro pushed a commit that referenced this pull request Sep 30, 2026
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gantt chart y axis labels are cut off

6 participants