visualMap-categories.html 7.5 KB

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