最大值用 Math.max()算出来
if (endsetwholeData) {
endsetwholeData.forEach((item) => {
if (item.value) {
maxarrs.push(item.value);
}
});
}
maxnums = Math.max(...maxarrs);
// 设置区间
const formatvalues = (value, maxnum) => {
if (maxnum >= 0) {
let num = 0;
let number = 0;
const maxheight = 400; // 可视化最大值的高
num = value / maxnum;
if (num * maxheight < 5) { // 最小值的高
number = 5;
} else if (num * maxheight >= 400) {// 可视化最大值的高
number = 400;
} else {// 区间中按比例来
number = num * maxheight;
}
return number;
}
};
调用 formatvalues(每一个值,最大值)