js.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1.  $(window).load(function () {
  2. $(".loading").fadeOut()
  3. })
  4. /* */
  5. $(function () {
  6. echarts_1();
  7. echarts_2();
  8. echarts_3();
  9. echarts_4();
  10. function echarts_1() {
  11. // 基于准备好的dom,初始化echarts实例
  12. var myChart = echarts.init(document.getElementById('echart1'));
  13. option = {
  14. tooltip: {
  15. trigger: 'item',
  16. formatter: "{a} <br/>{b} : {c} ({d}%)"
  17. },
  18. series: [{
  19. name: '占比情况',
  20. type: 'pie',
  21. radius: '50%',
  22. center: ['50%', '50%'],
  23. clockwise: false,
  24. data: [ {
  25. value: 25,
  26. name: '公司1'
  27. }, {
  28. value: 15,
  29. name: '公司2'
  30. }, {
  31. value: 8,
  32. name: '公司3'
  33. }],
  34. label: {
  35. normal: {
  36. textStyle: {
  37. color: 'rgba(255,255,255,.6)',
  38. fontSize: 14,
  39. }
  40. }
  41. },
  42. labelLine: {
  43. normal: {
  44. show: false
  45. }
  46. },
  47. itemStyle: {
  48. normal: {
  49. //borderWidth: 1,
  50. //borderColor: '#ffffff',
  51. },
  52. emphasis: {
  53. borderWidth: 0,
  54. shadowBlur: 10,
  55. shadowOffsetX: 0,
  56. shadowColor: 'rgba(0, 0, 0, 0.5)'
  57. }
  58. }
  59. }],
  60. color: ['#62c98d','#2f89cf','#4cb9cf'],
  61. //backgroundColor: '#fff'
  62. };
  63. // 使用刚指定的配置项和数据显示图表。
  64. myChart.setOption(option);
  65. window.addEventListener("resize", function () {
  66. myChart.resize();
  67. });
  68. }
  69. function echarts_2() {
  70. // 基于准备好的dom,初始化echarts实例
  71. var myChart = echarts.init(document.getElementById('echart2'));
  72. var vdata = [
  73. [4, 3, 5, 9, 1, 8, 3, 7, 2, 4, 6, 4],
  74. [5, 5, 7, 3, 6, 8, 9, 4, 3, 7, 2, 2],
  75. ];
  76. var xdata = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'];
  77. var ydata = ['计划数量', '销售金额'];
  78. var series = [];
  79. $.each(vdata, function (index, val) {
  80. var series_option = {
  81. name: ydata[index],
  82. type: 'bar',
  83. itemStyle: {
  84. normal: {color: ''}
  85. },
  86. barWidth: '30',
  87. data: val
  88. };
  89. series.push(series_option);
  90. })
  91. option = {
  92. legend: {
  93. data: ydata,
  94. type: 'scroll',
  95. textStyle: {color: "#fff"},
  96. top: '0'
  97. },
  98. tooltip: {
  99. trigger: 'axis',
  100. axisPointer: {
  101. type: 'shadow'
  102. }
  103. },
  104. "color": ["#62c98d", "#2f89cf"],
  105. grid: {
  106. top: '14%',
  107. left: '15',
  108. right: '35',
  109. bottom: '12%',
  110. containLabel: true
  111. },
  112. xAxis: [{
  113. type: 'category',
  114. axisLabel: {textStyle: {color: "rgba(255,255,255,.6)",}},
  115. axisLine: {lineStyle: { color: 'rgba(255,255,255,.1)'}},
  116. data: xdata,
  117. }],
  118. yAxis: [{
  119. name: '',
  120. type: 'value',
  121. axisTick: {show: false},
  122. splitLine: {
  123. show: true,
  124. lineStyle: {
  125. color: "#2f2a7a"
  126. }
  127. }, //x轴线
  128. axisLabel: {textStyle: {color: 'rgba(255,255,255,.6)'}},
  129. axisLine: {lineStyle: {color: 'rgba(255,255,255,.1)'}},
  130. }],
  131. "dataZoom": [{
  132. "show": true,
  133. "height": 12,
  134. "xAxisIndex": [
  135. 0
  136. ],
  137. bottom: 5,
  138. "start": 10,
  139. "end": 80,
  140. handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z',
  141. handleSize: '110%',
  142. handleStyle: {
  143. color: "#d3dee5",
  144. },
  145. textStyle: {
  146. color: "#fff"
  147. },
  148. borderColor: "rgba(255,255,255,.3)"
  149. }],
  150. series: series
  151. };
  152. // 使用刚指定的配置项和数据显示图表。
  153. myChart.setOption(option);
  154. window.addEventListener("resize", function () {
  155. myChart.resize();
  156. });
  157. }
  158. /* */
  159. function echarts_3() {
  160. var myChart = echarts.init(document.getElementById('echart3'));
  161. var geoCoordMap = {
  162. '上海': [121.4648,31.2891],
  163. '东莞': [113.8953,22.901],
  164. '东营': [118.7073,37.5513],
  165. '中山': [113.4229,22.478],
  166. '临汾': [111.4783,36.1615],
  167. '临沂': [118.3118,35.2936],
  168. '丹东': [124.541,40.4242],
  169. '丽水': [119.5642,28.1854],
  170. '乌鲁木齐': [87.9236,43.5883],
  171. '佛山': [112.8955,23.1097],
  172. '保定': [115.0488,39.0948],
  173. '兰州': [103.5901,36.3043],
  174. '包头': [110.3467,41.4899],
  175. '北京': [116.4551,40.2539],
  176. '北海': [109.314,21.6211],
  177. '南京': [118.8062,31.9208],
  178. '南宁': [108.479,23.1152],
  179. '南昌': [116.0046,28.6633],
  180. '南通': [121.1023,32.1625],
  181. '厦门': [118.1689,24.6478],
  182. '台州': [121.1353,28.6688],
  183. '合肥': [117.29,32.0581],
  184. '呼和浩特': [111.4124,40.4901],
  185. '咸阳': [108.4131,34.8706],
  186. '哈尔滨': [127.9688,45.368],
  187. '唐山': [118.4766,39.6826],
  188. '嘉兴': [120.9155,30.6354],
  189. '大同': [113.7854,39.8035],
  190. '大连': [122.2229,39.4409],
  191. '天津': [117.4219,39.4189],
  192. '太原': [112.3352,37.9413],
  193. '威海': [121.9482,37.1393],
  194. '宁波': [121.5967,29.6466],
  195. '宝鸡': [107.1826,34.3433],
  196. '宿迁': [118.5535,33.7775],
  197. '常州': [119.4543,31.5582],
  198. '广州': [113.5107,23.2196],
  199. '廊坊': [116.521,39.0509],
  200. '延安': [109.1052,36.4252],
  201. '张家口': [115.1477,40.8527],
  202. '徐州': [117.5208,34.3268],
  203. '德州': [116.6858,37.2107],
  204. '惠州': [114.6204,23.1647],
  205. '成都': [103.9526,30.7617],
  206. '扬州': [119.4653,32.8162],
  207. '承德': [117.5757,41.4075],
  208. '拉萨': [91.1865,30.1465],
  209. '无锡': [120.3442,31.5527],
  210. '日照': [119.2786,35.5023],
  211. '昆明': [102.9199,25.4663],
  212. '杭州': [119.5313,29.8773],
  213. '枣庄': [117.323,34.8926],
  214. '柳州': [109.3799,24.9774],
  215. '株洲': [113.5327,27.0319],
  216. '武汉': [114.3896,30.6628],
  217. '汕头': [117.1692,23.3405],
  218. '江门': [112.6318,22.1484],
  219. '沈阳': [123.1238,42.1216],
  220. '沧州': [116.8286,38.2104],
  221. '河源': [114.917,23.9722],
  222. '泉州': [118.3228,25.1147],
  223. '泰安': [117.0264,36.0516],
  224. '泰州': [120.0586,32.5525],
  225. '济南': [117.1582,36.8701],
  226. '济宁': [116.8286,35.3375],
  227. '海口': [110.3893,19.8516],
  228. '淄博': [118.0371,36.6064],
  229. '淮安': [118.927,33.4039],
  230. '深圳': [114.5435,22.5439],
  231. '清远': [112.9175,24.3292],
  232. '温州': [120.498,27.8119],
  233. '渭南': [109.7864,35.0299],
  234. '湖州': [119.8608,30.7782],
  235. '湘潭': [112.5439,27.7075],
  236. '滨州': [117.8174,37.4963],
  237. '潍坊': [119.0918,36.524],
  238. '烟台': [120.7397,37.5128],
  239. '玉溪': [101.9312,23.8898],
  240. '珠海': [113.7305,22.1155],
  241. '盐城': [120.2234,33.5577],
  242. '盘锦': [121.9482,41.0449],
  243. '石家庄': [114.4995,38.1006],
  244. '福州': [119.4543,25.9222],
  245. '秦皇岛': [119.2126,40.0232],
  246. '绍兴': [120.564,29.7565],
  247. '聊城': [115.9167,36.4032],
  248. '肇庆': [112.1265,23.5822],
  249. '舟山': [122.2559,30.2234],
  250. '苏州': [120.6519,31.3989],
  251. '莱芜': [117.6526,36.2714],
  252. '菏泽': [115.6201,35.2057],
  253. '营口': [122.4316,40.4297],
  254. '葫芦岛': [120.1575,40.578],
  255. '衡水': [115.8838,37.7161],
  256. '衢州': [118.6853,28.8666],
  257. '西宁': [101.4038,36.8207],
  258. '西安': [109.1162,34.2004],
  259. '贵阳': [106.6992,26.7682],
  260. '连云港': [119.1248,34.552],
  261. '邢台': [114.8071,37.2821],
  262. '邯郸': [114.4775,36.535],
  263. '郑州': [113.4668,34.6234],
  264. '鄂尔多斯': [108.9734,39.2487],
  265. '重庆': [107.7539,30.1904],
  266. '金华': [120.0037,29.1028],
  267. '铜川': [109.0393,35.1947],
  268. '银川': [106.3586,38.1775],
  269. '镇江': [119.4763,31.9702],
  270. '长春': [125.8154,44.2584],
  271. '长沙': [113.0823,28.2568],
  272. '长治': [112.8625,36.4746],
  273. '阳泉': [113.4778,38.0951],
  274. '青岛': [120.4651,36.3373],
  275. '韶关': [113.7964,24.7028]
  276. };
  277. var BJData = [
  278. [{name:'北京'}, {name:'上海',value:95}],
  279. [{name:'北京'}, {name:'广州',value:90}],
  280. [{name:'北京'}, {name:'大连',value:80}],
  281. [{name:'北京'}, {name:'南宁',value:70}],
  282. [{name:'北京'}, {name:'南昌',value:60}],
  283. [{name:'北京'}, {name:'拉萨',value:50}],
  284. [{name:'北京'}, {name:'长春',value:40}],
  285. [{name:'北京'}, {name:'包头',value:30}],
  286. [{name:'北京'}, {name:'重庆',value:20}],
  287. [{name:'北京'}, {name:'常州',value:10}]
  288. ];
  289. var planePath = 'path://M1705.06,1318.313v-89.254l-319.9-221.799l0.073-208.063c0.521-84.662-26.629-121.796-63.961-121.491c-37.332-0.305-64.482,36.829-63.961,121.491l0.073,208.063l-319.9,221.799v89.254l330.343-157.288l12.238,241.308l-134.449,92.931l0.531,42.034l175.125-42.917l175.125,42.917l0.531-42.034l-134.449-92.931l12.238-241.308L1705.06,1318.313z';
  290. var convertData = function (data) {
  291. var res = [];
  292. for (var i = 0; i < data.length; i++) {
  293. var dataItem = data[i];
  294. var fromCoord = geoCoordMap[dataItem[0].name];
  295. var toCoord = geoCoordMap[dataItem[1].name];
  296. if (fromCoord && toCoord) {
  297. res.push([{
  298. coord: fromCoord
  299. }, {
  300. coord: toCoord
  301. }]);
  302. }
  303. }
  304. return res;
  305. };
  306. var color = ['#fff'];
  307. var series = [];
  308. [['北京', BJData]].forEach(function (item, i) {
  309. series.push({
  310. name: item[0] + '',
  311. type: 'lines',
  312. // zlevel: 1,
  313. effect: {
  314. show: true,
  315. period: 6,
  316. trailLength: 0.7,
  317. color: '#fff',
  318. symbolSize: 3
  319. },
  320. lineStyle: {
  321. normal: {
  322. color: color[i],
  323. width: 0,
  324. curveness: 0.2
  325. }
  326. },
  327. data: convertData(item[1])
  328. },
  329. {
  330. name: item[0] ,
  331. type: 'lines',
  332. zlevel: 2,
  333. effect: {
  334. show: true,
  335. period: 6,
  336. trailLength: 0,
  337. symbol: planePath,
  338. symbolSize: 15
  339. },
  340. lineStyle: {
  341. normal: {
  342. color: color[i],
  343. width: 1,
  344. opacity: 0.4,
  345. curveness: 0.2
  346. }
  347. },
  348. data: convertData(item[1])
  349. },
  350. {
  351. name: item[0] ,
  352. type: 'effectScatter',
  353. coordinateSystem: 'geo',
  354. zlevel: 2,
  355. rippleEffect: {
  356. brushType: 'stroke'
  357. },
  358. label: {
  359. normal: {
  360. show: true,
  361. fontSize:16,
  362. color:'#fff',
  363. position: 'right',
  364. formatter: '{b}'
  365. }
  366. },
  367. symbolSize:'10',
  368. /**symbolSize: function (val) {
  369. return val[2] / 8;
  370. },**/
  371. itemStyle: {
  372. normal: {
  373. color: color[i]
  374. }
  375. },
  376. data: item[1].map(function (dataItem) {
  377. return {
  378. name: dataItem[1].name,
  379. value: geoCoordMap[dataItem[1].name].concat([dataItem[1].value])
  380. };
  381. })
  382. });
  383. });
  384. option = {
  385. // backgroundColor: '#404a59',
  386. title : {
  387. text: '全国发展路线图',
  388. subtext: '副标题,不需要主删除此行',
  389. left: 'center',
  390. top: '13%',
  391. textStyle: {
  392. color: '#fff'
  393. }
  394. },
  395. geo: {
  396. map: 'china',
  397. label: {
  398. emphasis: {
  399. show: false
  400. }
  401. },
  402. roam: true,
  403. itemStyle: {
  404. normal: {
  405. areaColor: '#2a91e2',
  406. borderColor: '#0165b4'
  407. },
  408. emphasis: {
  409. areaColor: '#306de8'
  410. }
  411. }
  412. },
  413. series:series
  414. };
  415. // 使用刚指定的配置项和数据显示图表。
  416. myChart.setOption(option);
  417. window.addEventListener("resize", function () {
  418. myChart.resize();
  419. });
  420. }
  421. function echarts_4() {
  422. var myChart = echarts.init(document.getElementById('echart4'));
  423. option = {
  424. tooltip: {
  425. trigger: 'axis',
  426. axisPointer: {
  427. lineStyle: {
  428. color: '#57617B'
  429. }
  430. },
  431. formatter: '{b}:<br/> 完成率{c}%'
  432. },
  433. grid: {
  434. left: '0',
  435. right: '20',
  436. top:'10',
  437. bottom: '20',
  438. containLabel: true
  439. },
  440. xAxis: [{
  441. type: 'category',
  442. boundaryGap: false,
  443. axisLabel: {
  444. show: true,
  445. textStyle: {
  446. color: 'rgba(255,255,255,.6)'
  447. }
  448. },
  449. axisLine: {
  450. lineStyle: {
  451. color: 'rgba(255,255,255,.1)'
  452. }
  453. },
  454. data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
  455. }],
  456. yAxis: [{
  457. axisLabel: {
  458. show: true,
  459. textStyle: {
  460. color: 'rgba(255,255,255,.6)'
  461. }
  462. },
  463. axisLine: {
  464. lineStyle: {
  465. color: 'rgba(255,255,255,.1)'
  466. }
  467. },
  468. splitLine: {
  469. lineStyle: {
  470. color: 'rgba(255,255,255,.1)'
  471. }
  472. }
  473. }],
  474. series: [{
  475. name: '完成率',
  476. type: 'line',
  477. smooth: true,
  478. symbol: 'circle',
  479. symbolSize: 5,
  480. showSymbol: false,
  481. lineStyle: {
  482. normal: {
  483. width: 3
  484. }
  485. },
  486. areaStyle: {
  487. normal: {
  488. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  489. offset: 0,
  490. color: 'rgba(98, 201, 141, 0.5)'
  491. }, {
  492. offset: 1,
  493. color: 'rgba(98, 201, 141, 0.1)'
  494. }], false),
  495. shadowColor: 'rgba(0, 0, 0, 0.1)',
  496. shadowBlur: 10
  497. }
  498. },
  499. itemStyle: {
  500. normal: {
  501. color: '#4cb9cf',
  502. borderColor: 'rgba(98, 201, 141,0.27)',
  503. borderWidth: 12
  504. }
  505. },
  506. data: [91, 60, 70, 54, 80, 40, 99, 33, 80, 20, 60, 10]
  507. }]
  508. };
  509. /* */
  510. // 使用刚指定的配置项和数据显示图表。
  511. myChart.setOption(option);
  512. window.addEventListener("resize",function(){
  513. myChart.resize();
  514. });
  515. }
  516. })