feat: 优化管理看板组件中的图表数据处理逻辑,简化最大值计算并移除冗余代码
This commit is contained in:
@@ -89,10 +89,7 @@ import useChartOption from '@/hooks/chart-option';
|
|||||||
import { ToolTipFormatterParams } from '@/types/echarts';
|
import { ToolTipFormatterParams } from '@/types/echarts';
|
||||||
import { AnyObject } from '@/types/global';
|
import { AnyObject } from '@/types/global';
|
||||||
import { apiClient } from '@/api';
|
import { apiClient } from '@/api';
|
||||||
import {
|
import { KamiApiOrderV1OrderSummaryDailyRecord } from '@/api/generated';
|
||||||
ApiOrderInfoSummaryGetListGetPageSizeEnum,
|
|
||||||
KamiApiOrderV1OrderSummaryDailyRecord
|
|
||||||
} from '@/api/generated';
|
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { LegendComponentOption } from 'echarts';
|
import { LegendComponentOption } from 'echarts';
|
||||||
|
|
||||||
@@ -417,23 +414,13 @@ const { chartOption } = useChartOption(() => {
|
|||||||
},
|
},
|
||||||
min: 0,
|
min: 0,
|
||||||
max: function (value: { min: number; max: number }) {
|
max: function (value: { min: number; max: number }) {
|
||||||
// 获取当前显示的数据系列
|
|
||||||
const visibleSeries = seriesData.value.filter((_, index) => {
|
|
||||||
const name = ['成功订单量', '总订单量', '成功率'][index];
|
|
||||||
return legendSelected.value[name as keyof LegendSelected];
|
|
||||||
});
|
|
||||||
|
|
||||||
// 如果是成功率,返回 100
|
|
||||||
if (visibleSeries.some(s => s.name === '成功率')) {
|
|
||||||
return 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 否则返回订单量的最大值
|
// 否则返回订单量的最大值
|
||||||
const maxValue = Math.max(
|
const maxValue = Math.max(
|
||||||
...seriesData.value[0].data,
|
...seriesData.value[0].data,
|
||||||
...seriesData.value[1].data
|
...seriesData.value[1].data,
|
||||||
|
...seriesData.value[2].data
|
||||||
);
|
);
|
||||||
return Math.ceil(maxValue / 1000) * 1000; // 向上取整到最接近的千位
|
return Math.ceil(maxValue); // 向上取整到最接近的千位
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user