Skip to content

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

Open
bikash-barnwal wants to merge 1 commit into
apache:masterfrom
bikash-barnwal:fix/gantt-yaxis-label-truncation
Open

fix(echarts): reserve grid room for Gantt category names#43189
bikash-barnwal wants to merge 1 commit into
apache:masterfrom
bikash-barnwal:fix/gantt-yaxis-label-truncation

Conversation

@bikash-barnwal

Copy link
Copy Markdown

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

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) <noreply@anthropic.com>
@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 evan@preset.io.

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 66.65%. Comparing base (f458721) to head (ef92916).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #43189   +/-   ##
=======================================
  Coverage   66.64%   66.65%           
=======================================
  Files        2873     2873           
  Lines      163625   163630    +5     
  Branches    37767    37769    +2     
=======================================
+ Hits       109053   109061    +8     
+ Misses      52442    52439    -3     
  Partials     2130     2130           
Flag Coverage Δ
javascript 73.76% <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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:frontend Requires changing the frontend plugins size/M viz:charts:echarts Related to Echarts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gantt chart y axis labels are cut off

2 participants