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) {