Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 19 additions & 0 deletions src/chart/bar/BarView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -783,9 +783,28 @@ const elementCreator: {
rect.name = 'item';

if (animationModel) {
const isStacked = seriesModel.get('stack') != null;
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, regardless of 'inverse'
const stackAnimateProperty = isHorizontal ? 'y' : 'x' as 'y' | 'x';
const itemLayout = data.getItemLayout(newIndex);
// valueAxisStart is unset only when `large` is true,
// in which case this branch is not taken
const valueAxisStart = itemLayout.valueAxisStart;

// make sure we don't go beyond the grid
const coordSys = (seriesModel.coordinateSystem as Cartesian2D);
const valueAxis = coordSys.getOtherAxis(coordSys.getBaseAxis());
const extentStart = valueAxis.getGlobalExtent()[0];
// compare with extentStart in the same direction as the stackAnimateProperty
const cmpFn = (valueAxis.inverse === isHorizontal) ? mathMax : mathMin;

rectShape[stackAnimateProperty] = cmpFn(valueAxisStart, extentStart);
}
}
return rect;
},
Expand Down
2 changes: 1 addition & 1 deletion src/layout/barGrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ export function createProgressiveLayout(seriesType: string): StageHandler {
}

if (!isLarge) {
data.setItemLayout(dataIndex, { x, y, width, height });
data.setItemLayout(dataIndex, { x, y, width, height, valueAxisStart });
}
else {
largePoints[idxOffset] = x;
Expand Down
Loading