Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
super-hive-web
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SuperHive
front-end
super-hive-web
Commits
b3e350e2
Commit
b3e350e2
authored
Aug 05, 2020
by
wends
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update 改用echarts
parent
fd4f831e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
145 additions
and
113 deletions
+145
-113
dashboard.js
src/api/object-visible/dashboard.js
+8
-0
ELine.vue
src/components/Charts/ELine.vue
+107
-0
index.vue
src/views/object-visible/dashboard/index.vue
+30
-113
No files found.
src/api/object-visible/dashboard.js
View file @
b3e350e2
...
...
@@ -28,3 +28,11 @@ export function getModelInstanceList(data) {
data
})
}
// 获取图表数据
export
function
getModelInstanceChart
(
data
)
{
return
request
({
url
:
`
${
baseURL
}
iot/dashboard/modelData`
,
method
:
'
post
'
,
data
})
}
src/components/Charts/ELine.vue
0 → 100644
View file @
b3e350e2
<
template
>
<div
:id=
"id"
:class=
"className"
:style=
"
{height:height,minWidth:width}" />
</
template
>
<
script
>
import
echarts
from
'
echarts
'
import
moment
from
'
moment
'
import
resize
from
'
./mixins/resize
'
export
default
{
mixins
:
[
resize
],
props
:
{
className
:
{
type
:
String
,
default
:
'
chart
'
},
id
:
{
type
:
String
,
default
:
'
chart
'
},
title
:
{
type
:
String
,
default
:
'
line
'
},
width
:
{
type
:
String
,
default
:
'
500px
'
},
height
:
{
type
:
String
,
default
:
'
400px
'
},
lineData
:
{
type
:
Array
,
default
:
()
=>
{
return
[]
}
},
description
:
{
type
:
String
,
default
:
''
}
},
data
()
{
return
{
chart
:
null
}
},
watch
:
{
lineData
:
function
(
val
)
{
this
.
updateChart
(
val
)
}
},
mounted
()
{
this
.
initChart
()
},
beforeDestroy
()
{
if
(
!
this
.
chart
)
{
return
}
this
.
chart
.
dispose
()
this
.
chart
=
null
},
methods
:
{
updateChart
(
data
)
{
const
xAxis
=
[]
const
series
=
[]
data
.
forEach
(
v
=>
{
xAxis
.
push
(
moment
(
v
.
time
).
format
(
'
HH:mm:ss
'
))
series
.
push
(
v
.
value
)
})
this
.
chart
.
setOption
({
xAxis
:
{
data
:
xAxis
},
series
:
[{
name
:
this
.
title
,
data
:
series
}]
})
},
initChart
()
{
this
.
chart
=
echarts
.
init
(
document
.
getElementById
(
this
.
id
))
this
.
chart
.
setOption
({
title
:
{
text
:
`
${
this
.
title
}
监控图表`
,
subtext
:
`单位为:
${
this
.
description
}
`
},
tooltip
:
{},
legend
:
{
data
:
[
this
.
title
]
},
xAxis
:
{
data
:
[]
},
yAxis
:
{},
series
:
[{
name
:
this
.
title
,
type
:
'
line
'
,
data
:
[]
}]
})
}
}
}
</
script
>
src/views/object-visible/dashboard/index.vue
View file @
b3e350e2
...
...
@@ -37,7 +37,7 @@
<el-checkbox
v-for=
"(prop, i) in propertyList"
:key=
"200+i"
:label=
"prop.
id
"
:label=
"prop.
propertyCode
"
>
{{
prop
.
propertyName
}}
</el-checkbox>
</el-checkbox-group>
</el-form-item>
...
...
@@ -71,13 +71,12 @@
:span=
"12"
style=
"height: 400px"
>
<
g2
-line
<
e
-line
:id=
"'line-' + chart.propertyCode"
:title=
"chart.propertyName"
:line-data=
"setChartData(chart.propertyCode)"
:description=
"chart.propertyUnit"
style=
"min-width: 500px;height: 400px"
/>
></e-line>
</el-col>
</el-row>
</div>
...
...
@@ -87,13 +86,13 @@
</
template
>
<
script
>
import
G2Line
from
'
@/components/G2Plot/G2
Line
'
import
{
getAllModel
,
getModelDetail
,
getModelInstanceList
}
from
'
@/api/object-visible/dashboard
'
import
ELine
from
'
@/components/Charts/E
Line
'
import
{
getAllModel
,
getModelDetail
,
getModelInstanceList
,
getModelInstanceChart
}
from
'
@/api/object-visible/dashboard
'
export
default
{
name
:
'
Dashboard
'
,
components
:
{
G2
Line
E
Line
},
data
()
{
return
{
...
...
@@ -118,79 +117,7 @@ export default {
yFields
:
[
{
type
:
'
array
'
,
required
:
true
,
message
:
'
请至少选择一个属性
'
,
trigger
:
'
change
'
}
]
},
fakeData
:
[
{
time
:
null
,
value
:
{
inpressure
:
110
,
outpressure
:
21
}
},
{
time
:
null
,
value
:
{
inpressure
:
111
,
outpressure
:
25
}
},
{
time
:
null
,
value
:
{
inpressure
:
112
,
outpressure
:
24
}
},
{
time
:
null
,
value
:
{
inpressure
:
115
,
outpressure
:
23
}
},
{
time
:
null
,
value
:
{
inpressure
:
117
,
outpressure
:
22
}
},
{
time
:
null
,
value
:
{
inpressure
:
110
,
outpressure
:
21
}
},
{
time
:
null
,
value
:
{
inpressure
:
111
,
outpressure
:
25
}
},
{
time
:
null
,
value
:
{
inpressure
:
112
,
outpressure
:
24
}
},
{
time
:
null
,
value
:
{
inpressure
:
115
,
outpressure
:
23
}
},
{
time
:
null
,
value
:
{
inpressure
:
117
,
outpressure
:
22
}
}
]
}
},
created
()
{
...
...
@@ -234,7 +161,7 @@ export default {
return
this
.
chartData
.
map
(
v
=>
{
return
{
time
:
v
.
time
,
value
:
v
.
value
[
yField
]
value
:
parseInt
(
v
[
yField
])
}
})
},
...
...
@@ -244,46 +171,36 @@ export default {
.
then
(
_
=>
{
this
.
chartData
=
[]
this
.
chartList
=
[]
this
.
mockData
()
.
then
(
_
=>
{
const
params
=
{
modelId
:
parseInt
(
this
.
activeModel
),
instanceId
:
this
.
chartField
.
instanceId
,
propertyCodeList
:
[...
this
.
chartField
.
yFields
]
}
getModelInstanceChart
(
params
)
.
then
(
res
=>
{
this
.
chartData
=
res
.
data
.
sort
((
a
,
b
)
=>
{
return
(
a
>
b
)
?
1
:
-
1
})
const
arr
=
[]
this
.
propertyList
.
forEach
(
v
=>
{
const
index
=
this
.
chartField
.
yFields
.
findIndex
(
item
=>
item
===
v
.
id
)
const
index
=
this
.
chartField
.
yFields
.
findIndex
(
item
=>
item
===
v
.
propertyCode
)
index
!==
-
1
&&
arr
.
push
({
...
v
})
})
this
.
chartList
=
[...
arr
]
})
.
then
(
_
=>
{
this
.
timer
&&
clearInterval
(
this
.
timer
)
this
.
timer
=
setInterval
(
async
()
=>
{
await
this
.
mockData
()
const
chartData
=
await
getModelInstanceChart
(
params
)
this
.
chartData
=
chartData
.
data
.
sort
((
a
,
b
)
=>
{
return
(
a
>
b
)
?
1
:
-
1
})
this
.
count
++
},
this
.
chartField
.
refresh
*
1000
)
})
.
catch
(
err
=>
console
.
error
(
err
))
},
mockData
()
{
return
new
Promise
(
resolve
=>
{
this
.
fakeData
.
shift
()
this
.
fakeData
.
push
({
time
:
null
,
value
:
{
inpressure
:
this
.
random
(
80
,
120
),
outpressure
:
this
.
random
(
20
,
30
)
}
})
const
arr
=
[]
const
time
=
new
Date
().
getTime
()
for
(
let
i
=
0
;
i
<
10
;
i
++
)
{
arr
.
push
({
time
:
time
-
(
9
-
i
)
*
1000
,
value
:
{
...
this
.
fakeData
[
i
].
value
}
})
}
this
.
chartData
=
[...
arr
]
resolve
()
.
catch
(
_
=>
{})
})
.
catch
(
err
=>
console
.
error
(
err
))
}
}
}
...
...
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