feat: 数据统计-对比分析,按月份排序数据并更新图表

按照月份正确排序数据,并更新图表以反映排序后的数据。
This commit is contained in:
LokerL 2024-10-13 11:07:35 +08:00
parent 5fd4b77bba
commit ccc3d7c616
1 changed files with 17 additions and 1 deletions

View File

@ -102,7 +102,23 @@ export default {
return;
}
const { data } = res;
this.chartData.series.data = Object.keys(data).map((key) => {
// month
function sortDataByMonth(data) {
//
for (const key in data) {
if (data.hasOwnProperty(key)) {
//
data[key].sort((a, b) => {
// month
return new Date(a.month) - new Date(b.month);
});
}
}
return data;
}
const sortedData = sortDataByMonth(data);
this.chartData.series.data = Object.keys(sortedData).map((key) => {
return {
name: this.deptList.find((item) => item.deptId === parseInt(key))?.deptName,
type: "line",