mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-08 18:39:01 +08:00
fix: the min data point as 0 in time series (#4203)
This commit is contained in:
parent
c0b0920901
commit
cb1a823f91
@ -3,8 +3,8 @@ import { convertValue } from 'lib/getConvertedValue';
|
|||||||
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] {
|
||||||
let min = 0;
|
let min = Number.MAX_SAFE_INTEGER;
|
||||||
let max = 0;
|
let max = Number.MIN_SAFE_INTEGER;
|
||||||
data?.forEach((entry) => {
|
data?.forEach((entry) => {
|
||||||
entry.series?.forEach((series) => {
|
entry.series?.forEach((series) => {
|
||||||
series.values.forEach((valueObj) => {
|
series.values.forEach((valueObj) => {
|
||||||
@ -23,20 +23,18 @@ function findMinMaxThresholdValues(
|
|||||||
thresholds: ThresholdProps[],
|
thresholds: ThresholdProps[],
|
||||||
yAxisUnit?: string,
|
yAxisUnit?: string,
|
||||||
): [number, number] {
|
): [number, number] {
|
||||||
let minThresholdValue = 0;
|
let minThresholdValue =
|
||||||
let maxThresholdValue = 0;
|
thresholds[0].thresholdValue || Number.MAX_SAFE_INTEGER;
|
||||||
|
let maxThresholdValue =
|
||||||
|
thresholds[0].thresholdValue || Number.MIN_SAFE_INTEGER;
|
||||||
|
|
||||||
thresholds.forEach((entry) => {
|
thresholds.forEach((entry) => {
|
||||||
const { thresholdValue, thresholdUnit } = entry;
|
const { thresholdValue, thresholdUnit } = entry;
|
||||||
if (thresholdValue === undefined) return;
|
if (thresholdValue === undefined) return;
|
||||||
minThresholdValue = Math.min(
|
const compareValue = convertValue(thresholdValue, thresholdUnit, yAxisUnit);
|
||||||
minThresholdValue,
|
if (compareValue === null) return;
|
||||||
convertValue(thresholdValue, thresholdUnit, yAxisUnit) || 0,
|
minThresholdValue = Math.min(minThresholdValue, compareValue);
|
||||||
);
|
maxThresholdValue = Math.max(maxThresholdValue, compareValue);
|
||||||
maxThresholdValue = Math.max(
|
|
||||||
maxThresholdValue,
|
|
||||||
convertValue(thresholdValue, thresholdUnit, yAxisUnit) || 0,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return [minThresholdValue, maxThresholdValue];
|
return [minThresholdValue, maxThresholdValue];
|
||||||
@ -79,7 +77,7 @@ export const getYAxisScale = (
|
|||||||
auto: boolean;
|
auto: boolean;
|
||||||
range?: [number, number];
|
range?: [number, number];
|
||||||
} => {
|
} => {
|
||||||
if (!thresholds || !series) return { auto: true };
|
if (!thresholds || !series || thresholds.length === 0) return { auto: true };
|
||||||
|
|
||||||
if (areAllSeriesEmpty(series)) return { auto: true };
|
if (areAllSeriesEmpty(series)) return { auto: true };
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user