Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/chart/bar/BarView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -783,9 +783,18 @@ const elementCreator: {
rect.name = 'item';

if (animationModel) {
const isStacked = seriesModel.get('stack') !== undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!= null should be better.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 444c75d

const rectShape = rect.shape;
const animateProperty = isHorizontal ? 'height' : 'width' as 'width' | 'height';
rectShape[animateProperty] = 0;
if (isStacked) {
// if it's stacked, the bar will be animated from the
// 'bottom' of the value axis, irregardless of 'inverse'
Copy link

Copilot AI Mar 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Replace 'irregardless' with 'regardless' for clarity and formal tone.

Suggested change
// 'bottom' of the value axis, irregardless of 'inverse'
// 'bottom' of the value axis, regardless of 'inverse'

Copilot uses AI. Check for mistakes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 444c75d

const stackAnimateProperty = isHorizontal ? 'y' : 'x' as 'y' | 'x';
const coordSys = (seriesModel.coordinateSystem as Cartesian2D);
const extent = coordSys.getOtherAxis(coordSys.getBaseAxis()).getGlobalExtent()[0];
Copy link
Contributor

@Ovilia Ovilia Mar 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extent[0] is the minimum value of the axis, which may not be expected to be the starting point of bar growing in the case with negative axes. Consider using startValue instead. Make sure you test the cases in varied value ranges.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep seems like you are correct, for test/bar-stack.html I edited the yAxis to have a startValue: -30 and min: -100 and it animates from the bottom (first 2s):

image

nani.mp4

The other half of the video describes a bug (not sure): the right most bar stack in that video isn't placed correctly (not respecting startValue). And by toggling the 'bottom'-most series of the stacked bar chart, the problem fixes itself. I can raise this in a issue if this is confirmed to be a bug.

I'll fix the startValue issue in a bit;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 444c75d - but will add tests in another commit

rectShape[stackAnimateProperty] = extent;
}
}
return rect;
},
Expand Down