visualMap-categories.html 7.5 KB

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