TimeSeries: Fix log y scale when min/max settings don't land on divisors (#60768)

This commit is contained in:
Leon Sorokin 2023-01-27 06:52:01 -06:00 committed by GitHub
parent 6bfd21ef0a
commit 52955d88a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -116,7 +116,7 @@ export class UPlotScaleBuilder extends PlotConfigBuilder<ScaleProps, Scale> {
minMax = uPlot.rangeNum(hardMinOnly ? hardMin : dataMin, hardMaxOnly ? hardMax : dataMax, rangeConfig);
}
} else if (scale.distr === 3) {
minMax = uPlot.rangeLog(dataMin!, dataMax!, logBase, true);
minMax = uPlot.rangeLog(hardMin ?? dataMin!, hardMax ?? dataMax!, logBase, true);
}
if (decimals === 0) {
@ -154,6 +154,7 @@ export class UPlotScaleBuilder extends PlotConfigBuilder<ScaleProps, Scale> {
}
}
if (scale.distr === 1) {
// if all we got were hard limits, treat them as static min/max
if (hardMinOnly) {
minMax[0] = hardMin!;
@ -162,6 +163,7 @@ export class UPlotScaleBuilder extends PlotConfigBuilder<ScaleProps, Scale> {
if (hardMaxOnly) {
minMax[1] = hardMax!;
}
}
// guard against invalid y ranges
if (minMax[0]! >= minMax[1]!) {