Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9640531c
authored
Feb 28, 2025
by
alwayssuper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:home
parent
5137b4a4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
9 deletions
+22
-9
src/views/iot/home/index.vue
+22
-9
No files found.
src/views/iot/home/index.vue
View file @
9640531c
...
@@ -373,17 +373,30 @@ const initGaugeChart = (el: any, value: number, color: string) => {
...
@@ -373,17 +373,30 @@ const initGaugeChart = (el: any, value: number, color: string) => {
/** 初始化消息统计图表 */
/** 初始化消息统计图表 */
const
initMessageChart
=
()
=>
{
const
initMessageChart
=
()
=>
{
// 获取所有时间戳并排序
const
timestamps
=
Array
.
from
(
const
timestamps
=
Array
.
from
(
new
Set
([
new
Set
([
...
Object
.
keys
(
messageStats
.
value
.
upstreamCounts
),
...
messageStats
.
value
.
upstreamCounts
.
map
(
item
=>
Number
(
Object
.
keys
(
item
)[
0
])
),
...
Object
.
keys
(
messageStats
.
value
.
downstreamCounts
)
...
messageStats
.
value
.
downstreamCounts
.
map
(
item
=>
Number
(
Object
.
keys
(
item
)[
0
])
)
])
])
).
sort
()
).
sort
((
a
,
b
)
=>
a
-
b
)
// 确保时间戳从小到大排序
const
xdata
=
timestamps
.
map
(
ts
=>
formatDate
(
Number
(
ts
),
'YYYY-MM-DD HH:mm'
))
// 准备数据
const
upData
=
timestamps
.
map
(
ts
=>
messageStats
.
value
.
upstreamCounts
[
Number
(
ts
)]
||
0
)
const
xdata
=
timestamps
.
map
(
ts
=>
formatDate
(
ts
,
'YYYY-MM-DD HH:mm'
))
const
downData
=
timestamps
.
map
(
ts
=>
messageStats
.
value
.
downstreamCounts
[
Number
(
ts
)]
||
0
)
const
upData
=
timestamps
.
map
(
ts
=>
{
const
item
=
messageStats
.
value
.
upstreamCounts
.
find
(
count
=>
Number
(
Object
.
keys
(
count
)[
0
])
===
ts
)
return
item
?
Object
.
values
(
item
)[
0
]
:
0
})
const
downData
=
timestamps
.
map
(
ts
=>
{
const
item
=
messageStats
.
value
.
downstreamCounts
.
find
(
count
=>
Number
(
Object
.
keys
(
count
)[
0
])
===
ts
)
return
item
?
Object
.
values
(
item
)[
0
]
:
0
})
// 配置图表
echarts
.
init
(
chartMsgStat
.
value
).
setOption
({
echarts
.
init
(
chartMsgStat
.
value
).
setOption
({
tooltip
:
{
tooltip
:
{
trigger
:
'axis'
,
trigger
:
'axis'
,
...
@@ -439,7 +452,7 @@ const initMessageChart = () => {
...
@@ -439,7 +452,7 @@ const initMessageChart = () => {
{
{
name
:
'上行消息量'
,
name
:
'上行消息量'
,
type
:
'line'
,
type
:
'line'
,
s
tack
:
'Total'
,
s
mooth
:
true
,
// 添加平滑曲线
data
:
upData
,
data
:
upData
,
itemStyle
:
{
itemStyle
:
{
color
:
'#3B82F6'
color
:
'#3B82F6'
...
@@ -457,7 +470,7 @@ const initMessageChart = () => {
...
@@ -457,7 +470,7 @@ const initMessageChart = () => {
{
{
name
:
'下行消息量'
,
name
:
'下行消息量'
,
type
:
'line'
,
type
:
'line'
,
s
tack
:
'Total'
,
s
mooth
:
true
,
// 添加平滑曲线
data
:
downData
,
data
:
downData
,
itemStyle
:
{
itemStyle
:
{
color
:
'#10B981'
color
:
'#10B981'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment