123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <!--********************************************************************
- * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
- *********************************************************************-->
- <!DOCTYPE html>
- <html lang="en-US">
- <head>
- <meta charset="UTF-8">
- <title data-i18n='resources.title_chart_iPortal'></title>
- <script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script>
- <script type="text/javascript" include="iclient-leaflet-css,echarts" src="../../dist/leaflet/include-leaflet.js"></script>
- <style>
- .chart-setting {
- position: absolute;
- top: 50px;
- right: 10px;
- width: 450px;
- height: 50px;
- z-index: 800;
- background-color: #fff;
- }
- .chart-type-btn {
- position: absolute;
- top: 8px;
- right: 20px;
- width: 112px;
- height: 36px;
- float: right;
- z-index: 800;
- }
- .chart-setting .input-group {
- left: 16px;
- top: 8px;
- width: 260px;
- }
- .graph {
- margin: 5px;
- width: 26px;
- height: 26px;
- border: none;
- border-radius: 4px;
- background-size: 100%;
- outline: none;
- }
- button {
- float: right;
- }
- #bar {
- background-image: url("../img/bar.png");
- }
- #line {
- background-image: url("../img/ling.png");
- }
- #scatter {
- background-image: url("../img/scatter.png");
- }
- #chart {
- position: absolute;
- top: 100px;
- right: 10px;
- width: 450px;
- height: 350px;
- z-index: 800;
- }
- </style>
- </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>
- <div class="chart-setting"></div>
- <div id="chart"></div>
- <script>
- init();
- function init() {
- var container = document.getElementsByClassName("chart-setting")[0];
- container.innerHTML =
- "<div class='chart-type-btn'>" +
- "<button type='button' class='btn btn-default graph' id='scatter' title='" + resources.title_Scatter +
- "'></button>" +
- "<button type='button' class='btn btn-default graph' id='line' title='" + resources.title_GraphLine +
- "'></button>" +
- "<button type='button' class='btn btn-default graph active' id='bar' title='" + resources.title_GraphBar +
- "''></button></div>"
- }
- var host = window.isLocal ? window.server : "https://iserver.supermap.io";
- var map, resultLayer, url = host + "/iserver/services/map-world/rest/maps/World";
- //加载底图
- map = L.map('map', {
- crs: L.CRS.EPSG4326,
- center: [40, 118],
- maxZoom: 18,
- zoom: 6
- });
- L.supermap.tiledMapLayer(url).addTo(map);
- //图表组件
- var options = {
- type: 'bar',
- datasets: {
- type: 'iPortal',
- url: 'https://iportal.supermap.io/iportal/web/datas/676516522',
- queryInfo: {
- attributeFilter: "SmID > 0"
- }
- },
- chartOptions: [{
- xAxis: {
- field: "机场",
- name: "Airport"
- },
- yAxis: {
- field: "同比增速%",
- name: "GrowthRate%"
- }
- }]
- }
- var barChart = new SuperMap.Components.Chart("chart", options);
- //加载图表之后,将要素添加到地图上
- barChart.onAdd(addDataToMap);
- function addDataToMap() {
- var features = barChart.getFeatures();
- resultLayer = L.geoJSON(features).addTo(map);
- }
- //为图表类型按钮绑定事件
- bindEvent();
- function bindEvent() {
- $(".graph").on("click", function () {
- $(".graph").removeClass("active");
- });
- $("#bar").on("click", function () {
- $("#bar").addClass("active");
- barChart.changeType('bar');
- });
- $("#line").on("click", function () {
- $("#line").addClass("active");
- barChart.changeType('line');
- });
- $("#scatter").on("click", function () {
- $("#scatter").addClass("active");
- barChart.changeType('scatter');
- });
- }
- </script>
- </body>
- </html>
|