parallel-aqi.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  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/testHelper.js"></script>
  7. <meta name="viewport" content="width=device-width, initial-scale=1" />
  8. <link rel="stylesheet" href="lib/reset.css" />
  9. </head>
  10. <body>
  11. <style>
  12. h1 {
  13. line-height: 60px;
  14. height: 60px;
  15. background: #e0ebff;
  16. text-align: center;
  17. font-weight: bold;
  18. font-size: 14px;
  19. }
  20. .chart {
  21. height: 500px;
  22. }
  23. </style>
  24. <h1>normal</h1>
  25. <div class="chart" id="main0"></div>
  26. <h1>data column 0 and column 2 is not used.</h1>
  27. <div class="chart" id="main1"></div>
  28. <h1>category is not specified but auto-collected.</h1>
  29. <div class="chart" id="main2"></div>
  30. <script>
  31. // Schema:
  32. // date,AQIindex,PM2.5,PM10,CO,NO2,SO2
  33. var schema = [
  34. {name: 'date', index: 0, text: '日期'},
  35. {name: 'AQIindex', index: 1, text: 'AQI指数'},
  36. {name: 'PM25', index: 2, text: 'PM2.5'},
  37. {name: 'PM10', index: 3, text: 'PM10'},
  38. {name: 'CO', index: 4, text: '一氧化碳 (CO)'},
  39. {name: 'NO2', index: 5, text: '二氧化氮 (NO2)'},
  40. {name: 'SO2', index: 6, text: '二氧化硫 (SO2)'},
  41. {name: '等级', index: 7, text: '等级'}
  42. ];
  43. </script>
  44. <script>
  45. require([
  46. 'data/aqi/BJdata',
  47. 'data/aqi/GZdata',
  48. 'data/aqi/SHdata',
  49. 'echarts'
  50. ], function (dataBJ, dataGZ, dataSH, echarts) {
  51. var zrUtil = echarts.util;
  52. var lineStyle = {
  53. normal: {
  54. width: 1
  55. }
  56. };
  57. var option = {
  58. aria: {
  59. show: true
  60. },
  61. animation: true,
  62. legend: {
  63. bottom: 30,
  64. data: ['北京', '上海', '广州'],
  65. itemGap: 20,
  66. textStyle: {
  67. // color: '#fff',
  68. fontSize: 16
  69. }
  70. },
  71. tooltip: {
  72. padding: 10,
  73. backgroundColor: '#222',
  74. borderColor: '#777',
  75. borderWidth: 1,
  76. formatter: function (obj) {
  77. var value = obj[0].value;
  78. return '<div style="border-bottom: 1px solid rgba(255,255,255,.3); font-size: 18px;padding-bottom: 7px;margin-bottom: 7px">'
  79. + obj[0].seriesName + ' ' + value[0] + '日期:'
  80. + value[7]
  81. + '</div>'
  82. + schema[1].text + ':' + value[1] + '<br>'
  83. + schema[2].text + ':' + value[2] + '<br>'
  84. + schema[3].text + ':' + value[3] + '<br>'
  85. + schema[4].text + ':' + value[4] + '<br>'
  86. + schema[5].text + ':' + value[5] + '<br>'
  87. + schema[6].text + ':' + value[6] + '<br>';
  88. }
  89. },
  90. visualMap: {
  91. show: true,
  92. min: 0,
  93. max: 150,
  94. top: 'center',
  95. dimension: 2,
  96. inRange: {
  97. color: ['#d94e5d','#eac736','#50a3ba'].reverse()
  98. },
  99. outOfRange: {
  100. color: ['#ccc'],
  101. opacity: 0.001
  102. }
  103. },
  104. parallelAxis: [
  105. {dim: 0, name: schema[0].text, max: 31, inverse: true, nameLocation: 'end'},
  106. {dim: 1, name: schema[1].text},
  107. {dim: 2, name: schema[2].text},
  108. {dim: 3, name: schema[3].text},
  109. {dim: 4, name: schema[4].text},
  110. {dim: 5, name: schema[5].text},
  111. {dim: 6, name: schema[6].text},
  112. {dim: 7, name: schema[7].text,
  113. type: 'category',
  114. data: ['优', '良', '轻度污染', '中度污染', '重度污染', '严重污染']
  115. }
  116. ],
  117. parallel: {
  118. bottom: 100,
  119. parallelAxisDefault: {
  120. type: 'value',
  121. name: 'AQI指数',
  122. nameLocation: 'end',
  123. nameGap: 20,
  124. tooltip: {
  125. show: true
  126. },
  127. nameTextStyle: {
  128. fontSize: 14
  129. },
  130. splitLine: {
  131. show: false
  132. }
  133. }
  134. },
  135. series: [
  136. {
  137. name: '北京',
  138. type: 'parallel',
  139. lineStyle: lineStyle,
  140. data: dataBJ
  141. },
  142. {
  143. name: '上海',
  144. type: 'parallel',
  145. lineStyle: lineStyle,
  146. data: dataSH
  147. },
  148. {
  149. name: '广州',
  150. type: 'parallel',
  151. lineStyle: lineStyle,
  152. data: dataGZ
  153. }
  154. ]
  155. };
  156. var chart = testHelper.createChart(echarts, 'main0', option);
  157. chart && chart.on('axisAreaSelected', function (event) {
  158. var indices = chart.getModel().getSeries()[0].getRawIndicesByActiveState('active');
  159. console.log('北京: ', indices);
  160. });
  161. });
  162. </script>
  163. <script>
  164. require([
  165. 'data/aqi/BJdata',
  166. 'data/aqi/GZdata',
  167. 'data/aqi/SHdata',
  168. 'echarts'
  169. ], function (dataBJ, dataGZ, dataSH, echarts) {
  170. var zrUtil = echarts.util;
  171. var lineStyle = {
  172. normal: {
  173. width: 1
  174. }
  175. };
  176. var option = {
  177. animation: true,
  178. legend: {
  179. bottom: 30,
  180. data: ['北京', '上海', '广州'],
  181. itemGap: 20,
  182. textStyle: {
  183. // color: '#fff',
  184. fontSize: 16
  185. }
  186. },
  187. tooltip: {
  188. padding: 10,
  189. backgroundColor: '#222',
  190. borderColor: '#777',
  191. borderWidth: 1,
  192. formatter: function (obj) {
  193. var value = obj[0].value;
  194. return '<div style="border-bottom: 1px solid rgba(255,255,255,.3); font-size: 18px;padding-bottom: 7px;margin-bottom: 7px">'
  195. + obj[0].seriesName + ' ' + value[0] + '日期:'
  196. + value[7]
  197. + '</div>'
  198. + schema[1].text + ':' + value[1] + '<br>'
  199. + schema[2].text + ':' + value[2] + '<br>'
  200. + schema[3].text + ':' + value[3] + '<br>'
  201. + schema[4].text + ':' + value[4] + '<br>'
  202. + schema[5].text + ':' + value[5] + '<br>'
  203. + schema[6].text + ':' + value[6] + '<br>';
  204. }
  205. },
  206. visualMap: {
  207. show: true,
  208. min: 0,
  209. max: 150,
  210. top: 'center',
  211. dimension: 2,
  212. inRange: {
  213. color: ['#d94e5d','#eac736','#50a3ba'].reverse()
  214. },
  215. outOfRange: {
  216. color: ['#ccc'],
  217. opacity: 0.001
  218. }
  219. },
  220. parallelAxis: [
  221. // {dim: 0, name: schema[0].text, max: 31, inverse: true, nameLocation: 'end'},
  222. {dim: 1, name: schema[1].text},
  223. // {dim: 2, name: schema[2].text},
  224. {dim: 3, name: schema[3].text},
  225. {dim: 4, name: schema[4].text},
  226. {dim: 5, name: schema[5].text},
  227. {dim: 6, name: schema[6].text},
  228. {dim: 7, name: schema[7].text,
  229. type: 'category',
  230. data: ['优', '良', '轻度污染', '中度污染', '重度污染', '严重污染']
  231. }
  232. ],
  233. parallel: {
  234. bottom: 100,
  235. parallelAxisDefault: {
  236. type: 'value',
  237. name: 'AQI指数',
  238. nameLocation: 'end',
  239. nameGap: 20,
  240. tooltip: {
  241. show: true
  242. },
  243. nameTextStyle: {
  244. fontSize: 14
  245. },
  246. splitLine: {
  247. show: false
  248. }
  249. }
  250. },
  251. series: [
  252. {
  253. name: '北京',
  254. type: 'parallel',
  255. lineStyle: lineStyle,
  256. data: dataBJ
  257. },
  258. {
  259. name: '上海',
  260. type: 'parallel',
  261. lineStyle: lineStyle,
  262. data: dataSH
  263. },
  264. {
  265. name: '广州',
  266. type: 'parallel',
  267. lineStyle: lineStyle,
  268. data: dataGZ
  269. }
  270. ]
  271. };
  272. var chart = testHelper.createChart(echarts, 'main1', option);
  273. chart && chart.on('axisAreaSelected', function (event) {
  274. var indices = chart.getModel().getSeries()[0].getRawIndicesByActiveState('active');
  275. console.log('北京: ', indices);
  276. });
  277. });
  278. </script>
  279. <script>
  280. require([
  281. 'data/aqi/BJdata',
  282. 'data/aqi/GZdata',
  283. 'data/aqi/SHdata',
  284. 'echarts'
  285. ], function (dataBJ, dataGZ, dataSH, echarts) {
  286. var zrUtil = echarts.util;
  287. var lineStyle = {
  288. normal: {
  289. width: 1
  290. }
  291. };
  292. var option = {
  293. animation: true,
  294. legend: {
  295. bottom: 30,
  296. data: ['北京', '上海', '广州'],
  297. itemGap: 20,
  298. textStyle: {
  299. // color: '#fff',
  300. fontSize: 16
  301. }
  302. },
  303. tooltip: {
  304. padding: 10,
  305. backgroundColor: '#222',
  306. borderColor: '#777',
  307. borderWidth: 1,
  308. formatter: function (obj) {
  309. var value = obj[0].value;
  310. return '<div style="border-bottom: 1px solid rgba(255,255,255,.3); font-size: 18px;padding-bottom: 7px;margin-bottom: 7px">'
  311. + obj[0].seriesName + ' ' + value[0] + '日期:'
  312. + value[7]
  313. + '</div>'
  314. + schema[1].text + ':' + value[1] + '<br>'
  315. + schema[2].text + ':' + value[2] + '<br>'
  316. + schema[3].text + ':' + value[3] + '<br>'
  317. + schema[4].text + ':' + value[4] + '<br>'
  318. + schema[5].text + ':' + value[5] + '<br>'
  319. + schema[6].text + ':' + value[6] + '<br>';
  320. }
  321. },
  322. visualMap: {
  323. show: true,
  324. min: 0,
  325. max: 150,
  326. top: 'center',
  327. dimension: 2,
  328. inRange: {
  329. color: ['#d94e5d','#eac736','#50a3ba'].reverse()
  330. },
  331. outOfRange: {
  332. color: ['#ccc'],
  333. opacity: 0.001
  334. }
  335. },
  336. parallelAxis: [
  337. // {dim: 0, name: schema[0].text, max: 31, inverse: true, nameLocation: 'end'},
  338. {dim: 1, name: schema[1].text},
  339. // {dim: 2, name: schema[2].text},
  340. {dim: 3, name: schema[3].text},
  341. {dim: 4, name: schema[4].text},
  342. {dim: 5, name: schema[5].text},
  343. {dim: 6, name: schema[6].text},
  344. {dim: 7, name: schema[7].text,
  345. type: 'category'
  346. // data: ['优', '良', '轻度污染', '中度污染', '重度污染', '严重污染']
  347. }
  348. ],
  349. parallel: {
  350. bottom: 100,
  351. parallelAxisDefault: {
  352. type: 'value',
  353. name: 'AQI指数',
  354. nameLocation: 'end',
  355. nameGap: 20,
  356. tooltip: {
  357. show: true
  358. },
  359. nameTextStyle: {
  360. fontSize: 14
  361. },
  362. splitLine: {
  363. show: false
  364. }
  365. }
  366. },
  367. series: [
  368. {
  369. name: '北京',
  370. type: 'parallel',
  371. lineStyle: lineStyle,
  372. data: dataBJ
  373. },
  374. {
  375. name: '上海',
  376. type: 'parallel',
  377. lineStyle: lineStyle,
  378. data: dataSH
  379. },
  380. {
  381. name: '广州',
  382. type: 'parallel',
  383. lineStyle: lineStyle,
  384. data: dataGZ
  385. }
  386. ]
  387. };
  388. var chart = testHelper.createChart(echarts, 'main2', option);
  389. chart && chart.on('axisAreaSelected', function (event) {
  390. var indices = chart.getModel().getSeries()[0].getRawIndicesByActiveState('active');
  391. console.log('北京: ', indices);
  392. });
  393. });
  394. </script>
  395. </body>
  396. </html>