Skip to content

Commit d733bc4

Browse files
committed
adjust ex tooltip.order, rename vars / calc stack util
1 parent df130cd commit d733bc4

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

src/component/tooltip/seriesFormatTooltip.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ export function defaultSeriesFormatTooltip(opt: {
7575
// Difference between the cumulative sum including this series and the cumulative sum before
7676
// this series gives its individual contribution.
7777
if (!isNaN(stackTop) && !isNaN(stackBottom)) {
78-
const percentVal = stackTop - stackBottom;
79-
inlineValue = `${inlineValue} (${percentVal.toFixed(1)}%)`;
78+
const percentValue = stackTop - stackBottom;
79+
inlineValue = `${inlineValue} (${percentValue.toFixed(1)}%)`;
8080
}
8181
}
8282
}

src/layout/barGrid.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,13 @@ export function createProgressiveLayout(seriesType: string): StageHandler {
525525
// stackResultDimension directly.
526526
if (stacked) {
527527
if (isPercentStack) {
528+
// For 'percent' stackStrategy, use the normalized bottom edge (stackedOverDimension)
529+
// as the start value of the bar segment.
528530
stackStartValue = store.get(stackedOverDimIdx, dataIndex);
529531
}
530532
else {
533+
// For standard (non-percent) stackStrategy, subtract the original value from the
534+
// stacked total to compute the bar segment's start value.
531535
stackStartValue = +value - (store.get(valueDimIdx, dataIndex) as number);
532536
}
533537
}

src/processor/dataStack.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ export default function dataStack(ecModel: GlobalModel) {
7171
calculatePercentStack(stackInfoList);
7272
}
7373
else {
74-
calculateStack(stackInfoList);
74+
calculateStandardStack(stackInfoList);
7575
}
7676
});
7777
}
7878

79-
function calculateStack(stackInfoList: StackInfo[]) {
79+
function calculateStandardStack(stackInfoList: StackInfo[]) {
8080
each(stackInfoList, function (targetStackInfo, idxInStack) {
8181
const resultVal: number[] = [];
8282
const resultNaN = [NaN, NaN];

test/percent-stack.html

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)