parallel-lineStyle.html 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="./lib/esl.js"></script>
  5. <script src="./lib/config.js"></script>
  6. <link rel="stylesheet" href="./lib/reset.css">
  7. </head>
  8. <body>
  9. <style>
  10. #main {
  11. width: 766px;
  12. height: 688px;
  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. {name: '等级', index: 7, text: '等级'}
  28. ];
  29. require([
  30. 'data/aqi/BJdata',
  31. 'data/aqi/GZdata',
  32. 'data/aqi/SHdata',
  33. // 'zrender/core/util',
  34. 'echarts'
  35. // 'echarts/chart/parallel',
  36. // 'echarts/component/legend',
  37. // 'echarts/component/tooltip',
  38. // 'echarts/component/visualMap',
  39. // 'echarts/component/parallel',
  40. ], function (dataBJ, dataGZ, dataSH, echarts) {
  41. var zrUtil = echarts.util;
  42. var chart = echarts.init(document.getElementById('main'));
  43. var lineStyle = {
  44. normal: {
  45. width: 1
  46. // opacity: 0.5,
  47. // shadowBlur: 10,
  48. // shadowOffsetX: 0,
  49. // shadowOffsetY: 0,
  50. // shadowColor: 'rgba(0, 0, 0, 0.5)'
  51. }
  52. };
  53. chart.setOption({
  54. animation: true,
  55. legend: {
  56. bottom: 30,
  57. data: ['北京', '上海', '广州'],
  58. itemGap: 20,
  59. textStyle: {
  60. // color: '#fff',
  61. fontSize: 16
  62. }
  63. },
  64. tooltip: {
  65. padding: 10,
  66. backgroundColor: '#222',
  67. borderColor: '#777',
  68. borderWidth: 1,
  69. formatter: function (obj) {
  70. var value = obj[0].value;
  71. return '<div style="border-bottom: 1px solid rgba(255,255,255,.3); font-size: 18px;padding-bottom: 7px;margin-bottom: 7px">'
  72. + obj[0].seriesName + ' ' + value[0] + '日期:'
  73. + value[7]
  74. + '</div>'
  75. + schema[1].text + ':' + value[1] + '<br>'
  76. + schema[2].text + ':' + value[2] + '<br>'
  77. + schema[3].text + ':' + value[3] + '<br>'
  78. + schema[4].text + ':' + value[4] + '<br>'
  79. + schema[5].text + ':' + value[5] + '<br>'
  80. + schema[6].text + ':' + value[6] + '<br>';
  81. }
  82. },
  83. // visualMap: {
  84. // show: true,
  85. // min: 0,
  86. // max: 150,
  87. // dimension: 2,
  88. // inRange: {
  89. // color: ['#d94e5d','#eac736','#50a3ba'].reverse()
  90. // },
  91. // outOfRange: {
  92. // color: ['#ccc'],
  93. // opacity: 0.001
  94. // }
  95. // },
  96. // dataZoom: {
  97. // show: true,
  98. // orient: 'vertical',
  99. // parallelAxisIndex: [0]
  100. // },
  101. parallelAxis: [
  102. {dim: 0, name: schema[0].text, inverse: true, max: 31, nameLocation: 'end'},
  103. {dim: 1, name: schema[1].text},
  104. {dim: 2, name: schema[2].text},
  105. {dim: 3, name: schema[3].text},
  106. {dim: 4, name: schema[4].text},
  107. {dim: 5, name: schema[5].text},
  108. {dim: 6, name: schema[6].text},
  109. {dim: 7, name: schema[7].text,
  110. type: 'category', data: ['优', '良', '轻度污染', '中度污染', '重度污染', '严重污染']}
  111. ],
  112. parallel: {
  113. bottom: 100,
  114. parallelAxisDefault: {
  115. type: 'value',
  116. name: 'AQI指数',
  117. nameLocation: 'end',
  118. nameGap: 20,
  119. tooltip: {
  120. show: true
  121. },
  122. nameTextStyle: {
  123. // color: '#fff',
  124. fontSize: 14
  125. },
  126. axisLine: {
  127. lineStyle: {
  128. // color: '#aaa'
  129. }
  130. },
  131. axisTick: {
  132. lineStyle: {
  133. // color: '#777'
  134. }
  135. },
  136. splitLine: {
  137. show: false
  138. },
  139. axisLabel: {
  140. textStyle: {
  141. // color: '#fff'
  142. }
  143. }
  144. }
  145. },
  146. series: [{
  147. type: 'parallel',
  148. data: [
  149. {
  150. 'value': ['韶关','63.37','38.41','72.15','57.33','84.56','82.66'],
  151. 'lineStyle': {
  152. 'normal': {
  153. 'color': 'green',
  154. width: 10,
  155. opacity: 1
  156. }
  157. }
  158. },
  159. {'value': ['湛江','31.42','99.18','44.09','3.62','5.65','63.37']}
  160. ]
  161. }]
  162. });
  163. chart.on('axisAreaSelected', function (event) {
  164. var indices = chart.getModel().getSeries()[0].getRawIndicesByActiveState('active');
  165. console.log('北京: ', indices);
  166. });
  167. });
  168. </script>
  169. </body>
  170. </html>