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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
| <template>
| <div class="publicToilets">
| <div class="header">
| <span class="title1">热门景区安保设备数量以及组成</span>
| </div>
| <div class="echartsTool">
| <chart :optionIn="option1" />
| </div>
| </div>
| </template>
|
| <script>
| import * as echarts from 'echarts';
| import chart from "@/components/chart.vue";
| export default {
| name: "AnBaoSheBei",
| data() {
| return {
| option1: {}
| }
| },
| components: {
| chart
| },
| mounted() {
| let obj = {
| ydata: [
| '大雁塔',
| '大唐芙蓉园',
| '冲鼓楼',
| '小寨商业区',
| '浐灞',
| '回民街',
| '南城门',
| '北大街商业区',
| ],
| data: {
| data1: [121, 132, 133, 124, 135, 146, 127, 128],
| data2: [31, 32, 23, 21, 22, 23, 31, 22],
| data3: [41, 52, 63, 41, 52, 61, 53, 21],
| data4: [20, 30, 10, 20, 40, 50, 10, 20],
| },
| };
| let accountArr = [];
| obj.data.data1.forEach((item, index) => {
| accountArr.push(item + obj.data.data2[index] + obj.data.data3[index] + obj.data.data4[index]);
| });
| this.option1 = {
| // backgroundColor: '#000',
| //鼠标滑过提示栏
| tooltip: {
| trigger: 'axis',
| axisPointer: {
| type: 'shadow',
| },
| itemSize: 18,
| itemGap: 15,
|
| formatter: function (params) {
| console.log(params)
| // <div style="margin-bottom:10px;">${params[0].name}</div>
| //params[0].marker,marker参数为提示语前面的小圆点
| return `
| <div style="box-sizing: border-box;width: 232px;height:195px;padding:16px 0 0 19px;background-color: rgba(2, 3, 4, 1);border-radius: 10px;border: solid 1px rgba(0, 176, 255, 1);">
| <div style="display:flex;align-items: center;margin-bottom:10px;">
| <div style="width: 11px;height: 11px;margin-right:5px;background-color: rgba(0, 246, 255, 1);border-radius:50%"></div>
| <div style="font-size: 18px;margin-right:15px;">摄像头</div>
| <div class="f-DC" style="font-size: 20px;color:rgba(0, 246, 255, 1);text-align:right;width:43px">${params[0].value}</div>
| <div style="font-size: 14px;margin-left:10px;">个</div>
| </div>
| <div style="display:flex;align-items:center;margin-bottom:10px;">
| <div style="width: 11px;margin-right:5px;height: 11px;background-color: rgba(1, 138, 92, 1);border-radius:50%"></div>
| <div style="font-size: 18px;margin-right:15px;">消防栓</div>
| <div class="f-DC" style="font-size: 20px;color: rgba(1, 138, 92, 1);text-align:right;width:43px">${params[1].value}</div>
| <div style="font-size: 14px;margin-left:10px;">个</div>
| </div>
| <div style="display:flex;align-items:center;margin-bottom:10px;">
| <div style="width: 11px;margin-right:5px;height: 11px;background-color: rgba(1, 54, 143, 1);border-radius:50%"></div>
| <div style="font-size: 18px;margin-right:15px;">安防装备</div>
| <div class="f-DC" style="font-size: 20px;color: rgba(1, 54, 143, 1);text-align:right;width:43px">${params[2].value}</div>
| <div style="font-size: 14px;margin-left:10px;">个</div>
| </div>
| <div style="display:flex;align-items:center;margin-bottom:10px;">
| <div style="width: 11px;margin-right:5px;height: 11px;background-color: rgba(214, 175, 38, 1);border-radius:50%"></div>
| <div style="font-size: 18px;margin-right:15px;">其余装备</div>
| <div class="f-DC" style="font-size: 20px;color: rgba(214, 175, 38, 1);text-align:right;width:43px">${params[3].value}</div>
| <div style="font-size: 14px;margin-left:10px;">个</div>
| </div>
| <div style="display:flex;align-items:center;">
| <div style="width: 11px;margin-right:5px;height: 11px;background-color:rgba(0, 246, 255, 1);border-radius:50%"></div>
| <div style="font-size: 18px;margin-right:15px;width:72px">总计</div>
| <div class="f-DC" style="font-size: 20px;color: rgba(0, 246, 255, 1);text-align:right;width:43px">${params[0].value + params[1].value + params[2].value + params[3].value}</div>
| <div style="font-size: 14px;margin-left:10px;">个</div>
| </div>
| </div>
| `
| }
| },
| //图表选择栏
| legend: {
| icon: 'square',
| top: '-5px',
| orient: 'horizontal', //图例方向【horizontal/vertical】
| itemHeight: 12, //修改icon图形大小
| itemWidth: 12, //修改icon图形大小
| // selectedMode: false, //不允许点击图例
| itemGap: 12,
| textStyle: {
| fontSize: 12,
| color: 'rgba(233, 240, 255, 1)',
| // padding: [0, 8],
| },
| data: ['摄像头', '消防栓', '安防装备', '其余装备'],
| },
| //图标离容器的距离
| grid: {
| left: '0px',
| right: '0px',
| bottom: '0px',
| top: '30px',
| //是否包含坐标轴
| containLabel: true,
| //鼠标滑过是否显示信息栏,目前来看最好在grid中配置tooltip鼠标滑过信息栏
| },
| //x坐标轴
| xAxis: [
| {
| min: 0,//最小
| max: 300,//最大
| interval: 100,//相差
| type: 'value',
| // name: '\n\n (个)',
| nameTextStyle: {
| color: '#333',
| fontSize: 12,
| // padding: [0, 40, 0, 0],
| },
|
| axisTick: {
| show: false,
| },
| boundaryGap: false,
| axisLine: {
| show: false,
| },
| splitLine: {
| show: false
| },
| axisLabel: {
| color: 'rgba(233, 240, 255, 1)',
| fontSize: 12,
| margin: 20,
| rotate: 45,
| },
| },
| ],
| //y坐标轴
| yAxis: [
| {
| boundaryGap: false,
| type: 'category',
| name: '',
| data: obj.ydata,
| splitLine: {
| show: false,
| },
| inverse: true,
| axisTick: {
| show: false,
| },
| axisLine: {
| show: true,
| lineStyle: {
| // 属性lineStyle控制线条样式
| color: 'rgba(21,93,174)',
| width: 1,
| type: 'solid',
| },
| },
| splitLine: {
| show: true,
| lineStyle: {
| type: 'dashed',
| color: 'rgba(21, 93, 174, 1)'
| }
|
| },
| axisLabel: {
| // margin: 20,
| textStyle: {
| color: 'rgba(255, 255, 255, 1)',
| fontSize: 12,
|
| },
|
| },
| },
| ],
| // 数据展示区域
| series: [
| {
| name: '摄像头',
| type: 'bar',
| stack: 'Ad',
| barWidth: 19,
| color: {
| type: 'linear',
| x: 1,
| y: 0,
| x2: 0,
| y2: 0,
| colorStops: [
| {
| offset: 0, color: 'rgb(28,186,195)' // 100% 处的颜色
| },
| {
| offset: 1, color: 'rgb(21,93,174,1)' // 100% 处的颜色
| }
| ],
| global: false // 缺省为 false
| },
| data: obj.data.data1,
| },
| {
| name: '消防栓',
| type: 'bar',
|
| stack: 'Ad',
| barWidth: 19,
| color: {
| type: 'linear',
| x: 1,
| y: 0,
| x2: 0,
| y2: 0,
| colorStops: [
| {
| offset: 0, color: 'rgb(28,186,195)' // 0% 处的颜色
| },
| {
| offset: 1, color: 'rgb(2,151,104)' // 100% 处的颜色
| }
| ],
| global: false // 缺省为 false
| },
| data: obj.data.data2,
| },
| {
| name: '安防装备',
| type: 'bar',
| stack: 'Ad',
| // color: '#536CC4',
| barWidth: 19,
| color: {
| type: 'linear',
| x: 1,
| y: 0,
| x2: 0,
| y2: 0,
| colorStops: [
| {
| offset: 0, color: 'rgba(35,115,200,1)' // 0% 处的颜色
| },
| {
| offset: 0.5, color: 'rgb(25,110,190,.9)' // 0% 处的颜色
| },
| {
| offset: 1, color: 'rgb(21,93,174,0.8)' // 100% 处的颜色
| }
| ],
| global: false // 缺省为 false
| },
| data: obj.data.data3,
| z: 2,
| },
| {
| name: '其余装备',
| type: 'bar',
| stack: 'Ad',
| // color: 'green',
| z: 2,
| itemStyle: {
| color: {
| type: 'linear',
| x: 1,
| y: 0,
| x2: 0,
| y2: 0,
| colorStops: [
| {
| offset: 0, color: 'rgba(208, 169, 37, 1)' // 0% 处的颜色
| },
| {
| offset: 0.5, color: 'rgba(208, 169, 37, .6)' // 0% 处的颜色
| },
| {
| offset: 1, color: 'rgba(208, 169, 37, .4)' // 100% 处的颜色
| }
| ],
| global: false // 缺省为 false
| }
| },
| //不同系列的柱间距离,为百分比,如果想要两个系列的柱子重叠,可以设置 barGap 为 '-100%'。
| barWidth: 19,
| data: obj.data.data4,
| },
| ],
| };
| },
| }
|
|
|
| </script>
|
| <style lang="scss" scoped>
| .publicToilets {
| width: 100%;
| height: 33%;
| display: flex;
| flex-direction: column;
| align-items: center;
|
| .echartsTool {
| width: calc(100% - 40px);
| height: 100%;
| margin-top: 20px;
| }
|
| .header {
| width: 304px;
| height: 27.5px;
| margin-left: 20px;
| margin-top: 20px;
| background-image: url("~@/assets/img/menuTitle1.png");
| background-repeat: no-repeat;
| background-size: 100% 100%;
| font-family: PangMenZhengDao;
| text-shadow: 0px 6px 9px #20618e;
| display: flex;
| flex-direction: row;
| align-items: center;
| flex-shrink: 0;
| align-self: flex-start;
|
| .title1 {
| margin-left: 30px;
| font-size: 15px;
| color: #ffffff;
| }
| }
| }
| </style>
|
|