mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-08 16:49:01 +08:00
[Fix]: range issue in uplot charts (#4262)
* fix: range issue in uplot charts * refactor: updated logic to strickly check is parsed value is number * refactor: safe check for number value
This commit is contained in:
parent
6b2f03d43f
commit
f487c1956b
@ -1,5 +1,6 @@
|
|||||||
import { ThresholdProps } from 'container/NewWidget/RightContainer/Threshold/types';
|
import { ThresholdProps } from 'container/NewWidget/RightContainer/Threshold/types';
|
||||||
import { convertValue } from 'lib/getConvertedValue';
|
import { convertValue } from 'lib/getConvertedValue';
|
||||||
|
import { isFinite } from 'lodash-es';
|
||||||
import { QueryDataV3 } from 'types/api/widgets/getQuery';
|
import { QueryDataV3 } from 'types/api/widgets/getQuery';
|
||||||
|
|
||||||
function findMinMaxValues(data: QueryDataV3[]): [number, number] {
|
function findMinMaxValues(data: QueryDataV3[]): [number, number] {
|
||||||
@ -9,9 +10,10 @@ function findMinMaxValues(data: QueryDataV3[]): [number, number] {
|
|||||||
entry.series?.forEach((series) => {
|
entry.series?.forEach((series) => {
|
||||||
series.values.forEach((valueObj) => {
|
series.values.forEach((valueObj) => {
|
||||||
const value = parseFloat(valueObj.value);
|
const value = parseFloat(valueObj.value);
|
||||||
if (!value) return;
|
if (isFinite(value)) {
|
||||||
min = Math.min(min, value);
|
min = Math.min(min, value);
|
||||||
max = Math.max(max, value);
|
max = Math.max(max, value);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -82,5 +84,10 @@ export const getYAxisScale = (
|
|||||||
if (areAllSeriesEmpty(series)) return { auto: true };
|
if (areAllSeriesEmpty(series)) return { auto: true };
|
||||||
|
|
||||||
const [min, max] = getRange(thresholds, series, yAxisUnit);
|
const [min, max] = getRange(thresholds, series, yAxisUnit);
|
||||||
|
|
||||||
|
// Min and Max value can be same if the value is same for all the series
|
||||||
|
if (min === max) {
|
||||||
|
return { auto: true };
|
||||||
|
}
|
||||||
return { auto: false, range: [min, max] };
|
return { auto: false, range: [min, max] };
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user