2022-08-12 10:21:25 +08:00
|
|
|
|
<template>
|
2022-08-31 18:07:01 +08:00
|
|
|
|
<Card title="设备管理">
|
|
|
|
|
|
<div class="container">
|
|
|
|
|
|
<div class="item" ref="firstChart"></div>
|
|
|
|
|
|
<div class="item" ref="secondChart"></div>
|
|
|
|
|
|
<div class="item" ref="thirdChart"></div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</Card>
|
2022-08-12 10:21:25 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2022-08-31 18:07:01 +08:00
|
|
|
|
import echarts from 'echarts4'
|
|
|
|
|
|
|
2022-08-24 15:52:18 +08:00
|
|
|
|
import Card from '../components/Card'
|
2022-08-31 18:07:01 +08:00
|
|
|
|
|
2022-08-12 10:21:25 +08:00
|
|
|
|
export default {
|
2022-08-24 15:52:18 +08:00
|
|
|
|
components: { Card },
|
2022-08-12 10:21:25 +08:00
|
|
|
|
data() {
|
2022-08-24 15:52:18 +08:00
|
|
|
|
return {}
|
2022-08-31 18:07:01 +08:00
|
|
|
|
},
|
|
|
|
|
|
mounted() {
|
2022-09-06 11:25:11 +08:00
|
|
|
|
this.initChart('firstChart', 7, '塔吊设备数', require('../assets/images/command-center/icon-tower.png'))
|
|
|
|
|
|
this.initChart('secondChart', 4, '升降机设备数', require('../assets/images/command-center/icon-lifter.png'))
|
|
|
|
|
|
this.initChart('thirdChart', 5, '视频设备数', require('../assets/images/command-center/icon-video.png'))
|
2022-08-31 18:07:01 +08:00
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2022-09-06 11:25:11 +08:00
|
|
|
|
initChart(ref, value, title = '默认标题', image) {
|
2022-08-31 18:07:01 +08:00
|
|
|
|
const myChart = echarts.init(this.$refs[ref])
|
|
|
|
|
|
|
2022-09-06 11:25:11 +08:00
|
|
|
|
let angle = 0 // 角度,用来做简单的动画效果的
|
|
|
|
|
|
|
2022-08-31 18:07:01 +08:00
|
|
|
|
const option = {
|
|
|
|
|
|
// backgroundColor: '#061740',
|
|
|
|
|
|
title: {
|
2022-09-06 11:25:11 +08:00
|
|
|
|
text: '{a|'+ value +'}\n{b|'+ title +'}',
|
|
|
|
|
|
// text: '10\n' + title,
|
2022-08-31 18:07:01 +08:00
|
|
|
|
x: 'center',
|
|
|
|
|
|
y: 'center',
|
|
|
|
|
|
top: '35%',
|
|
|
|
|
|
textStyle: {
|
2022-09-06 11:25:11 +08:00
|
|
|
|
rich: {
|
|
|
|
|
|
a: {
|
|
|
|
|
|
fontSize: 20,
|
|
|
|
|
|
color: '#e5e442'
|
|
|
|
|
|
},
|
|
|
|
|
|
b: {
|
|
|
|
|
|
fontSize: 13,
|
|
|
|
|
|
color: '#ffffff',
|
|
|
|
|
|
padding: [5, 0]
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-08-31 18:07:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-09-06 11:25:11 +08:00
|
|
|
|
graphic: {
|
|
|
|
|
|
elements: [
|
|
|
|
|
|
{
|
|
|
|
|
|
type: 'image',
|
|
|
|
|
|
style: {
|
|
|
|
|
|
image,
|
|
|
|
|
|
width: 20,
|
|
|
|
|
|
height: 20
|
|
|
|
|
|
},
|
|
|
|
|
|
left: '46%',
|
|
|
|
|
|
top: '59%',
|
|
|
|
|
|
z: 100
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
},
|
2022-08-31 18:07:01 +08:00
|
|
|
|
series: [
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'ring5',
|
|
|
|
|
|
type: 'custom',
|
|
|
|
|
|
coordinateSystem: 'none',
|
|
|
|
|
|
renderItem: function (params, api) {
|
|
|
|
|
|
return {
|
|
|
|
|
|
type: 'arc',
|
|
|
|
|
|
shape: {
|
|
|
|
|
|
cx: api.getWidth() / 2,
|
|
|
|
|
|
cy: api.getHeight() / 2,
|
|
|
|
|
|
r: (Math.min(api.getWidth(), api.getHeight()) / 2) * 0.6,
|
|
|
|
|
|
startAngle: ((0 + angle) * Math.PI) / 180,
|
|
|
|
|
|
endAngle: ((90 + angle) * Math.PI) / 180
|
|
|
|
|
|
},
|
|
|
|
|
|
style: {
|
|
|
|
|
|
stroke: '#0CD3DB',
|
|
|
|
|
|
fill: 'transparent',
|
|
|
|
|
|
lineWidth: 1.5
|
|
|
|
|
|
},
|
|
|
|
|
|
silent: true
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
data: [0]
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'ring5',
|
|
|
|
|
|
type: 'custom',
|
|
|
|
|
|
coordinateSystem: 'none',
|
|
|
|
|
|
renderItem: function (params, api) {
|
|
|
|
|
|
return {
|
|
|
|
|
|
type: 'arc',
|
|
|
|
|
|
shape: {
|
|
|
|
|
|
cx: api.getWidth() / 2,
|
|
|
|
|
|
cy: api.getHeight() / 2,
|
|
|
|
|
|
r: (Math.min(api.getWidth(), api.getHeight()) / 2) * 0.6,
|
|
|
|
|
|
startAngle: ((180 + angle) * Math.PI) / 180,
|
|
|
|
|
|
endAngle: ((270 + angle) * Math.PI) / 180
|
|
|
|
|
|
},
|
|
|
|
|
|
style: {
|
|
|
|
|
|
stroke: '#0CD3DB',
|
|
|
|
|
|
fill: 'transparent',
|
|
|
|
|
|
lineWidth: 1
|
|
|
|
|
|
},
|
|
|
|
|
|
silent: true
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
data: [0]
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'ring5',
|
|
|
|
|
|
type: 'custom',
|
|
|
|
|
|
coordinateSystem: 'none',
|
|
|
|
|
|
renderItem: function (params, api) {
|
|
|
|
|
|
return {
|
|
|
|
|
|
type: 'arc',
|
|
|
|
|
|
shape: {
|
|
|
|
|
|
cx: api.getWidth() / 2,
|
|
|
|
|
|
cy: api.getHeight() / 2,
|
|
|
|
|
|
r: (Math.min(api.getWidth(), api.getHeight()) / 2) * 0.65,
|
|
|
|
|
|
startAngle: ((270 + -angle) * Math.PI) / 180,
|
|
|
|
|
|
endAngle: ((40 + -angle) * Math.PI) / 180
|
|
|
|
|
|
},
|
|
|
|
|
|
style: {
|
|
|
|
|
|
stroke: '#0CD3DB',
|
|
|
|
|
|
fill: 'transparent',
|
|
|
|
|
|
lineWidth: 1
|
|
|
|
|
|
},
|
|
|
|
|
|
silent: true
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
data: [0]
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'ring5',
|
|
|
|
|
|
type: 'custom',
|
|
|
|
|
|
coordinateSystem: 'none',
|
|
|
|
|
|
renderItem: function (params, api) {
|
|
|
|
|
|
return {
|
|
|
|
|
|
type: 'arc',
|
|
|
|
|
|
shape: {
|
|
|
|
|
|
cx: api.getWidth() / 2,
|
|
|
|
|
|
cy: api.getHeight() / 2,
|
|
|
|
|
|
r: (Math.min(api.getWidth(), api.getHeight()) / 2) * 0.65,
|
|
|
|
|
|
startAngle: ((90 + -angle) * Math.PI) / 180,
|
|
|
|
|
|
endAngle: ((220 + -angle) * Math.PI) / 180
|
|
|
|
|
|
},
|
|
|
|
|
|
style: {
|
|
|
|
|
|
stroke: '#0CD3DB',
|
|
|
|
|
|
fill: 'transparent',
|
|
|
|
|
|
lineWidth: 1
|
|
|
|
|
|
},
|
|
|
|
|
|
silent: true
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
data: [0]
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'ring5',
|
|
|
|
|
|
type: 'custom',
|
|
|
|
|
|
coordinateSystem: 'none',
|
|
|
|
|
|
renderItem: function (params, api) {
|
|
|
|
|
|
let x0 = api.getWidth() / 2
|
|
|
|
|
|
let y0 = api.getHeight() / 2
|
|
|
|
|
|
let r = (Math.min(api.getWidth(), api.getHeight()) / 2) * 0.65
|
|
|
|
|
|
let point = getCirlPoint(x0, y0, r, 90 + -angle)
|
|
|
|
|
|
return {
|
|
|
|
|
|
type: 'circle',
|
|
|
|
|
|
shape: {
|
|
|
|
|
|
cx: point.x,
|
|
|
|
|
|
cy: point.y,
|
|
|
|
|
|
r: 2
|
|
|
|
|
|
},
|
|
|
|
|
|
style: {
|
|
|
|
|
|
stroke: '#0CD3DB', // 粉
|
|
|
|
|
|
fill: '#0CD3DB'
|
|
|
|
|
|
},
|
|
|
|
|
|
silent: true
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
data: [0]
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'ring5', // 绿点
|
|
|
|
|
|
type: 'custom',
|
|
|
|
|
|
coordinateSystem: 'none',
|
|
|
|
|
|
renderItem: function (params, api) {
|
|
|
|
|
|
let x0 = api.getWidth() / 2
|
|
|
|
|
|
let y0 = api.getHeight() / 2
|
|
|
|
|
|
let r = (Math.min(api.getWidth(), api.getHeight()) / 2) * 0.65
|
|
|
|
|
|
let point = getCirlPoint(x0, y0, r, 270 + -angle)
|
|
|
|
|
|
return {
|
|
|
|
|
|
type: 'circle',
|
|
|
|
|
|
shape: {
|
|
|
|
|
|
cx: point.x,
|
|
|
|
|
|
cy: point.y,
|
|
|
|
|
|
r: 2
|
|
|
|
|
|
},
|
|
|
|
|
|
style: {
|
|
|
|
|
|
stroke: '#0CD3DB', // 绿
|
|
|
|
|
|
fill: '#0CD3DB'
|
|
|
|
|
|
},
|
|
|
|
|
|
silent: true
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
data: [0]
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '吃猪肉频率',
|
|
|
|
|
|
type: 'pie',
|
|
|
|
|
|
radius: ['56%', '45%'],
|
|
|
|
|
|
center: ['50%', '50%'],
|
|
|
|
|
|
silent: true,
|
|
|
|
|
|
clockwise: true,
|
|
|
|
|
|
startAngle: 90,
|
|
|
|
|
|
z: 0,
|
|
|
|
|
|
zlevel: 0,
|
|
|
|
|
|
label: {
|
|
|
|
|
|
normal: {
|
|
|
|
|
|
position: 'center'
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
data: [
|
|
|
|
|
|
{
|
|
|
|
|
|
value: value,
|
|
|
|
|
|
name: '',
|
|
|
|
|
|
itemStyle: {
|
|
|
|
|
|
normal: {
|
|
|
|
|
|
color: {
|
|
|
|
|
|
// 完成的圆环的颜色
|
|
|
|
|
|
colorStops: [
|
|
|
|
|
|
{
|
|
|
|
|
|
offset: 0,
|
|
|
|
|
|
color: '#4FADFD' // 0% 处的颜色
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
offset: 1,
|
|
|
|
|
|
color: '#28E8FA' // 100% 处的颜色
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 100 - value,
|
|
|
|
|
|
name: '',
|
|
|
|
|
|
label: {
|
|
|
|
|
|
normal: {
|
|
|
|
|
|
show: false
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
itemStyle: {
|
|
|
|
|
|
normal: {
|
|
|
|
|
|
color: '#173164'
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '',
|
|
|
|
|
|
type: 'gauge',
|
|
|
|
|
|
radius: '58%',
|
|
|
|
|
|
center: ['50%', '50%'],
|
|
|
|
|
|
startAngle: 0,
|
|
|
|
|
|
endAngle: 359.9,
|
|
|
|
|
|
splitNumber: 8,
|
|
|
|
|
|
hoverAnimation: true,
|
|
|
|
|
|
axisTick: {
|
|
|
|
|
|
show: false
|
|
|
|
|
|
},
|
|
|
|
|
|
splitLine: {
|
|
|
|
|
|
length: 60,
|
|
|
|
|
|
lineStyle: {
|
|
|
|
|
|
width: 3,
|
|
|
|
|
|
// 分隔线的颜色
|
|
|
|
|
|
color: '#182337'
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
axisLabel: {
|
|
|
|
|
|
show: false
|
|
|
|
|
|
},
|
|
|
|
|
|
pointer: {
|
|
|
|
|
|
show: false
|
|
|
|
|
|
},
|
|
|
|
|
|
axisLine: {
|
|
|
|
|
|
lineStyle: {
|
|
|
|
|
|
opacity: 0
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
detail: {
|
|
|
|
|
|
show: false
|
|
|
|
|
|
},
|
|
|
|
|
|
data: [
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 0,
|
|
|
|
|
|
name: ''
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
|
|
|
|
|
//获取圆上面某点的坐标(x0,y0表示坐标,r半径,angle角度)
|
|
|
|
|
|
function getCirlPoint(x0, y0, r, angle) {
|
|
|
|
|
|
let x1 = x0 + r * Math.cos((angle * Math.PI) / 180)
|
|
|
|
|
|
let y1 = y0 + r * Math.sin((angle * Math.PI) / 180)
|
|
|
|
|
|
return {
|
|
|
|
|
|
x: x1,
|
|
|
|
|
|
y: y1
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function draw() {
|
|
|
|
|
|
angle = angle + 3
|
|
|
|
|
|
myChart.setOption(option, true)
|
|
|
|
|
|
//window.requestAnimationFrame(draw);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setInterval(function () {
|
|
|
|
|
|
//用setInterval做动画感觉有问题
|
|
|
|
|
|
draw()
|
|
|
|
|
|
}, 100)
|
|
|
|
|
|
myChart.setOption(option)
|
|
|
|
|
|
}
|
2022-08-12 10:21:25 +08:00
|
|
|
|
}
|
2022-08-24 15:52:18 +08:00
|
|
|
|
}
|
2022-08-12 10:21:25 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
2022-08-31 18:07:01 +08:00
|
|
|
|
<style lang="less" scoped>
|
|
|
|
|
|
.container {
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
white-space: nowrap;
|
2022-09-07 15:51:48 +08:00
|
|
|
|
// transform: translateY(-15px);
|
2022-08-31 18:07:01 +08:00
|
|
|
|
|
|
|
|
|
|
.item {
|
|
|
|
|
|
display: inline-block;
|
|
|
|
|
|
width: calc(100% / 2);
|
2022-09-09 11:55:23 +08:00
|
|
|
|
height: 120%;
|
2022-08-31 18:07:01 +08:00
|
|
|
|
color: transparent;
|
|
|
|
|
|
|
|
|
|
|
|
&:nth-child(1) {
|
2022-09-09 11:55:23 +08:00
|
|
|
|
transform: translate(-24%, -6%);
|
2022-08-31 18:07:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
&:nth-child(2) {
|
2022-09-09 11:55:23 +08:00
|
|
|
|
transform: translate(-48%, -6%);
|
2022-08-31 18:07:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
&:nth-child(3) {
|
2022-09-09 11:55:23 +08:00
|
|
|
|
transform: translate(-75%, -6%);
|
2022-08-31 18:07:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|