Files
admin-govern/src/utils/echartMethod.ts

27 lines
671 B
TypeScript
Raw Normal View History

2024-09-29 18:15:54 +08:00
export const yMethod = (arr: any) => {
let maxValue = 0
let minValue = 0
let max = 0
let min = 0
maxValue = Math.max(...arr)
minValue = Math.min(...arr)
2024-10-21 09:09:56 +08:00
if (maxValue > 1000 ||minValue < -1000) {
2024-09-29 18:15:54 +08:00
max = Math.ceil(maxValue / 100) * 100
2024-10-14 20:15:54 +08:00
if (minValue == 0) {
min = 0
} else {
2024-10-21 09:09:56 +08:00
min = (Math.floor(minValue / 100) ) * 100
2024-10-14 20:15:54 +08:00
}
2024-09-29 18:15:54 +08:00
} else {
max = Math.ceil(maxValue / 10) * 10
min = Math.floor(minValue / 10) * 10
}
2024-10-10 09:56:34 +08:00
if (maxValue > 0 && maxValue < 1) {
2024-09-29 18:15:54 +08:00
max = 1
2024-10-14 20:15:54 +08:00
} else if (max == 0 && minValue > -1 && minValue < 0) {
2024-10-10 09:56:34 +08:00
min = -1
2024-10-14 20:15:54 +08:00
}
2024-10-21 09:09:56 +08:00
return [min, max]
2024-09-29 18:15:54 +08:00
}