Repository navigation
fix(plugin-chart-echarts): misplaced first date label on horizontal bar charts - #43661
Conversation
…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.
Code Review Agent Run #2be38bActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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:
alignMinLabel: 'left'/alignMaxLabel: 'right'are horizontal textalignments, 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:
A horizontal chart then swaps the axes (
[xAxis, yAxis] = [yAxis, xAxis]), sothat 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 outof column with its neighbours. Only the minimum receives
alignMinLabel, whichis why only the first label moves.
The fix keeps
showMinLabel/showMaxLabelin both orientations — forcing theboundary 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:
!isHorizontalis true there, so both spreadsapply 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.
TESTING INSTRUCTIONS
Unit test:
npm run test -- plugins/plugin-chart-echarts/test/Timeseries/transformPropsManually:
leave X Axis label rotation at 0, and set Orientation: Horizontal.
The first date label lines up with the others.
off.
last labels are still pulled inward, away from the chart edges.
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
showMaxLabelfalse, which disablesthe whole block.
ADDITIONAL INFORMATION