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
139 lines (135 loc) · 4.81 KB
/
echartsBar.html
File metadata and controls
139 lines (135 loc) · 4.81 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
135
136
137
138
139
<!--********************************************************************
* Copyright© 2000 - 2018 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title data-i18n="resources.title_GraphBar"></title>
<script type="text/javascript" src="../js/include-web.js"></script>
</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/leaflet/include-leaflet.js"></script>
<script type="text/javascript">
var host = window.isLocal ? window.server : "http://support.supermap.com.cn:8090";
var map, resultLayer,
url = host + "/iserver/services/map-world/rest/maps/世界地图_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: [resources.text_rainfall, resources.text_runoff],
align: 'left'
},
toolbox: {
feature: {
magicType: {
type: ['stack', 'tiled']
},
saveAsImage: {
pixelRatio: 2
}
}
},
tooltip: {},
xAxis: {
data: [resources.text_monday,resources.text_tuesday,resources.text_wednesday,resources.text_thursday,resources.text_friday,resources.text_saturday,resources.text_sunday],
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: resources.text_fictitiouData,
},
series: [
{
name: resources.text_rainfall,
data: data1
},
{
name:resources.text_runoff,
data: data2
}
]
});
return chart.getDom();
}, {maxWidth: 600}).addTo(map);
});
});
}
function clearLayer() {
if (resultLayer) {
resultLayer.removeFrom(map);
resultLayer.removeFrom(map);
}
}
</script>
</body>
</html>