-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.js
118 lines (118 loc) · 2.74 KB
/
index.js
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
$(function(){
let myCharts = echarts.init(document.getElementById('cityMap'));
$.get('./libs/echarts/guangzhou.json',function(data){
echarts.registerMap('guangzhou', data, {});
var mapData = [ // 地图数据
{name: '海珠区', value: 19},
{name: '番禺区', value: 22},
{name: '白云区', value: 22},
{name: '从化区', value: 33},
{name: '花都区', value: 23},
{name: '黄埔区', value: 24},
{name: '荔湾区', value: 44},
{name: '萝岗区', value: 55},
{name: '南沙区', value: 66},
{name: '天河区', value: 22},
{name: '越秀区', value: 19},
{name: '增城区', value: 31}
];
var sanData = [ // 散点数据
{name: '散点1', value: 19},
{name: '散点2', value: 14},
{name: '散点3', value: 19},
{name: '散点4', value: 12},
{name: '散点5', value: 19},
{name: '散点6', value: 15}
];
var geoCoordMap = { // 散点坐标
'散点1': [113.52, 23.179],
'散点2': [113.42, 23.279],
'散点3': [113.32, 23.379],
'散点4': [113.22, 23.479],
'散点5': [113.12, 23.579],
'散点6': [113.62, 23.179],
};
var convertData = function (data) { // 处理数据函数
var res = [];
for (var i = 0; i < data.length; i++) {
var geoCoord = geoCoordMap[data[i].name];
if (geoCoord) {
res.push({
name: data[i].name,
value: geoCoord.concat(data[i].value)
});
}
}
return res;
};
let option = { // echarts 配置
tooltip: {
trigger: 'item'
},
geo: { // 地图配置
show: true,
map: 'guangzhou',
label: {
normal: {
show: false
},
emphasis: {
show: false
}
},
roam: false,
itemStyle: {
normal: {
areaColor: '#47D1FF',
borderColor: '#3B5077'
},
emphasis: {
areaColor: '#2B91B7'
}
},
zoom: 1.2
},
series: [{ // 散点配置
name: '数量',
type: 'effectScatter',
coordinateSystem: 'geo',
data: convertData(sanData),
symbolSize: function (val) {
return val[2];
},
showEffectOn: 'emphasis',
rippleEffect: {
brushType: 'stroke'
},
hoverAnimation: true,
label: {
normal: {
formatter: '{b}',
position: 'right',
show: false
},
emphasis: {
show: true
}
},
itemStyle: {
normal: {
color: '#ff8003'
}
}
}, { // 地图配置
name: '工程数',
type: 'map',
mapType: 'guagzhou', // 自定义扩展图表类型
geoIndex: 0,
// aspectScale: 0.75, // 长宽比
itemStyle: {
normal: {label: {show: true}},
emphasis: {label: {show: true}}
},
data: mapData
}]
};
myCharts.setOption(option);
});
});