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 }) } })