color-mix-aqi.html 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="./esl.js"></script>
  5. <script src="./config.js"></script>
  6. <link rel="stylesheet" href="./reset.css">
  7. </head>
  8. <body>
  9. <style>
  10. body {
  11. background: #000;
  12. }
  13. </style>
  14. <div id="main"></div>
  15. <script>
  16. // Schema:
  17. // date,AQIindex,PM2.5,PM10,CO,NO2,SO2
  18. var schema = [
  19. {name: 'date', index: 0, text: '日'},
  20. {name: 'AQIindex', index: 1, text: 'AQI指数'},
  21. {name: 'PM25', index: 2, text: 'PM2.5'},
  22. {name: 'PM10', index: 3, text: 'PM10'},
  23. {name: 'CO', index: 4, text: '一氧化碳(CO)'},
  24. {name: 'NO2', index: 5, text: '二氧化氮(NO2)'},
  25. {name: 'SO2', index: 6, text: '二氧化硫(SO2)'}
  26. ];
  27. require([
  28. 'data/aqi/BJdata',
  29. 'data/aqi/GZdata',
  30. 'data/aqi/SHdata',
  31. 'echarts',
  32. 'echarts/chart/scatter',
  33. 'echarts/component/legend',
  34. 'echarts/component/tooltip',
  35. 'echarts/component/grid',
  36. 'echarts/component/visualMapContinuous'
  37. ], function (dataBJ, dataGZ, dataSH, echarts) {
  38. var chart = echarts.init(document.getElementById('main'), null, {
  39. renderer: 'canvas'
  40. });
  41. var itemStyle = {
  42. normal: {
  43. opacity: 0.8,
  44. shadowBlur: 10,
  45. shadowOffsetX: 0,
  46. shadowOffsetY: 0,
  47. shadowColor: 'rgba(0, 0, 0, 0.5)'
  48. }
  49. };
  50. chart.setOption({
  51. legend: {
  52. top: 'top',
  53. data: ['北京', '上海', '广州'],
  54. textStyle: {
  55. color: '#fff',
  56. fontSize: 20
  57. }
  58. },
  59. grid: {
  60. left: '10%',
  61. right: 200,
  62. top: '15%',
  63. bottom: '10%'
  64. },
  65. tooltip: {
  66. padding: 10,
  67. backgroundColor: '#222',
  68. borderColor: '#777',
  69. borderWidth: 1,
  70. formatter: function (obj) {
  71. var value = obj.value;
  72. return '<div style="border-bottom: 1px solid rgba(255,255,255,.3); font-size: 18px;padding-bottom: 7px;margin-bottom: 7px">'
  73. + obj.seriesName + ' ' + value[0] + '日:'
  74. + value[7]
  75. + '</div>'
  76. + schema[1].text + ':' + value[1] + '<br>'
  77. + schema[2].text + ':' + value[2] + '<br>'
  78. + schema[3].text + ':' + value[3] + '<br>'
  79. + schema[4].text + ':' + value[4] + '<br>'
  80. + schema[5].text + ':' + value[5] + '<br>'
  81. + schema[6].text + ':' + value[6] + '<br>';
  82. }
  83. },
  84. xAxis: {
  85. type: 'value',
  86. name: '日期',
  87. nameGap: 16,
  88. nameTextStyle: {
  89. color: '#fff',
  90. fontSize: 14
  91. },
  92. max: 31,
  93. splitLine: {
  94. show: false
  95. },
  96. axisTick: {
  97. lineStyle: {
  98. color: '#777'
  99. }
  100. },
  101. axisLabel: {
  102. formatter: '{value}',
  103. textStyle: {
  104. color: '#fff'
  105. }
  106. }
  107. },
  108. yAxis: {
  109. type: 'value',
  110. name: 'AQI指数',
  111. nameLocation: 'end',
  112. nameGap: 20,
  113. nameTextStyle: {
  114. color: '#fff',
  115. fontSize: 20
  116. },
  117. axisTick: {
  118. lineStyle: {
  119. color: '#777'
  120. }
  121. },
  122. splitLine: {
  123. show: false
  124. },
  125. axisLabel: {
  126. textStyle: {
  127. color: '#fff'
  128. }
  129. }
  130. },
  131. visualMap: [
  132. {
  133. right: 0,
  134. top: 'top',
  135. dimension: 'z',
  136. min: 0,
  137. max: 250,
  138. itemWidth: 30,
  139. itemHeight: 130,
  140. calculable: true,
  141. precision: 0.1,
  142. text: ['圆形大小:PM2.5'],
  143. textGap: 30,
  144. textStyle: {
  145. color: '#fff'
  146. },
  147. inRange: {
  148. symbolSize: [10, 70]
  149. },
  150. outOfRange: {
  151. symbolSize: [10, 70],
  152. color: ['rgba(255,255,255,.2)']
  153. },
  154. controller: {
  155. outOfRange: {
  156. color: ['#444']
  157. }
  158. }
  159. },
  160. {
  161. left: 'right',
  162. top: 'bottom',
  163. dimension: 6,
  164. min: 0,
  165. max: 50,
  166. itemHeight: 130,
  167. calculable: true,
  168. precision: 0.1,
  169. text: ['明暗:二氧化硫'],
  170. textGap: 30,
  171. textStyle: {
  172. color: '#fff'
  173. },
  174. inRange: {
  175. colorLightness: [1, .5]
  176. },
  177. outOfRange: {
  178. color: ['rgba(255,255,255,.2)']
  179. },
  180. controller: {
  181. outOfRange: {
  182. color: ['#444']
  183. }
  184. }
  185. }
  186. ],
  187. series: [
  188. {
  189. name: '北京',
  190. type: 'scatter',
  191. itemStyle: itemStyle,
  192. data: dataBJ
  193. },
  194. {
  195. name: '上海',
  196. type: 'scatter',
  197. itemStyle: itemStyle,
  198. data: dataSH
  199. },
  200. {
  201. name: '广州',
  202. type: 'scatter',
  203. itemStyle: itemStyle,
  204. data: dataGZ
  205. }
  206. ]
  207. });
  208. });
  209. </script>
  210. </body>
  211. </html>