effectScatter.html 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  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/jquery.min.js'></script>
  7. <meta name="viewport" content="width=device-width, initial-scale=1" />
  8. </head>
  9. <body>
  10. <style>
  11. html, body, #main {
  12. width: 100%;
  13. height: 100%;
  14. margin: 0;
  15. }
  16. </style>
  17. <div id='main'></div>
  18. <script>
  19. require([
  20. 'echarts',
  21. 'echarts/chart/scatter',
  22. 'echarts/chart/effectScatter',
  23. 'echarts/component/legend',
  24. 'echarts/component/geo'
  25. ], function (echarts) {
  26. var data = [
  27. {name: '海门', value: 9},
  28. {name: '鄂尔多斯', value: 12},
  29. {name: '招远', value: 12},
  30. {name: '舟山', value: 12},
  31. {name: '齐齐哈尔', value: 14},
  32. {name: '盐城', value: 15},
  33. {name: '赤峰', value: 16},
  34. {name: '青岛', value: 18},
  35. {name: '乳山', value: 18},
  36. {name: '金昌', value: 19},
  37. {name: '泉州', value: 21},
  38. {name: '莱西', value: 21},
  39. {name: '日照', value: 21},
  40. {name: '胶南', value: 22},
  41. {name: '南通', value: 23},
  42. {name: '拉萨', value: 24},
  43. {name: '云浮', value: 24},
  44. {name: '梅州', value: 25},
  45. {name: '文登', value: 25},
  46. {name: '上海', value: 25},
  47. {name: '攀枝花', value: 25},
  48. {name: '威海', value: 25},
  49. {name: '承德', value: 25},
  50. {name: '厦门', value: 26},
  51. {name: '汕尾', value: 26},
  52. {name: '潮州', value: 26},
  53. {name: '丹东', value: 27},
  54. {name: '太仓', value: 27},
  55. {name: '曲靖', value: 27},
  56. {name: '烟台', value: 28},
  57. {name: '福州', value: 29},
  58. {name: '瓦房店', value: 30},
  59. {name: '即墨', value: 30},
  60. {name: '抚顺', value: 31},
  61. {name: '玉溪', value: 31},
  62. {name: '张家口', value: 31},
  63. {name: '阳泉', value: 31},
  64. {name: '莱州', value: 32},
  65. {name: '湖州', value: 32},
  66. {name: '汕头', value: 32},
  67. {name: '昆山', value: 33},
  68. {name: '宁波', value: 33},
  69. {name: '湛江', value: 33},
  70. {name: '揭阳', value: 34},
  71. {name: '荣成', value: 34},
  72. {name: '连云港', value: 35},
  73. {name: '葫芦岛', value: 35},
  74. {name: '常熟', value: 36},
  75. {name: '东莞', value: 36},
  76. {name: '河源', value: 36},
  77. {name: '淮安', value: 36},
  78. {name: '泰州', value: 36},
  79. {name: '南宁', value: 37},
  80. {name: '营口', value: 37},
  81. {name: '惠州', value: 37},
  82. {name: '江阴', value: 37},
  83. {name: '蓬莱', value: 37},
  84. {name: '韶关', value: 38},
  85. {name: '嘉峪关', value: 38},
  86. {name: '广州', value: 38},
  87. {name: '延安', value: 38},
  88. {name: '太原', value: 39},
  89. {name: '清远', value: 39},
  90. {name: '中山', value: 39},
  91. {name: '昆明', value: 39},
  92. {name: '寿光', value: 40},
  93. {name: '盘锦', value: 40},
  94. {name: '长治', value: 41},
  95. {name: '深圳', value: 41},
  96. {name: '珠海', value: 42},
  97. {name: '宿迁', value: 43},
  98. {name: '咸阳', value: 43},
  99. {name: '铜川', value: 44},
  100. {name: '平度', value: 44},
  101. {name: '佛山', value: 44},
  102. {name: '海口', value: 44},
  103. {name: '江门', value: 45},
  104. {name: '章丘', value: 45},
  105. {name: '肇庆', value: 46},
  106. {name: '大连', value: 47},
  107. {name: '临汾', value: 47},
  108. {name: '吴江', value: 47},
  109. {name: '石嘴山', value: 49},
  110. {name: '沈阳', value: 50},
  111. {name: '苏州', value: 50},
  112. {name: '茂名', value: 50},
  113. {name: '嘉兴', value: 51},
  114. {name: '长春', value: 51},
  115. {name: '胶州', value: 52},
  116. {name: '银川', value: 52},
  117. {name: '张家港', value: 52},
  118. {name: '三门峡', value: 53},
  119. {name: '锦州', value: 54},
  120. {name: '南昌', value: 54},
  121. {name: '柳州', value: 54},
  122. {name: '三亚', value: 54},
  123. {name: '自贡', value: 56},
  124. {name: '吉林', value: 56},
  125. {name: '阳江', value: 57},
  126. {name: '泸州', value: 57},
  127. {name: '西宁', value: 57},
  128. {name: '宜宾', value: 58},
  129. {name: '呼和浩特', value: 58},
  130. {name: '成都', value: 58},
  131. {name: '大同', value: 58},
  132. {name: '镇江', value: 59},
  133. {name: '桂林', value: 59},
  134. {name: '张家界', value: 59},
  135. {name: '宜兴', value: 59},
  136. {name: '北海', value: 60},
  137. {name: '西安', value: 61},
  138. {name: '金坛', value: 62},
  139. {name: '东营', value: 62},
  140. {name: '牡丹江', value: 63},
  141. {name: '遵义', value: 63},
  142. {name: '绍兴', value: 63},
  143. {name: '扬州', value: 64},
  144. {name: '常州', value: 64},
  145. {name: '潍坊', value: 65},
  146. {name: '重庆', value: 66},
  147. {name: '台州', value: 67},
  148. {name: '南京', value: 67},
  149. {name: '滨州', value: 70},
  150. {name: '贵阳', value: 71},
  151. {name: '无锡', value: 71},
  152. {name: '本溪', value: 71},
  153. {name: '克拉玛依', value: 72},
  154. {name: '渭南', value: 72},
  155. {name: '马鞍山', value: 72},
  156. {name: '宝鸡', value: 72},
  157. {name: '焦作', value: 75},
  158. {name: '句容', value: 75},
  159. {name: '北京', value: 79},
  160. {name: '徐州', value: 79},
  161. {name: '衡水', value: 80},
  162. {name: '包头', value: 80},
  163. {name: '绵阳', value: 80},
  164. {name: '乌鲁木齐', value: 84},
  165. {name: '枣庄', value: 84},
  166. {name: '杭州', value: 84},
  167. {name: '淄博', value: 85},
  168. {name: '鞍山', value: 86},
  169. {name: '溧阳', value: 86},
  170. {name: '库尔勒', value: 86},
  171. {name: '安阳', value: 90},
  172. {name: '开封', value: 90},
  173. {name: '济南', value: 92},
  174. {name: '德阳', value: 93},
  175. {name: '温州', value: 95},
  176. {name: '九江', value: 96},
  177. {name: '邯郸', value: 98},
  178. {name: '临安', value: 99},
  179. {name: '兰州', value: 99},
  180. {name: '沧州', value: 100},
  181. {name: '临沂', value: 103},
  182. {name: '南充', value: 104},
  183. {name: '天津', value: 105},
  184. {name: '富阳', value: 106},
  185. {name: '泰安', value: 112},
  186. {name: '诸暨', value: 112},
  187. {name: '郑州', value: 113},
  188. {name: '哈尔滨', value: 114},
  189. {name: '聊城', value: 116},
  190. {name: '芜湖', value: 117},
  191. {name: '唐山', value: 119},
  192. {name: '平顶山', value: 119},
  193. {name: '邢台', value: 119},
  194. {name: '德州', value: 120},
  195. {name: '济宁', value: 120},
  196. {name: '荆州', value: 127},
  197. {name: '宜昌', value: 130},
  198. {name: '义乌', value: 132},
  199. {name: '丽水', value: 133},
  200. {name: '洛阳', value: 134},
  201. {name: '秦皇岛', value: 136},
  202. {name: '株洲', value: 143},
  203. {name: '石家庄', value: 147},
  204. {name: '莱芜', value: 148},
  205. {name: '常德', value: 152},
  206. {name: '保定', value: 153},
  207. {name: '湘潭', value: 154},
  208. {name: '金华', value: 157},
  209. {name: '岳阳', value: 169},
  210. {name: '长沙', value: 175},
  211. {name: '衢州', value: 177},
  212. {name: '廊坊', value: 193},
  213. {name: '菏泽', value: 194},
  214. {name: '合肥', value: 229},
  215. {name: '武汉', value: 273},
  216. {name: '大庆', value: 279}
  217. ];
  218. $.get('../map/json/china.json', function (chinaJson) {
  219. echarts.registerMap('china', chinaJson);
  220. var geoCoordMap = {
  221. '海门':[121.15,31.89],
  222. '鄂尔多斯':[109.781327,39.608266],
  223. '招远':[120.38,37.35],
  224. '舟山':[122.207216,29.985295],
  225. '齐齐哈尔':[123.97,47.33],
  226. '盐城':[120.13,33.38],
  227. '赤峰':[118.87,42.28],
  228. '青岛':[120.33,36.07],
  229. '乳山':[121.52,36.89],
  230. '金昌':[102.188043,38.520089],
  231. '泉州':[118.58,24.93],
  232. '莱西':[120.53,36.86],
  233. '日照':[119.46,35.42],
  234. '胶南':[119.97,35.88],
  235. '南通':[121.05,32.08],
  236. '拉萨':[91.11,29.97],
  237. '云浮':[112.02,22.93],
  238. '梅州':[116.1,24.55],
  239. '文登':[122.05,37.2],
  240. '上海':[121.48,31.22],
  241. '攀枝花':[101.718637,26.582347],
  242. '威海':[122.1,37.5],
  243. '承德':[117.93,40.97],
  244. '厦门':[118.1,24.46],
  245. '汕尾':[115.375279,22.786211],
  246. '潮州':[116.63,23.68],
  247. '丹东':[124.37,40.13],
  248. '太仓':[121.1,31.45],
  249. '曲靖':[103.79,25.51],
  250. '烟台':[121.39,37.52],
  251. '福州':[119.3,26.08],
  252. '瓦房店':[121.979603,39.627114],
  253. '即墨':[120.45,36.38],
  254. '抚顺':[123.97,41.97],
  255. '玉溪':[102.52,24.35],
  256. '张家口':[114.87,40.82],
  257. '阳泉':[113.57,37.85],
  258. '莱州':[119.942327,37.177017],
  259. '湖州':[120.1,30.86],
  260. '汕头':[116.69,23.39],
  261. '昆山':[120.95,31.39],
  262. '宁波':[121.56,29.86],
  263. '湛江':[110.359377,21.270708],
  264. '揭阳':[116.35,23.55],
  265. '荣成':[122.41,37.16],
  266. '连云港':[119.16,34.59],
  267. '葫芦岛':[120.836932,40.711052],
  268. '常熟':[120.74,31.64],
  269. '东莞':[113.75,23.04],
  270. '河源':[114.68,23.73],
  271. '淮安':[119.15,33.5],
  272. '泰州':[119.9,32.49],
  273. '南宁':[108.33,22.84],
  274. '营口':[122.18,40.65],
  275. '惠州':[114.4,23.09],
  276. '江阴':[120.26,31.91],
  277. '蓬莱':[120.75,37.8],
  278. '韶关':[113.62,24.84],
  279. '嘉峪关':[98.289152,39.77313],
  280. '广州':[113.23,23.16],
  281. '延安':[109.47,36.6],
  282. '太原':[112.53,37.87],
  283. '清远':[113.01,23.7],
  284. '中山':[113.38,22.52],
  285. '昆明':[102.73,25.04],
  286. '寿光':[118.73,36.86],
  287. '盘锦':[122.070714,41.119997],
  288. '长治':[113.08,36.18],
  289. '深圳':[114.07,22.62],
  290. '珠海':[113.52,22.3],
  291. '宿迁':[118.3,33.96],
  292. '咸阳':[108.72,34.36],
  293. '铜川':[109.11,35.09],
  294. '平度':[119.97,36.77],
  295. '佛山':[113.11,23.05],
  296. '海口':[110.35,20.02],
  297. '江门':[113.06,22.61],
  298. '章丘':[117.53,36.72],
  299. '肇庆':[112.44,23.05],
  300. '大连':[121.62,38.92],
  301. '临汾':[111.5,36.08],
  302. '吴江':[120.63,31.16],
  303. '石嘴山':[106.39,39.04],
  304. '沈阳':[123.38,41.8],
  305. '苏州':[120.62,31.32],
  306. '茂名':[110.88,21.68],
  307. '嘉兴':[120.76,30.77],
  308. '长春':[125.35,43.88],
  309. '胶州':[120.03336,36.264622],
  310. '银川':[106.27,38.47],
  311. '张家港':[120.555821,31.875428],
  312. '三门峡':[111.19,34.76],
  313. '锦州':[121.15,41.13],
  314. '南昌':[115.89,28.68],
  315. '柳州':[109.4,24.33],
  316. '三亚':[109.511909,18.252847],
  317. '自贡':[104.778442,29.33903],
  318. '吉林':[126.57,43.87],
  319. '阳江':[111.95,21.85],
  320. '泸州':[105.39,28.91],
  321. '西宁':[101.74,36.56],
  322. '宜宾':[104.56,29.77],
  323. '呼和浩特':[111.65,40.82],
  324. '成都':[104.06,30.67],
  325. '大同':[113.3,40.12],
  326. '镇江':[119.44,32.2],
  327. '桂林':[110.28,25.29],
  328. '张家界':[110.479191,29.117096],
  329. '宜兴':[119.82,31.36],
  330. '北海':[109.12,21.49],
  331. '西安':[108.95,34.27],
  332. '金坛':[119.56,31.74],
  333. '东营':[118.49,37.46],
  334. '牡丹江':[129.58,44.6],
  335. '遵义':[106.9,27.7],
  336. '绍兴':[120.58,30.01],
  337. '扬州':[119.42,32.39],
  338. '常州':[119.95,31.79],
  339. '潍坊':[119.1,36.62],
  340. '重庆':[106.54,29.59],
  341. '台州':[121.420757,28.656386],
  342. '南京':[118.78,32.04],
  343. '滨州':[118.03,37.36],
  344. '贵阳':[106.71,26.57],
  345. '无锡':[120.29,31.59],
  346. '本溪':[123.73,41.3],
  347. '克拉玛依':[84.77,45.59],
  348. '渭南':[109.5,34.52],
  349. '马鞍山':[118.48,31.56],
  350. '宝鸡':[107.15,34.38],
  351. '焦作':[113.21,35.24],
  352. '句容':[119.16,31.95],
  353. '北京':[116.46,39.92],
  354. '徐州':[117.2,34.26],
  355. '衡水':[115.72,37.72],
  356. '包头':[110,40.58],
  357. '绵阳':[104.73,31.48],
  358. '乌鲁木齐':[87.68,43.77],
  359. '枣庄':[117.57,34.86],
  360. '杭州':[120.19,30.26],
  361. '淄博':[118.05,36.78],
  362. '鞍山':[122.85,41.12],
  363. '溧阳':[119.48,31.43],
  364. '库尔勒':[86.06,41.68],
  365. '安阳':[114.35,36.1],
  366. '开封':[114.35,34.79],
  367. '济南':[117,36.65],
  368. '德阳':[104.37,31.13],
  369. '温州':[120.65,28.01],
  370. '九江':[115.97,29.71],
  371. '邯郸':[114.47,36.6],
  372. '临安':[119.72,30.23],
  373. '兰州':[103.73,36.03],
  374. '沧州':[116.83,38.33],
  375. '临沂':[118.35,35.05],
  376. '南充':[106.110698,30.837793],
  377. '天津':[117.2,39.13],
  378. '富阳':[119.95,30.07],
  379. '泰安':[117.13,36.18],
  380. '诸暨':[120.23,29.71],
  381. '郑州':[113.65,34.76],
  382. '哈尔滨':[126.63,45.75],
  383. '聊城':[115.97,36.45],
  384. '芜湖':[118.38,31.33],
  385. '唐山':[118.02,39.63],
  386. '平顶山':[113.29,33.75],
  387. '邢台':[114.48,37.05],
  388. '德州':[116.29,37.45],
  389. '济宁':[116.59,35.38],
  390. '荆州':[112.239741,30.335165],
  391. '宜昌':[111.3,30.7],
  392. '义乌':[120.06,29.32],
  393. '丽水':[119.92,28.45],
  394. '洛阳':[112.44,34.7],
  395. '秦皇岛':[119.57,39.95],
  396. '株洲':[113.16,27.83],
  397. '石家庄':[114.48,38.03],
  398. '莱芜':[117.67,36.19],
  399. '常德':[111.69,29.05],
  400. '保定':[115.48,38.85],
  401. '湘潭':[112.91,27.87],
  402. '金华':[119.64,29.12],
  403. '岳阳':[113.09,29.37],
  404. '长沙':[113,28.21],
  405. '衢州':[118.88,28.97],
  406. '廊坊':[116.7,39.53],
  407. '菏泽':[115.480656,35.23375],
  408. '合肥':[117.27,31.86],
  409. '武汉':[114.31,30.52],
  410. '大庆':[125.03,46.58]
  411. };
  412. var convertData = function (data) {
  413. var res = [];
  414. for (var i = 0; i < data.length; i++) {
  415. var geoCoord = geoCoordMap[data[i].name];
  416. if (geoCoord) {
  417. res.push({
  418. name: data[i].name,
  419. value: geoCoord.concat(data[i].value)
  420. });
  421. }
  422. }
  423. return res;
  424. };
  425. var myChart = echarts.init(document.getElementById('main'));
  426. myChart.setOption({
  427. backgroundColor: '#404a59',
  428. title: {
  429. text: '全国主要城市空气质量',
  430. subtext: 'data from PM25.in',
  431. sublink: 'http://www.pm25.in',
  432. left: 'center',
  433. textStyle: {
  434. color: '#fff'
  435. }
  436. },
  437. tooltip : {
  438. trigger: 'item'
  439. },
  440. legend: {
  441. orient: 'vertical',
  442. top: 'bottom',
  443. left: 'right',
  444. data:['pm2.5'],
  445. textStyle: {
  446. color: '#fff'
  447. }
  448. },
  449. geo: {
  450. map: 'china',
  451. label: {
  452. emphasis: {
  453. show: false
  454. }
  455. },
  456. roam: true,
  457. itemStyle: {
  458. normal: {
  459. areaColor: '#323c48',
  460. borderColor: '#111'
  461. },
  462. emphasis: {
  463. areaColor: '#2a333d'
  464. }
  465. }
  466. },
  467. series : [
  468. {
  469. name: 'pm2.5',
  470. type: 'scatter',
  471. coordinateSystem: 'geo',
  472. data: convertData(data),
  473. symbolSize: function (val) {
  474. return val[2] / 10;
  475. },
  476. label: {
  477. normal: {
  478. formatter: '{b}',
  479. position: 'right',
  480. show: false
  481. },
  482. emphasis: {
  483. show: true
  484. }
  485. },
  486. itemStyle: {
  487. normal: {
  488. color: '#ddb926'
  489. }
  490. }
  491. },
  492. {
  493. name: 'Top 5',
  494. type: 'effectScatter',
  495. coordinateSystem: 'geo',
  496. data: convertData(data.sort(function (a, b) {
  497. return b.value - a.value;
  498. }).slice(0, 6)),
  499. symbolSize: function (val) {
  500. return val[2] / 10;
  501. },
  502. showEffectOn: 'emphasis',
  503. rippleEffect: {
  504. brushType: 'stroke'
  505. },
  506. hoverAnimation: true,
  507. label: {
  508. normal: {
  509. formatter: '{b}',
  510. position: 'right',
  511. show: true
  512. }
  513. },
  514. itemStyle: {
  515. normal: {
  516. color: '#f4e925',
  517. shadowBlur: 10,
  518. shadowColor: '#333'
  519. }
  520. },
  521. zlevel: 1
  522. }
  523. ]
  524. });
  525. });
  526. });
  527. </script>
  528. </body>
  529. </html>