Skip to content
Merged
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
29 changes: 24 additions & 5 deletions src/processor/dataStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,34 @@ export default function dataStack(ecModel: GlobalModel) {
return;
}

stackInfoList.length && data.setCalculationInfo(
'stackedOnSeries', stackInfoList[stackInfoList.length - 1].seriesModel
);

stackInfoList.push(stackInfo);
}
});

stackInfoMap.each(calculateStack);
// Process each stack group
stackInfoMap.each(function (stackInfoList) {
if (stackInfoList.length === 0) {
return;
}
// Check if stack order needs to be reversed
const firstSeries = stackInfoList[0].seriesModel;
const stackOrder = firstSeries.get('stackOrder') || 'seriesAsc';

if (stackOrder === 'seriesDesc') {
stackInfoList.reverse();
}

// Set stackedOnSeries for each series in the final order
each(stackInfoList, function (stackInfo, index) {
stackInfo.data.setCalculationInfo(
'stackedOnSeries',
index > 0 ? stackInfoList[index - 1].seriesModel : null
);
});

// Calculate stack values
calculateStack(stackInfoList);
});
}

function calculateStack(stackInfoList: StackInfo[]) {
Expand Down
1 change: 1 addition & 0 deletions src/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1679,6 +1679,7 @@ export interface SeriesLargeOptionMixin {
export interface SeriesStackOptionMixin {
stack?: string
stackStrategy?: 'samesign' | 'all' | 'positive' | 'negative';
stackOrder?: 'seriesAsc' | 'seriesDesc'; // default: seriesAsc
}

type SamplingFunc = (frame: ArrayLike<number>) => number;
Expand Down
281 changes: 281 additions & 0 deletions test/bar-stack-reverse.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading