From 70adfa21ae99d95b3a762cf2e1087783725f315b Mon Sep 17 00:00:00 2001 From: jianneng-fit2cloud Date: Mon, 2 Sep 2024 22:00:40 +0800 Subject: [PATCH] =?UTF-8?q?style(=E5=9B=BE=E8=A1=A8-=E8=AF=8D=E4=BA=91?= =?UTF-8?q?=E5=9B=BE):=20=E4=BC=98=E5=8C=96=E5=A4=A7=E5=B0=8F=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E4=B8=AD=E7=9A=84=E6=9C=80=E5=A4=A7=E6=9C=80=E5=B0=8F?= =?UTF-8?q?=E5=80=BC=EF=BC=8C=E5=BD=93=E6=B8=85=E7=A9=BA=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=A1=86=E6=97=B6=EF=BC=8C=E8=A1=A5=E5=85=A8=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E7=9A=84=E6=9C=80=E5=A4=A7=E6=9C=80=E5=B0=8F=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/chart/components/js/util.ts | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/core/core-frontend/src/views/chart/components/js/util.ts b/core/core-frontend/src/views/chart/components/js/util.ts index 4a4110bfe0..fcd478a1e7 100644 --- a/core/core-frontend/src/views/chart/components/js/util.ts +++ b/core/core-frontend/src/views/chart/components/js/util.ts @@ -630,13 +630,19 @@ export const getMaxAndMinValueByData = ( minValue: number, callback: (max: number, min: number) => void ) => { - if (minValue === 0 && maxValue === 0) { - const maxResult = data.reduce((max, current) => { - return current[field] > max ? current[field] : max - }, Number.MIN_SAFE_INTEGER) - const minResult = data.reduce((min, current) => { - return current[field] < min ? current[field] : min - }, Number.MAX_SAFE_INTEGER) + if ((minValue === 0 && maxValue === 0) || minValue === null || maxValue === null) { + let maxResult = maxValue + let minResult = minValue + if (maxResult === null) { + maxResult = data.reduce((max, current) => { + return current[field] > max ? current[field] : max + }, Number.MIN_SAFE_INTEGER) + } + if (minResult === null) { + minResult = data.reduce((min, current) => { + return current[field] < min ? current[field] : min + }, Number.MAX_SAFE_INTEGER) + } callback(maxResult, minResult) } }