chartLine = {
getScale: (min, max, dist) => {
min = Math.floor(min / dist) * dist;
max = Math.ceil(max / dist) * dist;
let length = (max - min) / dist;
let arr = [];
for (let i = 0; i < length; i++) {
arr.push(min + dist * i);
}
return arr
},
getDist: (height, min, max, dist) => {
let arr = chartLine.getScale(min, max, dist)
return arr
}
}
let min = 19, max = 85, distance = 20;
let arr = chartLine.getDist(600, min, max, distance);
console.log(arr)
console.log(arr.findIndex((val) => { return val == 0 })) // 找不到 0 的时候返回 -1
console