2024-09-29 18:15:54 +08:00
|
|
|
import { install$2 } from 'echarts/types/dist/shared'
|
|
|
|
|
|
|
|
|
|
export const yMethod = (arr: any) => {
|
|
|
|
|
console.log('🚀 ~ yMethod ~ arr:', arr)
|
|
|
|
|
let interval = 0
|
|
|
|
|
let maxValue = 0
|
|
|
|
|
let minValue = 0
|
|
|
|
|
let max = 0
|
|
|
|
|
let min = 0
|
|
|
|
|
maxValue = Math.max(...arr)
|
|
|
|
|
minValue = Math.min(...arr)
|
|
|
|
|
|
2024-09-30 16:32:16 +08:00
|
|
|
console.log('🚀 ~ yMethod ~ minValue:', minValue,maxValue)
|
2024-09-29 18:15:54 +08:00
|
|
|
|
|
|
|
|
// interval = (maxValue - minValue) / 4
|
|
|
|
|
// if (maxValue > 1000) {
|
|
|
|
|
// interval = (Math.ceil(maxValue / 100) * 100 - Math.ceil(minValue / 100) * 100) / 4
|
|
|
|
|
// min = Math.floor((minValue - interval / 2) / 100) * 100
|
|
|
|
|
// max = Math.ceil((maxValue + interval / 2) / 100) * 100
|
|
|
|
|
// min >= 0 ? 0 : ''
|
|
|
|
|
// } else {
|
|
|
|
|
// min = Math.floor(minValue - interval / 2)
|
|
|
|
|
// max = Math.ceil(maxValue + interval / 2)
|
|
|
|
|
// console.log('🚀 ~ yMethod ~ minValue:', minValue)
|
|
|
|
|
|
|
|
|
|
// if (minValue >= 0 && minValue < 10) {
|
|
|
|
|
// min = 0
|
|
|
|
|
// }
|
|
|
|
|
// if (maxValue < 1 && maxValue >= 0) {
|
|
|
|
|
// max = 1
|
|
|
|
|
// }
|
|
|
|
|
// interval = (max - min) / 4
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// if (interval < 1 && interval > -1) {
|
|
|
|
|
// interval = 1
|
|
|
|
|
// }
|
|
|
|
|
// console.log("🚀 ~ yMethod ~ minValue:", minValue)
|
|
|
|
|
|
|
|
|
|
if (maxValue > 1000) {
|
|
|
|
|
max = Math.ceil(maxValue / 100) * 100
|
|
|
|
|
min = (Math.floor(minValue / 100) - 1) * 100
|
|
|
|
|
} else {
|
|
|
|
|
max = Math.ceil(maxValue / 10) * 10
|
|
|
|
|
min = Math.floor(minValue / 10) * 10
|
|
|
|
|
}
|
|
|
|
|
if (max > 0 && max < 1) {
|
|
|
|
|
max = 1
|
|
|
|
|
}
|
|
|
|
|
// if (min < 0 && min < -1) {
|
|
|
|
|
// min = -1
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
return [min, max, interval]
|
|
|
|
|
}
|