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

This commit is contained in:
Leon Sorokin 2022-10-21 16:45:00 -05:00 committed by GitHub
parent 1f3d34ecda
commit 45707ccf99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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