echartsLineMarker.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <!--********************************************************************
  2. * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
  3. *********************************************************************-->
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <meta charset="UTF-8">
  8. <title data-i18n="resources.title_GraphLine"></title>
  9. </head>
  10. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
  11. <div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
  12. <script type="text/javascript" src="../js/include-web.js"></script>
  13. <script type="text/javascript" include="echarts" src="../../dist/leaflet/include-leaflet.js"></script>
  14. <script type="text/javascript">
  15. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  16. var map, resultLayer, url = host + "/iserver/services/map-world/rest/maps/世界地图_Gray";
  17. var url2 = host + "/iserver/services/map-china400/rest/maps/China";
  18. map = L.map('map', {
  19. crs: L.CRS.EPSG4326,
  20. center: [31.6, 105.2],
  21. maxZoom: 18,
  22. zoomControl: false,
  23. zoom: 5
  24. });
  25. L.supermap.tiledMapLayer(url, {zoomControl: false}).addTo(map);
  26. var option = {
  27. title: {
  28. subtext: resources.text_fictitiou
  29. },
  30. tooltip: {
  31. trigger: 'axis'
  32. },
  33. legend: {
  34. //data:["最高气温"]
  35. data:[resources.text_maxTemperature,resources.text_minTemperature]
  36. },
  37. toolbox: {
  38. show: true,
  39. feature: {
  40. dataZoom: {
  41. yAxisIndex: 'none'
  42. },
  43. magicType: {type: ['line', 'bar']},
  44. restore: {},
  45. saveAsImage: {}
  46. }
  47. },
  48. xAxis: {
  49. type: 'category',
  50. boundaryGap: false,
  51. data: [resources.text_monday,resources.text_tuesday,resources.text_wednesday,resources.text_thursday,resources.text_friday,resources.text_saturday,resources.text_sunday]
  52. },
  53. yAxis: {
  54. type: 'value',
  55. axisLabel: {
  56. formatter: '{value} °C'
  57. }
  58. },
  59. series: [
  60. {
  61. name: resources.text_maxTemperature,
  62. type: 'line',
  63. data: [11, 11, 15, 13, 12, 13, 10],
  64. markPoint: {
  65. data: [
  66. {type: 'max', name:resources.text_max},
  67. {type: 'min', name:resources.text_min}
  68. ]
  69. },
  70. markLine: {
  71. data: [
  72. {type: 'average', name:resources.text_averageValue},
  73. [{
  74. symbol: 'none',
  75. x: '90%',
  76. yAxis: 'max'
  77. }, {
  78. symbol: 'circle',
  79. label: {
  80. normal: {
  81. position: 'start',
  82. formatter:resources.text_max
  83. }
  84. },
  85. type: 'max',
  86. name: resources.text_maxHighDot
  87. }]
  88. ]
  89. }
  90. },
  91. {
  92. name:resources.text_minTemperature,
  93. type: 'line',
  94. data: [1, -2, 2, 5, 3, 2, 0],
  95. markPoint: {
  96. data: [
  97. {type: 'max', name:resources.text_max},
  98. {type: 'min', name:resources.text_min}
  99. ]
  100. },
  101. markLine: {
  102. data: [
  103. {type: 'average', name:resources.text_averageValue},
  104. [{
  105. symbol: 'none',
  106. x: '90%',
  107. yAxis: 'min'
  108. }, {
  109. symbol: 'circle',
  110. label: {
  111. normal: {
  112. position: 'start',
  113. formatter: resources.text_min
  114. }
  115. },
  116. type: 'min',
  117. name: resources.text_minLowDot
  118. }]
  119. ]
  120. }
  121. }
  122. ]
  123. };
  124. var div = L.DomUtil.create('div');
  125. var chart = echarts.init(div, '', {
  126. width: 600,
  127. height: 400
  128. });
  129. chart.setOption(option);
  130. query();
  131. function query() {
  132. clearLayer();
  133. var param = new SuperMap.QueryBySQLParameters({
  134. queryParams: [{
  135. name: "China_ProCenCity_pt@China",
  136. attributeFilter: "1 = 1"
  137. }, {
  138. name: "China_Capital_pt@China",
  139. attributeFilter: "1 = 1"
  140. }]
  141. });
  142. L.supermap
  143. .queryService(url2)
  144. .queryBySQL(param, function (serviceResult) {
  145. serviceResult.result.recordsets.map(function (record) {
  146. resultLayer = L.geoJSON(record.features, {
  147. coordsToLatLng: function (coords) {
  148. var latlng = L.CRS.EPSG3857.unproject(L.point(coords[0], coords[1]));
  149. latlng.alt = coords[2];
  150. return latlng;
  151. }
  152. }).bindPopup(function (layer) {
  153. var city = layer.feature.properties.NAME;
  154. chart.setOption({
  155. title: {
  156. text: city+resources.text_nextWeekTemperature,
  157. },
  158. series: [
  159. {
  160. name: resources.text_maxTemperature,
  161. data: [10 + Math.ceil(Math.random() * 10), 10 + Math.ceil(Math.random() * 10), 10 + Math.ceil(Math.random() * 10), 10 + Math.ceil(Math.random() * 10), 10 + Math.ceil(Math.random() * 10), 10 + Math.ceil(Math.random() * 10), 10 + Math.ceil(Math.random() * 10)],
  162. },
  163. {
  164. name:resources.text_minTemperature,
  165. data: [8 - Math.ceil(Math.random() * 10), 8 - Math.ceil(Math.random() * 10), 8 - Math.ceil(Math.random() * 10), 8 - Math.ceil(Math.random() * 10), 8 - Math.ceil(Math.random() * 10), 8 - Math.ceil(Math.random() * 10), 8 - Math.ceil(Math.random() * 10)],
  166. }
  167. ]
  168. });
  169. return chart.getDom();
  170. }, {maxWidth: 700}).addTo(map);
  171. })
  172. });
  173. }
  174. function clearLayer() {
  175. if (resultLayer) {
  176. resultLayer.removeFrom(map);
  177. }
  178. }
  179. </script>
  180. </body>
  181. </html>