index.vue
10.6 KB
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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
<template>
<div class="app-chinaMapBox theme-map">
<div class="mapTitle eleVerHorCenter-flex">
<div class="cellBox">
<table class="parkTotalTb">
<tr>
<td><div class="parkTotalImg"></div></td>
<td><div class="infoBox"><div><countTo :startVal='parkParams.startVal' :endVal='parkParams.endVal' :duration='animationTime'></countTo></div><div>停车场总数</div></div> </td>
</tr>
</table>
</div>
<div class="cellBox">
<table class="parkTotalTb">
<tr>
<td><div class="memberTotalImg"></div></td>
<td><div class="infoBox"><div><countTo :startVal='memberParams.startVal' :endVal='getParkingTotal' :duration='animationTime'></countTo></div><div>会员总数</div></div> </td>
</tr>
</table>
</div>
<div class="cellBox">
<table class="parkTotalTb">
<tr>
<td><div class="dayTotalImg"></div></td>
<td><div class="infoBox"><div><countTo :startVal='dayParams.startVal' :endVal='getOrderTotal' :duration='animationTime'></countTo></div><div>今日订单数</div></div> </td>
</tr>
</table>
</div>
</div>
<div class="mapChart"> </div>
</div>
</template>
<script>
import echarts from 'echarts'
import countTo from 'vue-count-to';//通过设置:endVall 和 :startVall 会自动判断计数和倒数,:duration='3000'是指完成动画的时间。
import {mapGetters} from 'vuex' //use commit
export default {
name: "chinaMap",
components: { countTo },
data() {
return {
animationTime:5000,//动画时间
parkParams:{//parkTotal:738,//停车场总数
startVal:0,
endVal: 0
},
memberParams:{//memberTotal:738,//会员总数
startVal:0,
endVal: 7200
},
dayParams:{//dayTotal:10000,//今日订单数
startVal:0,
endVal: 1000
},
mapChart: {},
mapData:[],
coordinateData:{}
}
},
computed: {
...mapGetters(['getParkingTotal','getOrderTotal'])
},
mounted() {
this.axios.post('urban/intelligence/park/queryParkNumStatisticByOrgIds',{
orgIds: [10003,10005]
}).then((response)=>{
let data = response.data.data
this.parkParams.endVal=data
}).catch((response)=>{
console.log(response);
})
this.axios.post('urban/intelligence/berth/queryBerthStatisticForOrgId',{
orgIds: [10003,10005]
}).then((response)=>{
let data = response.data.data
console.log(data)
//let mapData = [];
for (let i=0;i<data.length;i++){
this.mapData.push({
name:data[i].orgName,
value:data[i].allBerthNum
})
//this.coordinateData.data[i].orgName = [data[i].lonId,data[i].orgId]
}
this.mapChart= this.createPie();
window.addEventListener('resize', function() {
this.mapChart.resize()
}.bind(this));
}).catch((response)=>{
console.log(response);
})
},
methods: {
/*
* china地图
* */
createPie(){
let mapChart = echarts.init(document.querySelector('.app-chinaMapBox .mapChart'));
const series=this._getSeries();
const option= {
grid: {
top: '0%',left: '0%',
right: '0%',bottom: '3%'
},
tooltip: {
trigger: 'item',
backgroundColor: 'rgba(6, 75, 140, 0)',
borderColor: '#FFFFCC',
showDelay: 0,
hideDelay: 0,
enterable: true,
transitionDuration: 0,
//extraCssText: 'z-index:100',
formatter: function(params, ticket, callback) {
if (params.seriesType != "lines") {
//console.log(params)
//根据业务自己拓展要显示的内容
var res = "";
var name = params.name;
var value = params.value;
var numStyle='color:#02C202; font-size: 16px; font-family: display-free;line-height:25px;font-weight:bold;';
res = "<div style='padding:5px;height:16px;line-height:16px;background:rgba(43, 140, 209, 0.96)'>" + name + "</div>" ;
res +="<div style='padding:5px;height:25px;background:rgba(6, 75, 140, 0.9);'>"+"泊位总数:"+"<span style='"+numStyle+"'>"+ value[2] +"</span></div>";
return res;
}
}
},
dataRange: {
calculable: false,
color: ['#FFAB00'],
textStyle: {color: '#fff' },
show: false,
},
geo: {
map: 'china',
label: {
normal: {show: false },
emphasis: {show: false}
},
center: [104.94296,37.433088],
roam: true,zoom:1.3,
scaleLimit:{ min:1.1,max:5 },
itemStyle: {
normal: {
areaColor: '#020e33',borderColor: '#404a59'
},
emphasis: { areaColor: '#04294A'}
},
},
series: series
}
mapChart.setOption(option);
return mapChart;
},
//设置 series
_getSeries(){
const geoCoordMap = {
'无锡': [120.318915, 31.494359],
// '北京': [116.372555, 39.918295],//北京西城
'赤峰': [118.892761, 42.263681],
// '丹阳': [119.612594, 32.016089],
// '双流': [103.912493, 30.586969] //成都双流区
};
const dataFrom = '无锡';
// const data = [
// {name: '赤峰',value: 95},
// {name: '双流',value: 70},
// {name: '北京',value: 70},
// {name: '丹阳', value: 30}
// ];
const data = this.mapData;
console.log(data)
let tmpSeries=[{
//name: '无锡',
type: 'lines',
zlevel: 1,
effect: {
show: true,
period: 6,
trailLength: 0.2, //0-1
color: '#fff',
//shadowBlur: 3,
symbolSize: 2
},
lineStyle: {
normal: {
color: '#a6c84c',
width: 0,
curveness: 0.2
}
},
data: data.map(function(dataItem) {
return {
fromName: dataFrom,
toName: dataItem.name,
coords: [
geoCoordMap[dataFrom],
geoCoordMap[dataItem.name]
]
}
})
},
{
//name: '无锡',
type: 'lines',
//zlevel: 2,
symbol: 'none',//['none', 'pin'],
symbolSize: 8,
effect: {
show: true,
period: 6,
trailLength: 0,
color: '#fff',
},
lineStyle: {
normal: {
color: '#FFAB00', //线颜色
width: 1,
opacity: 0.6,
curveness: 0.2
}
},
data: data.map(function(dataItem) {
return {
fromName: dataFrom,
toName: dataItem.name,
coords: [
geoCoordMap[dataFrom],
geoCoordMap[dataItem.name]
]
}
})
},
{
name: '城市',
type: 'effectScatter',
coordinateSystem: 'geo',
//zlevel: 2,
rippleEffect: {
scale: 5,
brushType: 'stroke'
},
label: {
normal: {
show: true,
position: 'right',
color: '#FFFFFF',
formatter: '{b}'
}
},
//光圈大小
symbolSize: function(val) {
return 10;
},
itemStyle: {
normal: {
color: '#a6c84c'
}
},
data: data.map(function(dataItem) {
return {
name: dataItem.name,
value: geoCoordMap[dataItem.name].concat([dataItem.value])
};
})
},
{
name: '无锡',
type: 'scatter',
coordinateSystem: 'geo',
label: {
normal: {
show: true,
position: 'bottom',
formatter: '{b}',
textStyle: {
color: "#ED3D06"
}
},
emphasis: {
show: true
}
},
symbol: 'circle',
symbolSize: 5,
data: [{
name: dataFrom,
value: geoCoordMap[dataFrom].concat([100]),
}],
}
];
return tmpSeries;
},
//测试被父组件调用
setParkTotal(){
this.parkParams.startVal=this.parkParams.endVal;
this.parkParams.endVal=105;
console.log("停车场总数:root");
}
}
}
</script>
<style scoped lang="scss">
.app-chinaMapBox{
position: relative;
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
.mapChart{
position: relative;
width: 100%;
height: 100%;
/*margin-top: 5%;*/
/*margin-bottom: 5px;*/
/*height: -webkit-calc(100% - (5% + 5px));*/
/*height: -moz-calc(100% - (5% + 5px));*/
/*height: calc(100% - (5% + 5px));*/
/*top:0;left: 0;*/
/*bottom: 0;*/
/*right:0;*/
/*z-index: -1;*/
}
.cellBox{
width: 33.333%;text-align: center;
}
.mapTitle{
position: absolute;
top: 0;
width: 100%;
height: 70px;
background-color:RGBA(0, 45, 140, .7);
z-index: 5;
}
.parkTotalImg{
background: url(../../images/map/parkTotal.svg) no-repeat;
background-size: 100% 100%;
width: 45px;height: 45px;
}
.memberTotalImg{
background: url(../../images/map/memberTotal.svg) no-repeat;
background-size: 100% 100%;
width: 45px;height: 45px;
}
.dayTotalImg{
background: url(../../images/map/dayTotal.svg) no-repeat;
background-size: 100% 100%;
width: 45px;height: 45px;
}
.parkTotalTb{
display: inline-block;
margin-top:2px;
}
.infoBox{
margin-left: 5px;
text-align: left;
}
/*数字:738*/
.infoBox>div:first-child{
font-size: 24px;
}
/*文字:会员总数*/
.infoBox>div:last-child{
color: #00CFFE;font-size: 14px;
}
}
</style>