From 74e8cfe43ce489d88be4e5b42e3e1631ab27f51b Mon Sep 17 00:00:00 2001 From: GGJ <357021191@qq.com> Date: Tue, 29 Oct 2024 16:32:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9echart=20y=E8=BD=B4=E5=A4=84?= =?UTF-8?q?=E7=90=86=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/echartMethod.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/utils/echartMethod.ts b/src/utils/echartMethod.ts index fe190e2..a3c9d0f 100644 --- a/src/utils/echartMethod.ts +++ b/src/utils/echartMethod.ts @@ -1,11 +1,18 @@ +const dataProcessing = (arr: any[]) => { + return arr + .filter(item => typeof item === 'number' || (typeof item === 'string' && !isNaN(parseFloat(item)))) + .map(item => (typeof item === 'number' ? item : parseFloat(item))) +} + // 处理y轴最大最小值 export const yMethod = (arr: any) => { + let numList = dataProcessing(arr) let maxValue = 0 let minValue = 0 let max = 0 let min = 0 - maxValue = Math.max(...arr) - minValue = Math.min(...arr) + maxValue = Math.max(...numList) + minValue = Math.min(...numList) if (maxValue > 1000 || minValue < -1000) { max = Math.ceil(maxValue / 100) * 100 if (minValue == 0) {