diff --git a/ruoyi-ui/src/views/dataStatistics/comparison/index.vue b/ruoyi-ui/src/views/dataStatistics/comparison/index.vue index 1c21d19..ae7b684 100644 --- a/ruoyi-ui/src/views/dataStatistics/comparison/index.vue +++ b/ruoyi-ui/src/views/dataStatistics/comparison/index.vue @@ -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",