mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
fix(echarts): fix stacked horizontal bar chart clipping and duplicate x-axis labels (#39012)
This commit is contained in:
committed by
GitHub
parent
38f0dc74f7
commit
022342839a
@@ -659,7 +659,10 @@ export default function transformProps(
|
||||
for (const s of series) {
|
||||
if (s.id) {
|
||||
const columnsArr = labelMap[s.id];
|
||||
(s as any).stack = columnsArr[idxSelectedDimension];
|
||||
const dimensionValue = columnsArr?.[idxSelectedDimension];
|
||||
if (dimensionValue !== undefined) {
|
||||
(s as any).stack = dimensionValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -682,9 +685,24 @@ export default function transformProps(
|
||||
|
||||
// For horizontal bar charts, set max/min from calculated data bounds
|
||||
if (shouldCalculateDataBounds) {
|
||||
// Set max to actual data max to avoid gaps and ensure labels are visible
|
||||
if (dataMax !== undefined && yAxisMax === undefined) {
|
||||
yAxisMax = dataMax;
|
||||
// For stacked charts, clamp against the per-row stacked total to avoid
|
||||
// clipping bars. Also keep dataMax so that mixed-sign stacks (where
|
||||
// positive and negative values cancel in the algebraic row sum) cannot
|
||||
// produce an axis max smaller than the largest individual positive segment.
|
||||
const stackedTotalMax = Math.max(
|
||||
...sortedTotalValues.filter(
|
||||
(v): v is number => typeof v === 'number' && !Number.isNaN(v),
|
||||
),
|
||||
);
|
||||
const effectiveDataMax = stack
|
||||
? Math.max(dataMax ?? Number.NEGATIVE_INFINITY, stackedTotalMax)
|
||||
: dataMax;
|
||||
if (
|
||||
effectiveDataMax !== undefined &&
|
||||
Number.isFinite(effectiveDataMax) &&
|
||||
yAxisMax === undefined
|
||||
) {
|
||||
yAxisMax = effectiveDataMax;
|
||||
}
|
||||
// Set min to actual data min for diverging bars
|
||||
if (dataMin !== undefined && yAxisMin === undefined && dataMin < 0) {
|
||||
|
||||
Reference in New Issue
Block a user