feat(stack by dimension): add a stack by dimension dropdown list (#32707)

Co-authored-by: CAPELLI Giampaolo <giampaolo.capelli@docaposte.fr>
This commit is contained in:
Giampaolo Capelli
2025-05-22 16:10:18 +02:00
committed by GitHub
parent 875f538d54
commit 5b2f1bbf9e
3 changed files with 53 additions and 1 deletions

View File

@@ -191,6 +191,7 @@ export default function transformProps(
yAxisTitleMargin,
yAxisTitlePosition,
zoomable,
stackDimension,
}: EchartsTimeseriesFormData = { ...DEFAULT_FORM_DATA, ...formData };
const refs: Refs = {};
const groupBy = ensureIsArray(groupby);
@@ -418,6 +419,23 @@ export default function transformProps(
}
});
if (
stack === StackControlsValue.Stack &&
stackDimension &&
chartProps.rawFormData.groupby
) {
const idxSelectedDimension =
formData.metrics.length > 1
? 1
: 0 + chartProps.rawFormData.groupby.indexOf(stackDimension);
for (const s of series) {
if (s.id) {
const columnsArr = labelMap[s.id];
(s as any).stack = columnsArr[idxSelectedDimension];
}
}
}
// axis bounds need to be parsed to replace incompatible values with undefined
const [xAxisMin, xAxisMax] = (xAxisBounds || []).map(parseAxisBound);
let [yAxisMin, yAxisMax] = (yAxisBounds || []).map(parseAxisBound);