From ca4827a5645a0f925fba9593c332b687ecf5cad1 Mon Sep 17 00:00:00 2001 From: LiuJiaNan Date: Mon, 16 Jun 2025 16:09:03 +0800 Subject: [PATCH] =?UTF-8?q?feat(map):=20=E5=8F=B3=E4=BE=A7=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E7=BB=84=E4=BB=B6=E5=B0=BE=E7=9F=BF=E5=BA=93=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E5=9B=BE=E8=A1=A8=E5=8A=9F=E8=83=BD=E5=A2=9E=E5=BC=BA?= =?UTF-8?q?-=E6=9B=B4=E6=96=B0=E5=9B=BE=E8=A1=A8=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=EF=BC=8C=E4=BD=BF=E7=94=A8=E6=96=B0=E7=9A=84=E9=A2=9C=E8=89=B2?= =?UTF-8?q?=E6=96=B9=E6=A1=88=E5=92=8C=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/map/components/right_content.vue | 49 ++++++++++------------ 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/src/views/map/components/right_content.vue b/src/views/map/components/right_content.vue index 6de9cd7..e51b9b9 100644 --- a/src/views/map/components/right_content.vue +++ b/src/views/map/components/right_content.vue @@ -89,8 +89,8 @@ const fnGetMountainFloodVillageStatistics = async () => { }; fnGetMountainFloodVillageStatistics(); const fnGetTailingsPondStatisticsStatistics = async () => { - const { data } = await getTailingsPondStatistics(); - fnInitEcharts2(data); + const { data, runningStateList } = await getTailingsPondStatistics(); + fnInitEcharts2(data, runningStateList); }; fnGetTailingsPondStatisticsStatistics(); const fnGetEmergencyReserveWarehouseStatistics = async () => { @@ -127,17 +127,29 @@ const fnInitEcharts1 = (data) => { }; myChart2.setOption(option); }; -const fnInitEcharts2 = (data) => { +const fnInitEcharts2 = (data, runningStateList) => { const xAxisData = []; - const seriesData1 = []; - const seriesData2 = []; - for (let i = 0; i < data.length; i++) { - xAxisData.push(data[i].designGrade); - seriesData1.push(data[i].count["停用"] || 0); - seriesData2.push(data[i].count["运行"] || 0); + const seriesDataMap = {}; + for (let i = 0; i < runningStateList.length; i++) { + seriesDataMap[runningStateList[i].name] = []; } + for (let i = 0; i < data.length; i++) { + const item = data[i]; + xAxisData.push(item.designGrade); + Object.keys(seriesDataMap).forEach((status) => { + seriesDataMap[status].push(item.count[status] || 0); + }); + } + const series = Object.keys(seriesDataMap).map((status) => ({ + name: status, + type: "bar", + stack: "total", + barWidth: 24, + data: seriesDataMap[status], + })); myChart3 = echarts.init(document.getElementById("main3")); const option = { + color: ["#3d8bff", "#ff5252", "#54f313", "#f30404", "#a1a1a1", "#880909"], legend: { orient: "horizontal", right: 0, @@ -164,24 +176,7 @@ const fnInitEcharts2 = (data) => { axisPointer: { type: "shadow" }, textStyle: { color: "#424242" }, }, - series: [ - { - name: "停产停运", - type: "bar", - stack: "total", - barWidth: 24, - color: "#FFC53D", - data: seriesData1, - }, - { - name: "正常", - type: "bar", - stack: "total", - barWidth: 24, - color: "#52A8FF", - data: seriesData2, - }, - ], + series, }; myChart3.setOption(option);