-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11-仪表盘02.html
197 lines (195 loc) · 4.89 KB
/
11-仪表盘02.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
</head>
<body>
<div id="main" style="width:900px;height: 600px;"></div>
<script src="./js/echarts.min.js"></script>
<script>
let myCharts = echarts.init(document.getElementById('main'))
let option = {
title: {
text: '仪表盘--复杂'
},
toolbox: {
show: true,
left: 'right',
top: 'bottom',
feature: {
dataView: {
show: true,
readOnly: true
},
dataZoom: {
show: true
},
restore: {
show: true
},
saveAsImage: {
show: true,
type: 'png'
}
}
},
tooltip: {
formatter: '{a}<br>{b}:{c}'
},
series: [
{
name: '速度',
type: 'gauge',
z: 3, // 相当于 css中的 z-index
min: 0, // 最小值
max: 220, // 最大值
splitNumber: 11, // min-max 分成几等分
radius: '50%', // 半径
axisLine: {
// 坐标轴线--环形线粗细
lineStyle: {
width: 10
}
},
axisTick: {
// 坐标轴小标记 --小刻度线
length: 15,
lineStyle: {
color: 'auto'
}
},
splitLine: {
// 分割线--大刻度线
length: 20,
lineStyle: {
color: 'atuo'
}
},
title: {
textStyle: 'bolder',
fontSize: 20,
fontStyle: 'italic'
},
detail: {
textStyle: {
fontWeight: 'bolder'
},
formatter: '{value}km/h'
},
data: [
{
value: 40,
name: 'km/h'
}
]
},
{
name: '转速',
type: 'gauge',
center: ['18%', '55%'], //圆心坐标--数组,默认全局居中
radius: '35%',
min: 0,
max: 7,
endAngle: 45, // 结束的角度
axisLine: {
lineStyle: {
width: 8
}
},
axisTick: {
length: 12,
lineStyle: {
color: 'auto'
}
},
splitLine: {
length: 20,
lineStyle: {
color: 'auto'
}
},
pointer: {
// 指针样式
width: 5
},
title: {
offsetCenter: [0, '-40%']
},
detail: {
textStyle: {
fontWeight: 'normal'
}
},
data: [
{
value: 5,
name: 'x1000t/min'
}
]
},
{
name: '油表',
type: 'gauge',
center: ['77%', '58%'],
radius: '25%',
min: 0,
max: 2,
startAngle: 135,
endAngle: 45,
splitNumber: 2,
axisLine: {
lineStyle: {
width: 8
}
},
axisTick: {
splitNumber: 5,
length: 10,
lineStyle: {
color: 'auto'
}
},
axisLabel: {
//坐标轴文本标签
formatter: function(val) {
switch (val + '') {
case '0':
return 'E'
case '1':
return 'Gas'
case '2':
return 'F'
}
}
},
title: {
show: false
},
pointer: {
width: 2
},
detail: {
show: false
},
data: [
{
value: 0.5,
name: 'gas'
}
]
}
]
}
setInterval(() => {
option.series[0].data[0].value = (Math.random() * 100).toFixed(2) - 0
option.series[1].data[0].value = (Math.random() * 7).toFixed(2) - 0
option.series[2].data[0].value = (Math.random() * 2).toFixed(2) - 0
// opiton.series[3].data[3].value = (Math.random() * 2).toFixed(2) - 0
myCharts.setOption(option)
}, 2000)
</script>
</body>
</html>