Fix:1; Refactor:1; Perf:1 #47
@@ -59,13 +59,53 @@ const OnlineInfo = () => {
|
|||||||
const dataList = getTimesBetweenTwoTimes(
|
const dataList = getTimesBetweenTwoTimes(
|
||||||
data.history[0].time,
|
data.history[0].time,
|
||||||
data.history[data.history.length - 1].time,
|
data.history[data.history.length - 1].time,
|
||||||
'minute'
|
_scope === 'DAY'
|
||||||
).map((time) => [
|
? 'minute'
|
||||||
time,
|
: _scope === 'WEEK'
|
||||||
data.history.find(
|
? 'minute'
|
||||||
(value) => value.time.substring(0, 16) === time.substring(0, 16)
|
: _scope === 'MONTH'
|
||||||
)?.record ?? 0
|
? 'hour'
|
||||||
])
|
: 'day'
|
||||||
|
).map((time) => {
|
||||||
|
const records = data.history
|
||||||
|
.filter(
|
||||||
|
(value) =>
|
||||||
|
value.time.substring(
|
||||||
|
0,
|
||||||
|
_scope === 'DAY'
|
||||||
|
? 16
|
||||||
|
: _scope === 'WEEK'
|
||||||
|
? 16
|
||||||
|
: _scope === 'MONTH'
|
||||||
|
? 13
|
||||||
|
: 10
|
||||||
|
) ===
|
||||||
|
time.substring(
|
||||||
|
0,
|
||||||
|
_scope === 'DAY'
|
||||||
|
? 16
|
||||||
|
: _scope === 'WEEK'
|
||||||
|
? 16
|
||||||
|
: _scope === 'MONTH'
|
||||||
|
? 13
|
||||||
|
: 10
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.map((item) => Number(item.record))
|
||||||
|
return [
|
||||||
|
time.substring(
|
||||||
|
0,
|
||||||
|
_scope === 'DAY'
|
||||||
|
? 16
|
||||||
|
: _scope === 'WEEK'
|
||||||
|
? 16
|
||||||
|
: _scope === 'MONTH'
|
||||||
|
? 13
|
||||||
|
: 10
|
||||||
|
),
|
||||||
|
records.length ? Math.max(...records) : 0
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
onlineInfoEChartsRef.current = echarts.init(
|
onlineInfoEChartsRef.current = echarts.init(
|
||||||
onlineInfoDivRef.current,
|
onlineInfoDivRef.current,
|
||||||
@@ -77,7 +117,15 @@ const OnlineInfo = () => {
|
|||||||
...lineEChartsBaseOption,
|
...lineEChartsBaseOption,
|
||||||
tooltip: {
|
tooltip: {
|
||||||
...lineEChartsBaseOption.tooltip,
|
...lineEChartsBaseOption.tooltip,
|
||||||
formatter: getTooltipTimeFormatter('yyyy-MM-DD HH:mm')
|
formatter: getTooltipTimeFormatter(
|
||||||
|
_scope === 'DAY'
|
||||||
|
? 'yyyy-MM-DD HH:mm'
|
||||||
|
: _scope === 'WEEK'
|
||||||
|
? 'yyyy-MM-DD HH:mm'
|
||||||
|
: _scope === 'MONTH'
|
||||||
|
? 'yyyy-MM-DD HH时'
|
||||||
|
: 'yyyy-MM-DD'
|
||||||
|
)
|
||||||
},
|
},
|
||||||
xAxis: {
|
xAxis: {
|
||||||
...lineEChartsBaseOption.xAxis
|
...lineEChartsBaseOption.xAxis
|
||||||
|
|||||||
Reference in New Issue
Block a user