-
Notifications
You must be signed in to change notification settings - Fork 1
109 lines (107 loc) · 2.7 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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>echarts extension azuremaps</title>
<link
href="https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.css"
rel="stylesheet"
/>
<script src="https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.js"></script>
<!-- ECharts CDN -->
<script
type="text/javascript"
src="https://fastly.jsdelivr.net/npm/echarts@5/dist/echarts.min.js"
></script>
<script type="text/javascript" src="../dist/echarts-extension-azure-map.min.js"></script>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
html,
body,
#app,
#echarts-azuremap {
width: 100%;
height: 100%;
overflow: hidden;
}
</style>
</head>
<body onload="loadMap()">
<div id="app">
<div id="echarts-azuremap"></div>
</div>
</body>
<script>
const data = {
北京: [10, 20, 30, 40],
攀枝花: [15, 20, 36, 42],
开封: [17, 42, 15, 31],
上海: [46, 50, 59, 80],
广州: [90, 45, 36, 15],
};
const geoCoords = {
北京: [116.46, 39.92],
攀枝花: [101.718637, 26.582347],
开封: [114.35, 34.79],
上海: [121.48, 31.22],
广州: [113.23, 23.16],
};
const pieDimensions = ['A', 'B', 'C', 'D'];
const pieSeries = [];
echarts.util.each(data, function (values, name) {
pieSeries.push({
type: 'pie',
name: name,
coordinateSystem: 'azuremap',
center: geoCoords[name],
radius: 20,
data: echarts.util.map(values, function (value, idx) {
return {
name: pieDimensions[idx],
value: value,
};
}),
label: {
show: false,
},
emphasis: {
label: {
show: true,
},
labelLine: {
show: true,
lineStyle: {
color: '#fff',
},
},
},
});
});
const option = {
azuremap: {
view: 'Auto',
language: 'en-US',
center: [113.493471, 23.169598],
zoom: 5,
authOptions: {
authType: 'subscriptionKey',
subscriptionKey: 'your subscriptionKey',
},
},
tooltip: {
trigger: 'item',
},
animation: true,
series: pieSeries,
};
function loadMap() {
const chart = echarts.init(document.getElementById('echarts-azuremap'));
chart.setOption(option);
}
</script>
</html>