TimeSeries: fix negative stacked percent y-axis range (#57470) (#57478)

(cherry picked from commit 45707ccf99)

Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2022-10-21 16:41:45 -06:00
committed by GitHub
co-authored by Leon Sorokin
parent a318b15cab
commit c4233171f2
@@ -223,7 +223,14 @@ export const preparePlotConfigBuilder: UPlotConfigPrepFn<{
softMin: customConfig.axisSoftMin,
softMax: customConfig.axisSoftMax,
centeredZero: customConfig.axisCenteredZero,
range: customConfig.stacking?.mode === StackingMode.Percent ? [0, 1] : undefined,
range:
customConfig.stacking?.mode === StackingMode.Percent
? (u: uPlot, dataMin: number, dataMax: number) => {
dataMin = dataMin < 0 ? -1 : 0;
dataMax = dataMax > 0 ? 1 : 0;
return [dataMin, dataMax];
}
: undefined,
decimals: field.config.decimals,
},
field