Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(axis): allow stacking on value xAxis #19653

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/data/helper/dataStackHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ export function enableDataStack(
let stackResultDimension: string;
let stackedOverDimension: string;

const yCoordDimension = dimensionDefineList.find(
dimensionInfo => !isString(dimensionInfo) && dimensionInfo.coordDim === 'y'
) as SeriesDimensionDefine | undefined;
const isYCoordDimensionStackable = yCoordDimension != null
&& yCoordDimension.type !== 'ordinal' && yCoordDimension.type !== 'time';

each(dimensionDefineList, function (dimensionInfo, index) {
if (isString(dimensionInfo)) {
dimensionDefineList[index] = dimensionInfo = {
Expand All @@ -110,6 +116,7 @@ export function enableDataStack(
if (!stackedDimInfo
&& dimensionInfo.type !== 'ordinal'
&& dimensionInfo.type !== 'time'
&& (yCoordDimension == null || (dimensionInfo.coordDim !== 'x' && isYCoordDimensionStackable))
&& (!stackedCoordDimension || stackedCoordDimension === dimensionInfo.coordDim)
) {
stackedDimInfo = dimensionInfo;
Expand All @@ -123,6 +130,12 @@ export function enableDataStack(
byIndex = true;
}

if (stackedDimInfo && !byIndex && !stackedByDimInfo) {
// Compatible with previous design, value axis (time axis) only stack by index.
// It may make sense if the user provides elaborately constructed data.
byIndex = true;
}

// Add stack dimension, they can be both calculated by coordinate system in `unionExtent`.
// That put stack logic in List is for using conveniently in echarts extensions, but it
// might not be a good way.
Expand Down