Map.vue
3.17 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
<template>
<div>
<div id="map" class="map"></div>
</div>
</template>
<script>
import utils from '../../utils/util'
import * as echarts from 'echarts'
import mapBg from '../../assets/images/map-bg.png'
export default {
name: 'Map',
mounted() {
console.log(1111)
const imgDom = new Image()
imgDom.src = '../../assets/images/map-bg.png'
imgDom.alt = 'alt'
var option = {
tooltip: {
show: true,
borderWidth: 0,
padding: 0,
backgroundColor: '#051526',
formatter: function(params) {
var _html = `<div style="backdrop-filter: blur(4px);background-color: #051526;border: 2px solid;border-image: linear-gradient(90deg, #074989, #30DCFF, #074989) 1;padding: 10px;">
<div style="color: #fff;">${params.name}</div>
<div style="display:flex;"><div style="color: #c9c9c9">客单价:</div><div style="color: #fff;">¥${params.data ? utils.numAddSymbol(params.data.value1) : 0}</div></div>
<div style="display:flex;"><div style="color: #c9c9c9">转化率:</div><div style="color: #fff;">${params.data ? utils.numAddSymbol(params.data.value2) : 0}%</div></div>
<div style="display:flex;"><div style="color: #c9c9c9">占比:</div><div style="color: #fff;">${params.data ? utils.numAddSymbol(params.data.rate) : 0}%</div></div>
</div>`
return _html
}
},
series: [{
type: 'map',
map: 'china',
data: [
{ name: '北京', value: 100, value1: 2323, value2: 43, rate: '29' },
{ name: '上海', value: 200, value1: 2323, value2: 3, rate: '29' },
{ name: '广东', value: 300, value1: 2323, value2: 34, rate: '29' }
],
itemStyle: {
// areaColor: '#061422',
areaColor: {
image: mapBg,
repeat: 'repeat'
},
borderColor: '#65C6F8',
shadowBlur: 10,
shadowColor: 'rgba(61, 87, 255, 0.41)'
},
emphasis: {
label: {
color: '#fff'
},
itemStyle: {
areaColor: {
type: 'linear',
x: 0,
y: 0,
x2: 1,
y2: 0,
colorStops: [{
offset: 0, color: '#079FF1' // 0% 处的颜色
}, {
offset: 1, color: '#6578FF' // 100% 处的颜色
}],
global: false // 缺省为 false
}
},
select: {
areaColor: {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [{
offset: 0, color: '#079FF1' // 0% 处的颜色
}, {
offset: 1, color: '#6578FF' // 100% 处的颜色
}],
global: false // 缺省为 false
}
}
}
}]
}
var myChart = echarts.init(document.getElementById('map'))
myChart.setOption(option)
}
}
</script>
<style lang="scss">
.map {
width: 40.58vw;
height: 45.89vh;
}
</style>