Skip to content

fix(echarts): only reserve left grid padding when a Y-axis title exists - #43299

Merged
rusackas merged 4 commits into
apache:masterfrom
s1ny1998:fix/echarts-yaxis-title-left-padding
Sep 21, 2026
Merged

rusackas merged 4 commits into
apache:masterfrom
s1ny1998:fix/echarts-yaxis-title-left-padding

Conversation

@s1ny1998

@s1ny1998 s1ny1998 commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

SUMMARY

Timeseries charts render with a large blank strip on the left: the plot area starts well inside the card, far outside the tick labels. It is barely noticeable on a wide desktop chart, but it eats roughly a third of the plot area on a narrow one.

The cause is in getPadding() (plugins/plugin-chart-echarts/src/Timeseries/transformers.ts):

left:
  yAxisTitlePosition === 'Left'
    ? TIMESERIES_CONSTANTS.gridOffsetLeft + (Number(yAxisTitleMargin) || 0)
    : TIMESERIES_CONSTANTS.gridOffsetLeft,

The Y-axis title margin is added whenever the title position is 'Left', without checking that a title is actually rendered. The control defaults (sections/chartTitle.tsx) are position 'Left' and margin 50, so every chart with an empty y_axis_title — the default — reserves 20 + 50 = 70px on the left. Because grid.containLabel is enabled, that reservation sits outside the axis labels, so it is pure dead space.

The guard already exists: callers compute addYAxisTitleOffset = !!yAxisTitle && convertInteger(yAxisTitleMargin) !== 0, and the 'Top' position branch consumes it. Only the 'Left' branch ignored it.

Changes:

  • Gate the left title margin on addYAxisTitleOffset. Charts with a Y-axis title keep exactly the spacing they have today; charts without one reclaim the 50px.
  • Gantt/transformProps.ts hardcoded false for that flag at both getPadding() call sites while relying on the 'Left' branch for its left padding, so it now computes the flag properly and passes it to both. Without that, gating the left branch would have silently removed Gantt's title spacing.
  • Added a getPadding() unit test covering the no-title case.

This supersedes #43064, which was closed while in draft. Same change, rebased onto current master with a clean history.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — the visible effect is the left grid offset shrinking from 70px to 20px on charts with no Y-axis title, which is easiest to confirm with the testing instructions below.

BEFORE :
image
AFTER :
image

TESTING INSTRUCTIONS

Unit tests:

cd superset-frontend
npm run test -- plugins/plugin-chart-echarts/test/Timeseries/transformers.test.ts

Manually:

  1. Create a Line Chart (or any ECharts timeseries viz) and leave Customize → Y Axis title empty.
  2. Before this change the plot area starts ~70px from the left edge, leaving a visible blank strip outside the tick labels. After it, the strip is gone and the chart fills the card.
  3. Set a Y Axis title with position Left. Spacing is unchanged from current behaviour — the title still gets its 50px margin.
  4. Repeat with a Gantt chart, with and without a Y-axis title, to confirm its padding is unchanged when a title is set.

ADDITIONAL INFORMATION

  • Has associated issue:
  • 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

getPadding() added y_axis_title_margin to the left grid offset whenever
y_axis_title_position was 'Left', without checking that a Y-axis title
was actually rendered. Since the control defaults are position 'Left'
and margin 50, every timeseries chart with no Y-axis title reserved 70px
on the left. With grid.containLabel enabled that space sits outside the
tick labels, so it is pure dead space. It is unnoticeable on a wide
desktop chart but consumes roughly a third of the plot area on a phone.

Gate the left margin on the existing addYAxisTitleOffset flag, which
callers already compute as `!!yAxisTitle && margin !== 0`, and have Gantt
pass that flag instead of a hardcoded false so it keeps its padding when
a title is present.
@dosubot dosubot Bot added change:frontend Requires changing the frontend viz:charts:echarts Related to Echarts viz:charts:timeseries Related to Timeseries labels Aug 18, 2026
@bito-code-review

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

Copy link
Copy Markdown
Contributor

Code Review Agent Run #2f3b05

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: 4e5029f..4e5029f
    • superset-frontend/plugins/plugin-chart-echarts/src/Gantt/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformers.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

Comment on lines 798 to 805
// The title margin is only reserved when a Y-axis title is actually
// rendered. Without this guard every chart pays for the default
// margin, which eats a large share of the plot area on narrow charts.
left:
yAxisTitlePosition === 'Left'
yAxisTitlePosition === 'Left' && addYAxisTitleOffset
? TIMESERIES_CONSTANTS.gridOffsetLeft +
(Number(yAxisTitleMargin) || 0)
: TIMESERIES_CONSTANTS.gridOffsetLeft,

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.

Suggestion: The new comment claims the title margin is reserved only when a title is rendered, but the top branch still adds yAxisTitleMargin whenever yAxisTitlePosition is Top, even when addYAxisTitleOffset is false. Timeseries and MixedTimeseries therefore continue reserving the default top margin for charts without a Y-axis title. Gate the top margin with the same rendered-title condition, or narrow the comment so it only describes the left branch. [comment mismatch]

Severity Level: Major ⚠️
- ⚠️ Timeseries charts waste top plot space with empty titles.
- ⚠️ MixedTimeseries charts retain unnecessary top padding.
- ⚠️ Narrow charts lose usable vertical plotting area.

Use CodeAnt Skill

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts
**Line:** 798:805
**Comment:**
	*Comment Mismatch: The new comment claims the title margin is reserved only when a title is rendered, but the `top` branch still adds `yAxisTitleMargin` whenever `yAxisTitlePosition` is `Top`, even when `addYAxisTitleOffset` is false. Timeseries and MixedTimeseries therefore continue reserving the default top margin for charts without a Y-axis title. Gate the top margin with the same rendered-title condition, or narrow the comment so it only describes the left branch.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is correct. In superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts, the getPadding function's top branch currently adds yAxisTitleMargin unconditionally when yAxisTitlePosition is 'Top', regardless of whether a title is actually rendered (i.e., addYAxisTitleOffset is false). This causes unnecessary top padding for charts without a Y-axis title.

To resolve this, you should gate the top margin calculation with the addYAxisTitleOffset condition, similar to how the left branch is handled. Here is the corrected implementation for the top property:

      top:
        yAxisTitlePosition === 'Top' && addYAxisTitleOffset
          ? TIMESERIES_CONSTANTS.gridOffsetTop + (Number(yAxisTitleMargin) || 0)
          : TIMESERIES_CONSTANTS.gridOffsetTop,

I have checked the PR comments, and there are no other pending review comments to address. Would you like me to check for any other potential issues in this file?

superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts

top:
        yAxisTitlePosition === 'Top' && addYAxisTitleOffset
          ? TIMESERIES_CONSTANTS.gridOffsetTop + (Number(yAxisTitleMargin) || 0)
          : TIMESERIES_CONSTANTS.gridOffsetTop,

@codecov

codecov Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.14%. Comparing base (b20ad09) to head (278c9a2).
⚠️ Report is 202 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #43299   +/-   ##
=======================================
  Coverage   80.14%   80.14%           
=======================================
  Files        2924     2924           
  Lines      172407   172409    +2     
  Branches    40028    40030    +2     
=======================================
+ Hits       138175   138177    +2     
  Misses      31647    31647           
  Partials     2585     2585           
Flag Coverage Δ
javascript 75.66% <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.

s1ny1998 and others added 2 commits August 19, 2026 10:47
The `top` branch of `getPadding()` added `yAxisTitleMargin` whenever the
title position was `Top`, without checking that a title is actually
rendered — the same defect the `left` branch had. Charts with an empty
`y_axis_title` and position `Top` therefore reserved the default 50px of
dead space above the plot area.

Gate it on `addYAxisTitleOffset`, the flag callers already compute as
`!!yAxisTitle && convertInteger(yAxisTitleMargin) !== 0`, so the fall
through yields the bare `gridOffsetTop`. Charts with a title keep their
existing spacing. Adds a `getPadding()` test for the no-title `Top` case.
@bito-code-review

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

Copy link
Copy Markdown
Contributor

Code Review Agent Run #e7fb0e

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 4e5029f..3ebf761
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformers.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

@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 the writeup and the before/after shots, this is a clean fix and catching that Gantt's two getPadding call sites needed the same flag is a nice catch too. CI's green, this looks mergeable to me.

@rusackas
rusackas merged commit b8cc2a7 into apache:master Sep 21, 2026
82 checks passed
villebro pushed a commit that referenced this pull request Sep 22, 2026
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 viz:charts:timeseries Related to Timeseries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants