找了好久才找到得,感谢大佬得分享
function getOptInterval(intv){
if (intv > 5){
return intv;
} else if (intv>2){
return intv * 2;
} else {
return 10;
}
}
function generateAxis(start, end){
let dif = end - start;
let mag = Math.round(Math.log10(dif));
let n = parseInt(dif / (10**mag)) +1;
let n1 = getOptInterval(n);
let l = n * (10**mag) / n1;
let optStart = parseInt(parseInt(start)/l) * l;
if (optStart < start){
optStart += l;
}
let result = [];
for (int i = 0; i <= n1; i++){
result.push(optStart + i * l);
}
return result;
}
源地址:
暂无评论