Skip to content

Commit 19fd4ff

Browse files
committed
[feature] 图表微件(edit by yangtt)
review by songym
1 parent 872ecce commit 19fd4ff

File tree

19 files changed

+82341
-81374
lines changed

19 files changed

+82341
-81374
lines changed

dist/leaflet/iclient9-leaflet.js

Lines changed: 80790 additions & 79771 deletions
Large diffs are not rendered by default.

dist/leaflet/iclient9-leaflet.min.js

Lines changed: 149 additions & 1599 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/leaflet/include-leaflet.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@
8080
inputScript("https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.12.13/xlsx.core.min.js");
8181
}
8282
if (!inArray(excludes, 'iclient9-leaflet')) {
83-
if (supportES6() && !inArray(includes, 'iclient9-plot-leaflet')) {
84-
inputScript("../../dist/leaflet/iclient9-leaflet-es6.min.js");
85-
} else {
83+
// if (supportES6() && !inArray(includes, 'iclient9-plot-leaflet')) {
84+
// inputScript("../../dist/leaflet/iclient9-leaflet-es6.min.js");
85+
// } else {
8686
inputScript("../../dist/leaflet/iclient9-leaflet.min.js");
87-
}
87+
// }
8888
}
8989
if (inArray(includes, 'iclient9-leaflet-css')) {
9090
inputCSS("../../dist/leaflet/iclient9-leaflet.min.css");

examples/img/scatter.png

1.1 KB
Loading

examples/leaflet/config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,12 @@ var exampleConfig = {
12121212
version: "9.1.0",
12131213
thumbnail: "widgets_dataServiceQuery.png",
12141214
fileName: "widgets_dataServiceQuery"
1215+
},{
1216+
name: "图表",
1217+
name_en: "chart",
1218+
version: "9.1.1",
1219+
thumbnail: "widgets_chart.png",
1220+
fileName: "widgets_chart"
12151221
}]
12161222
},
12171223
"widgetsAdvanced": {
47.6 KB
Loading

examples/leaflet/widgets_chart.html

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
<!--********************************************************************
2+
* Copyright© 2000 - 2018 SuperMap Software Co.Ltd. All rights reserved.
3+
*********************************************************************-->
4+
<!DOCTYPE html>
5+
<html lang="en-US">
6+
7+
<head>
8+
<meta charset="UTF-8">
9+
<title data-i18n='resources.title_chart'></title>
10+
<script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script>
11+
<script type="text/javascript" include="iclient9-leaflet-css,echarts" src="../../dist/leaflet/include-leaflet.js"></script>
12+
13+
<style>
14+
.chart-setting {
15+
position: absolute;
16+
top: 10px;
17+
right: 10px;
18+
width: 450px;
19+
height: 50px;
20+
z-index: 800;
21+
background-color: #fff;
22+
}
23+
24+
.chart-type-btn {
25+
position: absolute;
26+
top: 8px;
27+
right: 20px;
28+
width: 112px;
29+
height: 36px;
30+
float: right;
31+
z-index: 800;
32+
}
33+
34+
.chart-setting .input-group {
35+
left: 16px;
36+
top: 8px;
37+
width: 260px;
38+
}
39+
40+
.graph {
41+
margin: 5px;
42+
width: 26px;
43+
height: 26px;
44+
border: none;
45+
border-radius: 4px;
46+
background-size: 100%;
47+
outline: none;
48+
}
49+
50+
button {
51+
float: right;
52+
}
53+
54+
#bar {
55+
background-image: url("../img/bar.png");
56+
}
57+
58+
#line {
59+
background-image: url("../img/ling.png");
60+
}
61+
62+
#scatter {
63+
background-image: url("../img/scatter.png");
64+
}
65+
66+
#chart {
67+
position: absolute;
68+
top: 60px;
69+
right: 10px;
70+
width: 450px;
71+
height: 350px;
72+
z-index: 800;
73+
}
74+
</style>
75+
</head>
76+
77+
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
78+
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
79+
<div class="chart-setting"></div>
80+
<div id="chart"></div>
81+
<script>
82+
init();
83+
function init() {
84+
let container = document.getElementsByClassName("chart-setting")[0];
85+
container.innerHTML = "<div class='input-group'><span class='input-group-addon'>"
86+
+ resources.text_dataset + "</span>"
87+
+ "<select class='form-control' id='rule' name='rule'>"
88+
+ "<option value='/iserver/services/data-jingjin/rest/data/datasources/Jingjin/datasets/Landuse_R' selected>Landuse_R@Jingjin</option>"
89+
+ "<option value='/iserver/services/data-jingjin/rest/data/datasources/Jingjin/datasets/BaseMap_P'>BaseMap_P@Jingjin</option>"
90+
+ "<option value='/iserver/services/map-world/rest/maps/World/layers/Rivers@World@@World'>Rivers@World</option>"
91+
+ "</select></div>"
92+
+ "<div class='chart-type-btn'>"
93+
+ "<button type='button' class='btn btn-default graph' id='scatter' title='" + resources.title_Scatter + "'></button>"
94+
+ "<button type='button' class='btn btn-default graph' id='line' title='" + resources.title_GraphLine + "'></button>"
95+
+ "<button type='button' class='btn btn-default graph active' id='bar' title='" + resources.title_GraphBar + "''></button></div>"
96+
}
97+
98+
var host = window.isLocal ? window.server : "http://support.supermap.com.cn:8090";
99+
var map, resultLayer, url = host + "/iserver/services/map-world/rest/maps/World";
100+
//加载底图
101+
map = L.map('map', {
102+
crs: L.CRS.EPSG4326,
103+
center: [40, 118],
104+
maxZoom: 18,
105+
zoom: 6
106+
});
107+
L.supermap.tiledMapLayer(url).addTo(map);
108+
//图表微件
109+
let options = {
110+
type: 'bar',
111+
datasets: {
112+
url: host + "/iserver/services/data-jingjin/rest/data/datasources/Jingjin/datasets/Landuse_R",
113+
queryInfo: {
114+
attributeFilter: "SmID > 0"
115+
}
116+
},
117+
chartOptions: [{
118+
xAxis: {
119+
field: "LANDTYPE",
120+
name: "type"
121+
},
122+
yAxis: {
123+
field: "AREA",
124+
name: "Area"
125+
}
126+
}]
127+
}
128+
let barChart = new SuperMap.Widgets.Chart("chart", options);
129+
//加载图表之后,将要素添加到地图上
130+
barChart.onAdd(addDataToMap);
131+
function addDataToMap() {
132+
let features = barChart.getFeatures();
133+
resultLayer = L.geoJSON(features).addTo(map);
134+
}
135+
136+
//为图表类型按钮绑定事件
137+
bindEvent();
138+
function bindEvent() {
139+
$(".graph").on("click", function () {
140+
$(".graph").removeClass("active");
141+
});
142+
143+
$("#bar").on("click", function () {
144+
$("#bar").addClass("active");
145+
barChart.changeType('bar');
146+
});
147+
$("#line").on("click", function () {
148+
$("#line").addClass("active");
149+
barChart.changeType('line');
150+
});
151+
$("#scatter").on("click", function () {
152+
$("#scatter").addClass("active");
153+
barChart.changeType('scatter');
154+
});
155+
}
156+
//切换数据集
157+
$("#rule").change(function () {
158+
var selectedIndex = ($(this).get(0).selectedIndex);
159+
var rule = $(this).val();
160+
var url = host + rule;
161+
var chartOption;
162+
map.removeLayer(resultLayer);
163+
if (selectedIndex === 0) {
164+
chartOption = [{
165+
xAxis: {
166+
field: "LANDTYPE",
167+
name: "type"
168+
},
169+
yAxis: {
170+
field: "AREA",
171+
name: "Area"
172+
}
173+
}]
174+
} else if (selectedIndex === 1) {
175+
chartOption = [{
176+
xAxis: {
177+
field: "ADCLASS",
178+
name: "class"
179+
}
180+
}];
181+
} else if (selectedIndex === 2) {
182+
chartOption = [{
183+
xAxis: {
184+
field: "NAME",
185+
name: "name"
186+
},
187+
yAxis: {
188+
field: "KILOMETERS",
189+
name: "Kilometers"
190+
}
191+
}];
192+
}
193+
barChart.updateData(url, null, chartOption);
194+
});
195+
</script>
196+
</body>
197+
</html>

examples/locales/en-US/resources.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ window.examplesResources = {
489489
"title_openFile_react": "OpenFile(React)",
490490
"title_openFile_vue": "OpenFile(Vue)",
491491
"title_dataFlow": "Data Flow",
492+
"title_chart": 'Chart',
492493
"title_spatialAnalysis": 'Client Computation',
493494
"title_distributeAnalysis": 'Distribute Analysis',
494495
"title_dataServiceQuery": 'Data service query',

examples/locales/zh-CN/resources.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ window.examplesResources = {
434434
"title_openFile_react": "打开文件(React)",
435435
"title_openFile_vue": "打开文件(Vue)",
436436
"title_dataFlow": "数据流服务",
437+
"title_chart": '图表',
437438
"title_spatialAnalysis": '客户端计算',
438439
"title_distributeAnalysis": '分布式分析',
439440
"title_dataServiceQuery": '数据服务查询',

src/common/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,8 @@ import {
432432
FileConfig,
433433
FileModel,
434434
MessageBox,
435+
ChartView,
436+
ChartViewModel,
435437
CommonContainer,
436438
DropDownBox,
437439
Select,
@@ -455,6 +457,8 @@ export {
455457
FileConfig,
456458
FileModel,
457459
MessageBox,
460+
ChartView,
461+
ChartViewModel,
458462
CommonContainer,
459463
DropDownBox,
460464
Select,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy