|
@ -27,27 +27,41 @@ const LeftCenter = (props) => { |
|
|
dispatch(getNearestAssessData({ monthRange: 6 })).then(res => { |
|
|
dispatch(getNearestAssessData({ monthRange: 6 })).then(res => { |
|
|
if (res.success) { |
|
|
if (res.success) { |
|
|
let nextChartSeries = [] |
|
|
let nextChartSeries = [] |
|
|
let nextXAxis = new Set() |
|
|
let nextXAxis = [] |
|
|
let data = res.payload.data |
|
|
let data = res.payload.data |
|
|
data.reverse() |
|
|
data.reverse() |
|
|
for (let d of data) { |
|
|
for (let d of data) { |
|
|
let corUnitSeries = nextChartSeries.find(item => item.name == d.unit) |
|
|
let corUnitSeries = nextChartSeries.find(item => item.name == d.unit) |
|
|
let month = moment(d.month).format('YYYY-MM') |
|
|
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) { |
|
|
if (corUnitSeries) { |
|
|
corUnitSeries.data.push(d.totalPoints) |
|
|
corUnitSeries.data[curMonthIndex] = d.totalPoints |
|
|
} else { |
|
|
} else { |
|
|
nextChartSeries.push({ |
|
|
let nextnextChartSerie = { |
|
|
type: 'line', |
|
|
type: 'line', |
|
|
smooth: true, |
|
|
smooth: true, |
|
|
data: [d.totalPoints], |
|
|
data: [], |
|
|
name: d.unit, |
|
|
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({ |
|
|
setChartData({ |
|
|
series: nextChartSeries, |
|
|
series: nextChartSeries, |
|
|
xAxis: [...nextXAxis] |
|
|
xAxis: nextXAxis |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|