Skip to content

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

Closed
s1ny1998 wants to merge 1 commit into
apache:mobile-dashboard-supportfrom
s1ny1998:fix/echarts-yaxis-title-margin
Closed

fix(echarts): only reserve left grid padding when a Y-axis title exists#43064
s1ny1998 wants to merge 1 commit into
apache:mobile-dashboard-supportfrom
s1ny1998:fix/echarts-yaxis-title-margin

Conversation

@s1ny1998

@s1ny1998 s1ny1998 commented Aug 11, 2026

Copy link
Copy Markdown

SUMMARY

On mobile, timeseries charts render with a large blank strip on the left: the plot area starts roughly a third of the way into the card, well outside the tick labels.

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 50px of plot area.
  • 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 this, Gantt charts that do have a title would lose their title padding.
  • Add a getPadding() unit test for the no-title case.

Affected chart families: Timeseries (line/bar/area/scatter/smooth), Mixed Timeseries, Box Plot, Gantt. Bubble already passed true unconditionally and is unchanged.

This is negligible on wide desktop charts and very visible on narrow ones, which is why it surfaced in mobile consumption mode.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before: plot area begins ~95px into a ~320px-wide mobile chart (70px reserved margin + tick-label width), leaving the series squeezed into the right portion of the card.
image

After: only gridOffsetLeft (20px) plus the tick-label width is reserved, and the series fills the card.
image

TESTING INSTRUCTIONS

  1. Open any timeseries line chart on a dashboard and leave Customize → Chart Title → Y Axis Title empty (the default).
  2. View the dashboard at a mobile width (~390px). The plot area should start just after the Y-axis tick labels, with no blank strip before them.
  3. Set a Y Axis Title with position Left and a non-zero margin. The reserved space returns and the rotated title renders inside it, unchanged from before.
  4. Repeat step 3 with position Top to confirm top spacing is untouched.
  5. Check a Gantt chart both with and without a Y-axis title.

Unit tests:

npm run test -- plugins/plugin-chart-echarts/test

56 suites / 655 tests pass, including the new getPadding case.

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.
@bito-code-review

bito-code-review Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped - Branch Excluded

Bito didn't auto-review because the source or target branch is excluded from automatic reviews.
No action is needed if you didn't intend for the agent to review it. Otherwise, to manually trigger a review, type /review in a comment and save.
You can change the branch exclusion settings here, or contact your Bito workspace admin at evan@preset.io.

@netlify

netlify Bot commented Aug 11, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit c5560bd
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a7b34600246ad0008564cb3
😎 Deploy Preview https://deploy-preview-43064--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.

@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.80%. Comparing base (3cd6720) to head (c5560bd).

Additional details and impacted files
@@                    Coverage Diff                    @@
##           mobile-dashboard-support   #43064   +/-   ##
=========================================================
  Coverage                     65.80%   65.80%           
=========================================================
  Files                          2845     2845           
  Lines                        162333   162335    +2     
  Branches                      37256    37258    +2     
=========================================================
+ Hits                         106822   106824    +2     
  Misses                        53446    53446           
  Partials                       2065     2065           
Flag Coverage Δ
javascript 72.07% <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

Copy link
Copy Markdown
Author

Waiting on @rusackas for approval. Hence marked as draft.

@sadpandajoe
sadpandajoe deleted the branch apache:mobile-dashboard-support August 13, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants