-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdraft.html
292 lines (286 loc) · 11 KB
/
draft.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
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
<html>
<head>
<meta charset="utf-8">
<title>中正智控公司概况</title>
<link href="https://cdn.bootcss.com/normalize/8.0.1/normalize.min.css" rel="stylesheet">
<style>
.wrapper { width: 100%; height: 100% }
.content { width: 100%; height: 100%; display: flex; flex-direction: row; background-color: black; }
.content>.left { flex: 1; }
.content>.center { flex: 3; }
.content>.right { flex: 1; }
#chart-map { width: 100%; height: 100%; }
</style>
</head>
<body>
<div class="wrapper">
<div class="content">
<div class="left">
</div>
<div class="center">
<div id="chart-map"></div>
</div>
<div class="right">
</div>
</div>
</div>
<!-- <script src="http://api.map.baidu.com/getscript?v=2.0&ak=LMhOLFt0YNFLvtQWdAuHSGS1aXdoC2uB"></script> -->
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/echarts/4.2.1/echarts.min.js"></script>
<script src="https://cdn.bootcss.com/echarts/4.2.1/extension/bmap.min.js"></script>
<script src="https://cdn.bootcss.com/echarts/4.2.0-rc.2/extension/dataTool.min.js"></script>
<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/china.js"></script>
<script>
// 常量
var mapName = 'china'
var pcolor = '#45a1f1'
var ncolor = '#020b3b'
var max = 480, min = 9, maxSize4Pin = 150, minSize4Pin = 20; // 气泡参数
// 数据
var data = [{name: "北京", value: 25866}, {name: "天津", value: 700}, {name: "上海", value: 7620}, {name: "重庆", value: 459}, {name: "河北", value: 344}, {name: "山西", value: 185}, {name: "辽宁", value: 142}, {name: "吉林", value: 32}, {name: "黑龙江", value: 24}, {name: "江苏", value: 521}, {name: "浙江", value: 1186}, {name: "安徽", value: 220}, {name: "福建", value: 251}, {name: "江西", value: 318}, {name: "山东", value: 533}, {name: "河南", value: 382}, {name: "湖北", value: 120}, {name: "湖南", value: 261}, {name: "广东", value: 786}, {name: "海南", value: 52}, {name: "四川", value: 225}, {name: "贵州", value: 46}, {name: "云南", value: 68}, {name: "陕西", value: 145}, {name: "甘肃", value: 66}, {name: "青海", value: 24}, {name: "台湾", value: 1}, {name: "内蒙古自治区", value: 7}, {name: "广西壮族自治区", value: 2}, {name: "西藏自治区", value: 0}, {name: "宁夏回族自治区", value: 1}, {name: "新疆维吾尔自治区", value: 6}, {name: "香港特别行政区", value: 0}, {name: "澳门特别行政区", value: 0}]
// 提示数据
var toolTipData = []
// 地理位置
var geoCoordMap = {}
var mapFeatures = echarts.getMap(mapName).geoJson.features
mapFeatures.forEach(function(v) {
// 地区名称
var name = v.properties.name;
// 地区经纬度
geoCoordMap[name] = v.properties.cp;
});
// 关联数据和地理位置
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;
};
// 图表配置
option = {
tooltip: {
trigger: 'item',
formatter: function (params) {
if(typeof(params.value)[2] == "undefined"){
if (!params.value) {
return params.name + ' : -';
}
return params.name + ' : ' + params.value;
}else{
return params.name + ' : ' + params.value[2];
}
}
},
// backgroundColor: {
// type: 'linear',
// x: 0,
// y: 0,
// x2: 1,
// y2: 1,
// colorStops: [{
// offset: 0, color: '#0f2c70' // 0% 处的颜色
// }, {
// offset: 1, color: '#091732' // 100% 处的颜色
// }],
// globalCoord: false // 缺省为 false
// },
legend: {
orient: 'vertical',
y: 'bottom',
x: 'right',
data: ['credit_pm2.5'],
textStyle: {
color: '#fff'
}
},
visualMap: {
show: false,
min: 0,
max: 500,
left: 'left',
top: 'bottom',
text: ['高', '低'], // 文本,默认为数值文本
calculable: true,
seriesIndex: [1],
inRange: {
color: [ncolor]
// color: [ncolor, '#512a9d', '#0a2029']
}
},
// 工具按钮组
// toolbox: {
// show: true,
// orient: 'vertical',
// left: 'right',
// top: 'center',
// feature: {
// dataView: {
// readOnly: false
// },
// restore: {},
// saveAsImage: {}
// }
// },
geo: {
show: true,
map: mapName,
label: {
normal: {
show: false
},
emphasis: {
show: false,
}
},
roam: true,
itemStyle: {
normal: {
areaColor: ncolor,
borderColor: pcolor,
borderWidth: 1.8,
shadowColor: 'rgba(69, 161, 241, 0.4)',
shadowBlur: 20,
opacity: 0.8,
// shadowOffsetX: -2,
// shadowOffsetY: -2
},
emphasis: {
areaColor: '#2B91B7',
}
}
},
series: [
{ // 散点
name: '散点',
type: 'effectScatter',
coordinateSystem: 'geo',
data: convertData(data),
symbolSize: function(val) {
return 10;
},
label: {
normal: {
formatter: '{b}',
position: 'right',
show: true
},
emphasis: {
show: true
}
},
itemStyle: {
normal: {
color: '#05C3F9'
}
}
},
{ // 区域颜色
type: 'map',
map: mapName,
geoIndex: 0,
aspectScale: 0.75, // 长宽比
showLegendSymbol: false, // 存在legend时显示
label: {
normal: {
show: false
},
emphasis: {
show: false,
textStyle: {
color: '#fff'
}
}
},
roam: true,
itemStyle: {
normal: {
areaColor: '#031525',
borderColor: '#3B5077',
},
emphasis: {
areaColor: '#2B91B7'
}
},
animation: false,
data: data
},
{ // 气泡
name: '点',
type: 'scatter',
coordinateSystem: 'geo',
symbol: 'pin', //气泡
symbolSize: function(val) {
var a = (maxSize4Pin - minSize4Pin) / (max - min);
var b = minSize4Pin - a * min;
b = maxSize4Pin - a * max;
return 35 ;
},
label: {
normal: {
show: true,
formatter: function(params) {
return params.data.value[2]
},
textStyle: {
color: '#fff',
fontSize: 9,
}
}
},
itemStyle: {
normal: {
color: '#F62157', // 标志颜色
}
},
zlevel: 6,
data: convertData(data),
},
{
name: 'Top 5',
type: 'effectScatter',
coordinateSystem: 'geo',
data: convertData(data.sort(function(a, b) {
return b.value - a.value;
}).slice(0, 5)),
symbolSize: function(val) {
return 20;
},
showEffectOn: 'render',
rippleEffect: {
brushType: 'stroke'
},
hoverAnimation: true,
label: {
normal: {
formatter: '{b}',
position: 'right',
show: false // bug: 设置为true造成top5的省份名称重影
}
},
itemStyle: {
normal: {
color: 'yellow',
shadowBlur: 10,
shadowColor: 'yellow'
}
},
zlevel: 1
}
]
};
let chart = echarts.init(document.getElementById("chart-map"))
chart.setOption(option)
// 自适应
window.onresize = function () {
chart.resize()
}
</script>
</body>
</html>