From cd50a4b7d5315b4e0a08df9573b51fa5e6135770 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Thu, 13 Jul 2023 20:48:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BB=E6=8A=A4=E5=A4=A7=E5=B1=8F=E5=90=84?= =?UTF-8?q?=E4=B9=A1=E9=95=87=E5=85=BB=E6=8A=A4=E5=BE=97=E5=88=86=E8=B6=8B?= =?UTF-8?q?=E5=8A=BF=E6=A8=A1=E5=9D=97=E6=95=B0=E6=8D=AE=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../footer/conserve/left/left-center.js | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/web/client/src/sections/quanju/containers/footer/conserve/left/left-center.js b/web/client/src/sections/quanju/containers/footer/conserve/left/left-center.js index f092903d..1df50f48 100644 --- a/web/client/src/sections/quanju/containers/footer/conserve/left/left-center.js +++ b/web/client/src/sections/quanju/containers/footer/conserve/left/left-center.js @@ -27,27 +27,41 @@ const LeftCenter = (props) => { dispatch(getNearestAssessData({ monthRange: 6 })).then(res => { if (res.success) { let nextChartSeries = [] - let nextXAxis = new Set() + let nextXAxis = [] let data = res.payload.data data.reverse() for (let d of data) { let corUnitSeries = nextChartSeries.find(item => item.name == d.unit) let month = moment(d.month).format('YYYY-MM') - nextXAxis.add(month) + let curMonthIndex = nextXAxis.findIndex(item => item == month) + if (curMonthIndex < 0) { + nextXAxis.push(month) + curMonthIndex = nextXAxis.length - 1 + } if (corUnitSeries) { - corUnitSeries.data.push(d.totalPoints) + corUnitSeries.data[curMonthIndex] = d.totalPoints } else { - nextChartSeries.push({ + let nextnextChartSerie = { type: 'line', smooth: true, - data: [d.totalPoints], + data: [], name: d.unit, - }) + } + nextnextChartSerie.data[curMonthIndex] = d.totalPoints + nextChartSeries.push(nextnextChartSerie) + } + } + for (let s of nextChartSeries) { + for (let i = 0; i < nextXAxis.length; i++) { + if (!s.data[i] && s.data[i] != 0) { + s.data[i] = undefined + } } } + setChartData({ series: nextChartSeries, - xAxis: [...nextXAxis] + xAxis: nextXAxis }) } })