Skip to content

Commit 9640531

Browse files
committed
feat:home
1 parent 5137b4a commit 9640531

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

src/views/iot/home/index.vue

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -373,17 +373,30 @@ const initGaugeChart = (el: any, value: number, color: string) => {
373373
374374
/** 初始化消息统计图表 */
375375
const initMessageChart = () => {
376+
// 获取所有时间戳并排序
376377
const timestamps = Array.from(
377378
new Set([
378-
...Object.keys(messageStats.value.upstreamCounts),
379-
...Object.keys(messageStats.value.downstreamCounts)
379+
...messageStats.value.upstreamCounts.map(item => Number(Object.keys(item)[0])),
380+
...messageStats.value.downstreamCounts.map(item => Number(Object.keys(item)[0]))
380381
])
381-
).sort()
382-
383-
const xdata = timestamps.map(ts => formatDate(Number(ts), 'YYYY-MM-DD HH:mm'))
384-
const upData = timestamps.map(ts => messageStats.value.upstreamCounts[Number(ts)] || 0)
385-
const downData = timestamps.map(ts => messageStats.value.downstreamCounts[Number(ts)] || 0)
382+
).sort((a, b) => a - b) // 确保时间戳从小到大排序
383+
384+
// 准备数据
385+
const xdata = timestamps.map(ts => formatDate(ts, 'YYYY-MM-DD HH:mm'))
386+
const upData = timestamps.map(ts => {
387+
const item = messageStats.value.upstreamCounts.find(
388+
count => Number(Object.keys(count)[0]) === ts
389+
)
390+
return item ? Object.values(item)[0] : 0
391+
})
392+
const downData = timestamps.map(ts => {
393+
const item = messageStats.value.downstreamCounts.find(
394+
count => Number(Object.keys(count)[0]) === ts
395+
)
396+
return item ? Object.values(item)[0] : 0
397+
})
386398
399+
// 配置图表
387400
echarts.init(chartMsgStat.value).setOption({
388401
tooltip: {
389402
trigger: 'axis',
@@ -439,7 +452,7 @@ const initMessageChart = () => {
439452
{
440453
name: '上行消息量',
441454
type: 'line',
442-
stack: 'Total',
455+
smooth: true, // 添加平滑曲线
443456
data: upData,
444457
itemStyle: {
445458
color: '#3B82F6'
@@ -457,7 +470,7 @@ const initMessageChart = () => {
457470
{
458471
name: '下行消息量',
459472
type: 'line',
460-
stack: 'Total',
473+
smooth: true, // 添加平滑曲线
461474
data: downData,
462475
itemStyle: {
463476
color: '#10B981'

0 commit comments

Comments
 (0)