Skip to content

Commit a77d165

Browse files
committed
add AMap example
1 parent 2ced799 commit a77d165

File tree

6 files changed

+257
-12
lines changed

6 files changed

+257
-12
lines changed

AMap/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- [AMap - AMap_base](AMap/amap_base.md ':type=code')

AMap/amap_base.html

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Awesome-pyecharts</title>
6+
<script type="text/javascript" src="https://assets.pyecharts.org/assets/v5/echarts.min.js"></script>
7+
<script type="text/javascript" src="https://assets.pyecharts.org/assets/v5/echarts-extension-amap.min.js"></script>
8+
<script type="text/javascript" src="https://webapi.amap.com/maps?v=2.0&key=fakekey&plugin=AMap.Scale,AMap.ToolBar"></script>
9+
10+
</head>
11+
<body >
12+
<div id="dd03edd2a4a045d8a3b509f50788afd8" class="chart-container" style="width:900px; height:500px; "></div>
13+
<script>
14+
var chart_dd03edd2a4a045d8a3b509f50788afd8 = echarts.init(
15+
document.getElementById('dd03edd2a4a045d8a3b509f50788afd8'), 'white', {renderer: 'canvas'});
16+
var option_dd03edd2a4a045d8a3b509f50788afd8 = {
17+
"animation": true,
18+
"animationThreshold": 2000,
19+
"animationDuration": 1000,
20+
"animationEasing": "cubicOut",
21+
"animationDelay": 0,
22+
"animationDurationUpdate": 300,
23+
"animationEasingUpdate": "cubicOut",
24+
"animationDelayUpdate": 0,
25+
"aria": {
26+
"enabled": false
27+
},
28+
"color": [
29+
"#5470c6",
30+
"#91cc75",
31+
"#fac858",
32+
"#ee6666",
33+
"#73c0de",
34+
"#3ba272",
35+
"#fc8452",
36+
"#9a60b4",
37+
"#ea7ccc"
38+
],
39+
"series": [
40+
{
41+
"type": "scatter",
42+
"name": "amap",
43+
"coordinateSystem": "amap",
44+
"symbolSize": 12,
45+
"data": [
46+
{
47+
"name": "\u5e7f\u4e1c\u7701",
48+
"value": [
49+
113.26653,
50+
23.132191,
51+
112
52+
]
53+
},
54+
{
55+
"name": "\u5317\u4eac\u5e02",
56+
"value": [
57+
116.4,
58+
39.9,
59+
125
60+
]
61+
},
62+
{
63+
"name": "\u4e0a\u6d77\u5e02",
64+
"value": [
65+
121.47,
66+
31.23,
67+
21
68+
]
69+
},
70+
{
71+
"name": "\u6c5f\u897f\u7701",
72+
"value": [
73+
115.909228,
74+
28.675696,
75+
147
76+
]
77+
},
78+
{
79+
"name": "\u6e56\u5357\u7701",
80+
"value": [
81+
112.98381,
82+
28.112444,
83+
146
84+
]
85+
},
86+
{
87+
"name": "\u6d59\u6c5f\u7701",
88+
"value": [
89+
120.152791,
90+
30.267446,
91+
28
92+
]
93+
},
94+
{
95+
"name": "\u6c5f\u82cf\u7701",
96+
"value": [
97+
118.763232,
98+
32.061707,
99+
72
100+
]
101+
}
102+
],
103+
"label": {
104+
"show": true,
105+
"margin": 8,
106+
"formatter": "{b}",
107+
"valueAnimation": false
108+
}
109+
}
110+
],
111+
"legend": [
112+
{
113+
"data": [
114+
"amap"
115+
],
116+
"selected": {},
117+
"show": true,
118+
"padding": 5,
119+
"itemGap": 10,
120+
"itemWidth": 25,
121+
"itemHeight": 14,
122+
"backgroundColor": "transparent",
123+
"borderColor": "#ccc",
124+
"borderRadius": 0,
125+
"pageButtonItemGap": 5,
126+
"pageButtonPosition": "end",
127+
"pageFormatter": "{current}/{total}",
128+
"pageIconColor": "#2f4554",
129+
"pageIconInactiveColor": "#aaa",
130+
"pageIconSize": 15,
131+
"animationDurationUpdate": 800,
132+
"selector": false,
133+
"selectorPosition": "auto",
134+
"selectorItemGap": 7,
135+
"selectorButtonGap": 10
136+
}
137+
],
138+
"tooltip": {
139+
"show": true,
140+
"trigger": "item",
141+
"triggerOn": "mousemove|click",
142+
"axisPointer": {
143+
"type": "line"
144+
},
145+
"showContent": true,
146+
"alwaysShowContent": false,
147+
"showDelay": 0,
148+
"hideDelay": 100,
149+
"enterable": false,
150+
"confine": false,
151+
"appendToBody": false,
152+
"transitionDuration": 0.4,
153+
"formatter": function (params) { return params.name + ' : ' + params.value[2]; },
154+
"textStyle": {
155+
"fontSize": 14
156+
},
157+
"borderWidth": 0,
158+
"padding": 5,
159+
"order": "seriesAsc"
160+
},
161+
"title": [
162+
{
163+
"show": true,
164+
"text": "AMap-\u57fa\u672c\u793a\u4f8b",
165+
"target": "blank",
166+
"subtarget": "blank",
167+
"padding": 5,
168+
"itemGap": 10,
169+
"textAlign": "auto",
170+
"textVerticalAlign": "auto",
171+
"triggerEvent": false
172+
}
173+
],
174+
"amap": {
175+
"center": [
176+
120.13066322374,
177+
30.240018034923
178+
],
179+
"viewMode": "3D",
180+
"resizeEnable": true,
181+
"renderOnMoving": true,
182+
"echartsLayerInteractive": true,
183+
"largeMode": false
184+
}
185+
};
186+
chart_dd03edd2a4a045d8a3b509f50788afd8.setOption(option_dd03edd2a4a045d8a3b509f50788afd8);
187+
// Get AMap extension component
188+
var amapComponent = chart_dd03edd2a4a045d8a3b509f50788afd8.getModel().getComponent('amap');
189+
// Get the instance of AMap
190+
var amap = amapComponent.getAMap();
191+
// Add some controls provided by AMap.
192+
amap.addControl(new AMap.Scale());
193+
amap.addControl(new AMap.ToolBar());
194+
amapComponent.setEChartsLayerInteractive(true);
195+
</script>
196+
</body>
197+
</html>

AMap/amap_base.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
## pyecharts 代码 / 效果
3+
4+
* 需要 pyecharts 2.0.7+ 以上版本才有该图例(Requires pyecharts 2.0.7+ or higher to have this chart)
5+
6+
```python
7+
from pyecharts import options as opts
8+
from pyecharts.charts import AMap
9+
from pyecharts.faker import Faker
10+
11+
c = (
12+
AMap()
13+
.add_schema(amap_ak="fakekey", center=[120.13066322374, 30.240018034923])
14+
.add(
15+
"amap",
16+
[list(z) for z in zip(Faker.provinces, Faker.values())],
17+
label_opts=opts.LabelOpts(formatter="{b}"),
18+
)
19+
.set_global_opts(title_opts=opts.TitleOpts(title="AMap-基本示例"))
20+
.render("amap_base.html")
21+
)
22+
23+
# 下面的示例大概率无法展示,原因是需要一个有效的 amap_ak,需要自行申请!
24+
# There is a high probability that the following example will not be displayed, due to the need for a valid amap_ak, which needs to be requested on its own!
25+
```
26+
27+
<iframe width="100%" height="800px" src="AMap/amap_base.html"></iframe>

AMap/amap_base.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from pyecharts import options as opts
2+
from pyecharts.charts import AMap
3+
from pyecharts.faker import Faker
4+
5+
# Start from pyecharts version 2.0.7
6+
7+
c = (
8+
AMap()
9+
.add_schema(amap_ak="fakekey", center=[120.13066322374, 30.240018034923])
10+
.add(
11+
"amap",
12+
[list(z) for z in zip(Faker.provinces, Faker.values())],
13+
label_opts=opts.LabelOpts(formatter="{b}"),
14+
)
15+
.set_global_opts(title_opts=opts.TitleOpts(title="AMap-基本示例"))
16+
.render("amap_base.html")
17+
)

BMap/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
- [Bmap - Air_quality_baidu_map](BMap/air_quality_baidu_map.md ':type=code')
2-
- [Bmap - Bmap_beijing_bus_routines](BMap/bmap_beijing_bus_routines.md ':type=code')
3-
- [Bmap - Bmap_base](BMap/bmap_base.md ':type=code')
4-
- [Bmap - Bmap_heatmap](BMap/bmap_heatmap.md ':type=code')
5-
- [Bmap - Bmap_custom](BMap/bmap_custom.md ':type=code')
6-
- [Bmap - Hiking_trail_in_hangzhou](BMap/hiking_trail_in_hangzhou.md ':type=code')
1+
- [BMap - Air_quality_baidu_map](BMap/air_quality_baidu_map.md ':type=code')
2+
- [BMap - BMap_beijing_bus_routines](BMap/bmap_beijing_bus_routines.md ':type=code')
3+
- [BMap - BMap_base](BMap/bmap_base.md ':type=code')
4+
- [BMap - BMap_heatmap](BMap/bmap_heatmap.md ':type=code')
5+
- [BMap - BMap_custom](BMap/bmap_custom.md ':type=code')
6+
- [BMap - Hiking_trail_in_hangzhou](BMap/hiking_trail_in_hangzhou.md ':type=code')

_sidebar.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
- [中文简介](README.md)
44
- [英文简介](README_EN.md)
55
- 示例
6+
- [**高德地图 AMap**](AMap/README.md)
7+
- [AMap - AMap_base](AMap/amap_base.md ':type=code')
8+
69
- [**百度地图 BMap**](BMap/README.md)
7-
- [Bmap - Air_quality_baidu_map](BMap/air_quality_baidu_map.md ':type=code')
8-
- [Bmap - Bmap_beijing_bus_routines](BMap/bmap_beijing_bus_routines.md ':type=code')
9-
- [Bmap - Bmap_base](BMap/bmap_base.md ':type=code')
10-
- [Bmap - Bmap_heatmap](BMap/bmap_heatmap.md ':type=code')
11-
- [Bmap - Bmap_custom](BMap/bmap_custom.md ':type=code')
12-
- [Bmap - Hiking_trail_in_hangzhou](BMap/hiking_trail_in_hangzhou.md ':type=code')
10+
- [BMap - Air_quality_baidu_map](BMap/air_quality_baidu_map.md ':type=code')
11+
- [BMap - BMap_beijing_bus_routines](BMap/bmap_beijing_bus_routines.md ':type=code')
12+
- [BMap - BMap_base](BMap/bmap_base.md ':type=code')
13+
- [BMap - BMap_heatmap](BMap/bmap_heatmap.md ':type=code')
14+
- [BMap - BMap_custom](BMap/bmap_custom.md ':type=code')
15+
- [BMap - Hiking_trail_in_hangzhou](BMap/hiking_trail_in_hangzhou.md ':type=code')
1316

1417
- [**柱状图 Bar**](Bar/README.md)
1518
- [Bar - Stack_bar_percent](Bar/stack_bar_percent.md ':type=code')

0 commit comments

Comments
 (0)