feat: 优化管理看板组件中的图表最大值计算逻辑,支持动态计算并处理小数位数

This commit is contained in:
danial
2025-05-09 00:55:06 +08:00
parent 44b0fb3962
commit 4f9f324bc5

View File

@@ -402,7 +402,7 @@ const { chartOption } = useChartOption(() => {
axisLabel: {
formatter(value: any, idx: number) {
if (idx === 0) return value;
return `${value}k`;
return `${value}`;
}
},
splitLine: {
@@ -420,13 +420,16 @@ const { chartOption } = useChartOption(() => {
return legendSelected.value[name as keyof LegendSelected];
});
// 否则返回订单的最大值
const maxValue = Math.max(
...visibleSeries.map(series =>
series.data.reduce((sum, value) => sum + value, 0)
)
);
return Math.ceil(maxValue + 1); // 向上取整到最接近的千位
// 返回订单所有数据的最大值
let maxValue = 0;
visibleSeries.forEach(series => {
maxValue = Math.max(maxValue, Math.max(...series.data));
});
// 判断数字出多少位,数字中可能有小数
return (
Math.ceil(maxValue + 1) +
Math.pow(10, maxValue.toFixed().length - 1)
); // 向上取整到最接近的千位
}
},
{