修改echart y轴处理方案

This commit is contained in:
GGJ
2024-10-29 16:32:32 +08:00
parent 16f9f433a7
commit 74e8cfe43c

View File

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