Skip to content

fix(plugin-chart-echarts): misplaced first date label on horizontal bar charts - #43661

Merged
hainenber merged 1 commit into
apache:masterfrom
rlei-odes:fix/echarts-horizontal-boundary-label-align
Aug 29, 2026
Merged

hainenber merged 1 commit into
apache:masterfrom
rlei-odes:fix/echarts-horizontal-boundary-label-align

Conversation

@rlei-odes

Copy link
Copy Markdown
Contributor

SUMMARY

On a bar chart with Orientation: Horizontal and a time x-axis, the first
date label sits out of line with the rest and is partly cut off. Every other
label on that axis is fine.

The cause is an alignment written for a bottom axis being applied to one that
has moved to the side. The transform forces the boundary labels on a time axis
so the first and last dates stay visible, and aligns them inward so they do not
overhang the plot area:

...(showMaxLabel && {
  showMaxLabel: true,
  alignMaxLabel: 'right',
  showMinLabel: true,
  alignMinLabel: 'left',
}),

alignMinLabel: 'left' / alignMaxLabel: 'right' are horizontal text
alignments, correct for an axis running along the bottom: they pull the first
and last labels inward, away from the left and right edges.

But the condition that emits them tests the axis type, never the orientation:

const showMaxLabel =
  xAxisType === AxisType.Time && xAxisLabelRotation === 0 && !!resolvedTimeGrain;

A horizontal chart then swaps the axes ([xAxis, yAxis] = [yAxis, xAxis]), so
that block lands on a vertical axis, where labels normally sit right-aligned
against the axis line. Re-anchoring the minimum label to 'left' shifts it out
of column with its neighbours. Only the minimum receives alignMinLabel, which
is why only the first label moves.

The fix keeps showMinLabel/showMaxLabel in both orientations — forcing the
boundary dates visible is wanted either way — and applies the alignment only
when the axis is actually along the bottom. There is precedent a few lines
below, where the rotated-label padding compensation is already guarded with
!isHorizontal.

Vertical charts are unaffected: !isHorizontal is true there, so both spreads
apply and the axis receives the same four properties as before.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Every label is identically right-aligned in both, except the bottom one:
clipped to "2…" before, a clean "2003" after.

label_misplaced_before_after

TESTING INSTRUCTIONS

Unit test: npm run test -- plugins/plugin-chart-echarts/test/Timeseries/transformProps

Manually:

  1. Build a Bar chart on a temporal column with a time grain set (Month works),
    leave X Axis label rotation at 0, and set Orientation: Horizontal.
    The first date label lines up with the others.
  2. On master, the same chart shows that label shifted sideways and partly cut
    off.
  3. Switch back to Vertical and confirm nothing has changed: the first and
    last labels are still pulled inward, away from the chart edges.
  4. Set X Axis label rotation to a non-zero value in either orientation.
    Boundary labels are not forced at all in that case, before or after this
    change.

Note the rotation control is a quick way to confirm the diagnosis rather than
part of the fix: a non-zero rotation makes showMaxLabel false, which disables
the whole block.

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

…ar charts

The transform forces the boundary labels on a time axis so the first and
last dates stay visible, and aligns them inward so they do not overhang the
plot area:

  alignMaxLabel: 'right',
  alignMinLabel: 'left',

Those are horizontal text alignments, correct for an axis along the bottom.
But the condition emitting them tests the axis type, never the orientation,
and a horizontal chart swaps the axes — so the block lands on a vertical
axis and shifts the first label out of column with the rest.

Apply the alignment only when the axis is along the bottom. The boundary
labels stay forced in both orientations.
@dosubot dosubot Bot added viz:charts:bar Related to the Bar chart viz:charts:echarts Related to Echarts labels Aug 28, 2026
@bito-code-review

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

Copy link
Copy Markdown
Contributor

Code Review Agent Run #2be38b

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

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.21%. Comparing base (5c24f72) to head (83185fa).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #43661   +/-   ##
=======================================
  Coverage   79.21%   79.21%           
=======================================
  Files        2879     2879           
  Lines      165949   165951    +2     
  Branches    38389    38391    +2     
=======================================
+ Hits       131452   131454    +2     
  Misses      32020    32020           
  Partials     2477     2477           
Flag Coverage Δ
javascript 74.67% <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.

@rusackas
rusackas requested review from msyavuz and rusackas August 29, 2026 03:15

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

LGTM. Thank you

@hainenber
hainenber merged commit 74ea780 into apache:master Aug 29, 2026
91 checks passed
@rlei-odes
rlei-odes deleted the fix/echarts-horizontal-boundary-label-align branch August 29, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugins size/M viz:charts:bar Related to the Bar chart viz:charts:echarts Related to Echarts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants