forked from SuperMap/iClient-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathechartsBar.html
More file actions
134 lines (130 loc) · 4.39 KB
/
echartsBar.html
File metadata and controls
134 lines (130 loc) · 4.39 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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ECharts Bar with Leaflet</title>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
<script type="text/javascript" include="echarts" src="../../dist/include-leaflet.js"></script>
<script type="text/javascript">
var host = window.isLocal ? document.location.protocol + "//" + document.location.host : "http://support.supermap.com.cn:8090";
var map, resultLayer,
url = host + "/iserver/services/map-world/rest/maps/%E4%B8%96%E7%95%8C%E5%9C%B0%E5%9B%BE_Gray";
var url2 = host + "/iserver/services/map-china400/rest/maps/China";
map = L.map('map', {
preferCanvas: true,
crs: L.CRS.EPSG4326,
center: [30.236064370321, 120.14322240845],
maxZoom: 18,
zoom: 5
});
L.supermap.tiledMapLayer(url).addTo(map);
option = {
legend: {
data: ['降雨量', '径流量'],
align: 'left'
},
toolbox: {
feature: {
magicType: {
type: ['stack', 'tiled']
},
saveAsImage: {
pixelRatio: 2
}
}
},
tooltip: {},
xAxis: {
data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
silent: false,
splitLine: {
show: false
}
},
yAxis: {},
series: [{
name: 'bar',
type: 'bar',
animationDelay: function (idx) {
return idx * 10;
}
}, {
name: 'bar2',
type: 'bar',
animationDelay: function (idx) {
return idx * 10 + 100;
}
}],
animationEasing: 'elasticOut',
animationDelayUpdate: function (idx) {
return idx * 5;
}
};
var div = L.DomUtil.create('div');
var chart = echarts.init(div, '', {
width: 500,
height: 300
});
chart.setOption(option);
query();
function query() {
clearLayer();
var param = new SuperMap.QueryBySQLParameters({
queryParams: [{
name: "China_ProCenCity_pt@China",
attributeFilter: "1 = 1"
}, {
name: "China_Capital_pt@China",
attributeFilter: "1 = 1"
}]
});
L.supermap
.queryService(url2)
.queryBySQL(param, function (serviceResult) {
serviceResult.result.recordsets.map(function (records) {
resultLayer = L.geoJSON(records.features, {
coordsToLatLng: function (coords) {
var latlng = L.CRS.EPSG3857.unproject(L.point(coords[0], coords[1]));
latlng.alt = coords[2];
return latlng;
}
}).bindPopup(function (layer) {
var city = layer.feature.properties.NAME;
var data1 = [];
var data2 = [];
for (var i = 0; i < 7; i++) {
var data = Math.random().toFixed(2);
data1.push(data);
data2.push(data * (Math.random() + 1.5));
}
chart.setOption({
title: {
text: city,
subtext: '数据纯属虚构'
},
series: [
{
name: '降雨量',
data: data1
},
{
name: '径流量',
data: data2
}
]
});
return chart.getDom();
}, {maxWidth: 600}).addTo(map);
});
});
}
function clearLayer() {
if (resultLayer) {
resultLayer.removeFrom(map);
}
}
</script>
</body>
</html>