index.js 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419
  1. $(function () {
  2. echart_1();
  3. echart_2();
  4. echart_3();
  5. echart_4();
  6. echart_map();
  7. echart_5();
  8. //echart_1湖南货物收入
  9. function echart_1() {
  10. // 基于准备好的dom,初始化echarts实例
  11. var myChart = echarts.init(document.getElementById('chart_1'));
  12. option = {
  13. tooltip: {
  14. trigger: 'item',
  15. formatter: "{a} <br/>{b} : {c}万元"
  16. },
  17. legend: {
  18. x: 'center',
  19. y: '15%',
  20. data: [ '张家口', '承德', '衡水','邢台', '邯郸', '保定','秦皇岛','石家庄', '唐山'],
  21. icon: 'circle',
  22. textStyle: {
  23. color: '#fff',
  24. }
  25. },
  26. calculable: true,
  27. series: [{
  28. name: '',
  29. type: 'pie',
  30. //起始角度,支持范围[0, 360]
  31. startAngle: 0,
  32. //饼图的半径,数组的第一项是内半径,第二项是外半径
  33. radius: [41, 100.75],
  34. //支持设置成百分比,设置成百分比时第一项是相对于容器宽度,第二项是相对于容器高度
  35. center: ['50%', '40%'],
  36. //是否展示成南丁格尔图,通过半径区分数据大小。可选择两种模式:
  37. // 'radius' 面积展现数据的百分比,半径展现数据的大小。
  38. // 'area' 所有扇区面积相同,仅通过半径展现数据大小
  39. roseType: 'area',
  40. //是否启用防止标签重叠策略,默认开启,圆环图这个例子中需要强制所有标签放在中心位置,可以将该值设为 false。
  41. avoidLabelOverlap: false,
  42. label: {
  43. normal: {
  44. show: true,
  45. formatter: '{c}万元'
  46. },
  47. emphasis: {
  48. show: true
  49. }
  50. },
  51. labelLine: {
  52. normal: {
  53. show: true,
  54. length2: 1,
  55. },
  56. emphasis: {
  57. show: true
  58. }
  59. },
  60. data: [{
  61. value: 900.58,
  62. name: '张家口',
  63. itemStyle: {
  64. normal: {
  65. color: '#f845f1'
  66. }
  67. }
  68. },
  69. {
  70. value: 1100.58,
  71. name: '承德',
  72. itemStyle: {
  73. normal: {
  74. color: '#ad46f3'
  75. }
  76. }
  77. },
  78. {
  79. value: 1200.58,
  80. name: '衡水',
  81. itemStyle: {
  82. normal: {
  83. color: '#5045f6'
  84. }
  85. }
  86. },
  87. {
  88. value: 1300.58,
  89. name: '邢台',
  90. itemStyle: {
  91. normal: {
  92. color: '#4777f5'
  93. }
  94. }
  95. },
  96. {
  97. value: 1400.58,
  98. name: '邯郸',
  99. itemStyle: {
  100. normal: {
  101. color: '#44aff0'
  102. }
  103. }
  104. },
  105. {
  106. value: 1500.58,
  107. name: '保定',
  108. itemStyle: {
  109. normal: {
  110. color: '#45dbf7'
  111. }
  112. }
  113. },
  114. {
  115. value: 1500.58,
  116. name: '秦皇岛',
  117. itemStyle: {
  118. normal: {
  119. color: '#f6d54a'
  120. }
  121. }
  122. },
  123. {
  124. value: 1600.58,
  125. name: '石家庄',
  126. itemStyle: {
  127. normal: {
  128. color: '#f69846'
  129. }
  130. }
  131. },
  132. {
  133. value: 1800,
  134. name: '唐山',
  135. itemStyle: {
  136. normal: {
  137. color: '#ff4343'
  138. }
  139. }
  140. },
  141. {
  142. value: 0,
  143. name: "",
  144. itemStyle: {
  145. normal: {
  146. color: 'transparent'
  147. }
  148. },
  149. label: {
  150. show: false
  151. },
  152. labelLine: {
  153. show: false
  154. }
  155. },
  156. {
  157. value: 0,
  158. name: "",
  159. itemStyle: {
  160. normal: {
  161. color: 'transparent'
  162. }
  163. },
  164. label: {
  165. show: false
  166. },
  167. labelLine: {
  168. show: false
  169. }
  170. },
  171. {
  172. value: 0,
  173. name: "",
  174. itemStyle: {
  175. normal: {
  176. color: 'transparent'
  177. }
  178. },
  179. label: {
  180. show: false
  181. },
  182. labelLine: {
  183. show: false
  184. }
  185. },
  186. {
  187. value: 0,
  188. name: "",
  189. itemStyle: {
  190. normal: {
  191. color: 'transparent'
  192. }
  193. },
  194. label: {
  195. show: false
  196. },
  197. labelLine: {
  198. show: false
  199. }
  200. },
  201. {
  202. value: 0,
  203. name: "",
  204. itemStyle: {
  205. normal: {
  206. color: 'transparent'
  207. }
  208. },
  209. label: {
  210. show: false
  211. },
  212. labelLine: {
  213. show: false
  214. }
  215. },
  216. {
  217. value: 0,
  218. name: "",
  219. itemStyle: {
  220. normal: {
  221. color: 'transparent'
  222. }
  223. },
  224. label: {
  225. show: false
  226. },
  227. labelLine: {
  228. show: false
  229. }
  230. },
  231. {
  232. value: 0,
  233. name: "",
  234. itemStyle: {
  235. normal: {
  236. color: 'transparent'
  237. }
  238. },
  239. label: {
  240. show: false
  241. },
  242. labelLine: {
  243. show: false
  244. }
  245. },
  246. {
  247. value: 0,
  248. name: "",
  249. itemStyle: {
  250. normal: {
  251. color: 'transparent'
  252. }
  253. },
  254. label: {
  255. show: false
  256. },
  257. labelLine: {
  258. show: false
  259. }
  260. },
  261. {
  262. value: 0,
  263. name: "",
  264. itemStyle: {
  265. normal: {
  266. color: 'transparent'
  267. }
  268. },
  269. label: {
  270. show: false
  271. },
  272. labelLine: {
  273. show: false
  274. }
  275. }
  276. ]
  277. }]
  278. };
  279. // 使用刚指定的配置项和数据显示图表。
  280. myChart.setOption(option);
  281. window.addEventListener("resize", function () {
  282. myChart.resize();
  283. });
  284. }
  285. //echart_2湖南省地图
  286. function echart_2() {
  287. // 基于准备好的dom,初始化echarts实例
  288. var myChart = echarts.init(document.getElementById('chart_2'));
  289. function showProvince() {
  290. myChart.setOption(option = {
  291. // backgroundColor: '#ffffff',
  292. visualMap: {
  293. show: false,
  294. min: 0,
  295. max: 100,
  296. left: 'left',
  297. top: 'bottom',
  298. text: ['高', '低'], // 文本,默认为数值文本
  299. calculable: true,
  300. inRange: {
  301. color: ['yellow', 'lightskyblue', 'orangered']
  302. }
  303. },
  304. series: [{
  305. type: 'map',
  306. mapType: 'hunan',
  307. roam: true,
  308. label: {
  309. normal: {
  310. show: true
  311. },
  312. emphasis: {
  313. textStyle: {
  314. color: '#fff'
  315. }
  316. }
  317. },
  318. itemStyle: {
  319. normal: {
  320. borderColor: '#389BB7',
  321. areaColor: '#fff',
  322. },
  323. emphasis: {
  324. areaColor: '#389BB7',
  325. borderWidth: 0
  326. }
  327. },
  328. animation: false,
  329. data: [{
  330. name: '长沙市',
  331. value: 100
  332. }, {
  333. name: '株洲市',
  334. value: 96
  335. }, {
  336. name: '湘潭市',
  337. value: 98
  338. }, {
  339. name: '衡阳市',
  340. value: 80
  341. }, {
  342. name: '邵阳市',
  343. value: 88
  344. }, {
  345. name: '岳阳市',
  346. value: 79
  347. }, {
  348. name: '常德市',
  349. value: 77,
  350. }, {
  351. name: '张家界市',
  352. value: 33
  353. }, {
  354. name: '益阳市',
  355. value: 69,
  356. }, {
  357. name: '郴州市',
  358. value: 66
  359. }, {
  360. name: '永州市',
  361. value: 22
  362. },{
  363. name: '娄底市',
  364. value: 51
  365. },{
  366. name: '湘西土家族苗族自治州',
  367. value: 44
  368. },{
  369. name: '怀化市',
  370. value: 9
  371. }]
  372. }]
  373. });
  374. }
  375. var currentIdx = 0;
  376. showProvince();
  377. // 使用刚指定的配置项和数据显示图表。
  378. window.addEventListener("resize", function () {
  379. myChart.resize();
  380. });
  381. }
  382. // echart_map中国地图
  383. function echart_map() {
  384. // 基于准备好的dom,初始化echarts实例
  385. var myChart = echarts.init(document.getElementById('chart_map'));
  386. var mapName = 'china'
  387. var data = []
  388. var toolTipData = [];
  389. /*获取地图数据*/
  390. myChart.showLoading();
  391. var mapFeatures = echarts.getMap(mapName).geoJson.features;
  392. myChart.hideLoading();
  393. var geoCoordMap = {
  394. '福州': [119.4543, 25.9222],
  395. '长春': [125.8154, 44.2584],
  396. '重庆': [107.7539, 30.1904],
  397. '西安': [109.1162, 34.2004],
  398. '成都': [103.9526, 30.7617],
  399. '常州': [119.4543, 31.5582],
  400. '北京': [116.4551, 40.2539],
  401. '北海': [109.314, 21.6211],
  402. '海口': [110.3893, 19.8516],
  403. '长沙': [113.019455,28.200103],
  404. '上海': [121.40, 31.73],
  405. '内蒙古': [106.82, 39.67]
  406. };
  407. var GZData = [
  408. [{
  409. name: '长沙'
  410. }, {
  411. name: '福州',
  412. value: 95
  413. }],
  414. [{
  415. name: '长沙'
  416. }, {
  417. name: '长春',
  418. value: 80
  419. }],
  420. [{
  421. name: '长沙'
  422. }, {
  423. name: '重庆',
  424. value: 70
  425. }],
  426. [{
  427. name: '长沙'
  428. }, {
  429. name: '西安',
  430. value: 60
  431. }],
  432. [{
  433. name: '长沙'
  434. }, {
  435. name: '成都',
  436. value: 50
  437. }],
  438. [{
  439. name: '长沙'
  440. }, {
  441. name: '常州',
  442. value: 40
  443. }],
  444. [{
  445. name: '长沙'
  446. }, {
  447. name: '北京',
  448. value: 30
  449. }],
  450. [{
  451. name: '长沙'
  452. }, {
  453. name: '北海',
  454. value: 20
  455. }],
  456. [{
  457. name: '长沙'
  458. }, {
  459. name: '海口',
  460. value: 10
  461. }],
  462. [{
  463. name: '长沙'
  464. }, {
  465. name: '上海',
  466. value: 80
  467. }],
  468. [{
  469. name: '长沙'
  470. }, {
  471. name: '内蒙古',
  472. value: 80
  473. }]
  474. ];
  475. var convertData = function (data) {
  476. var res = [];
  477. for (var i = 0; i < data.length; i++) {
  478. var dataItem = data[i];
  479. var fromCoord = geoCoordMap[dataItem[0].name];
  480. var toCoord = geoCoordMap[dataItem[1].name];
  481. if (fromCoord && toCoord) {
  482. res.push({
  483. fromName: dataItem[0].name,
  484. toName: dataItem[1].name,
  485. coords: [fromCoord, toCoord]
  486. });
  487. }
  488. }
  489. return res;
  490. };
  491. var color = ['#c5f80e'];
  492. var series = [];
  493. [
  494. ['石家庄', GZData]
  495. ].forEach(function (item, i) {
  496. series.push({
  497. name: item[0],
  498. type: 'lines',
  499. zlevel: 2,
  500. symbol: ['none', 'arrow'],
  501. symbolSize: 10,
  502. effect: {
  503. show: true,
  504. period: 6,
  505. trailLength: 0,
  506. symbol: 'arrow',
  507. symbolSize: 5
  508. },
  509. lineStyle: {
  510. normal: {
  511. color: color[i],
  512. width: 1,
  513. opacity: 0.6,
  514. curveness: 0.2
  515. }
  516. },
  517. data: convertData(item[1])
  518. }, {
  519. name: item[0],
  520. type: 'effectScatter',
  521. coordinateSystem: 'geo',
  522. zlevel: 2,
  523. rippleEffect: {
  524. brushType: 'stroke'
  525. },
  526. label: {
  527. normal: {
  528. show: true,
  529. position: 'right',
  530. formatter: '{b}'
  531. }
  532. },
  533. symbolSize: function (val) {
  534. return val[2] / 8;
  535. },
  536. itemStyle: {
  537. normal: {
  538. color: color[i]
  539. }
  540. },
  541. data: item[1].map(function (dataItem) {
  542. return {
  543. name: dataItem[1].name,
  544. value: geoCoordMap[dataItem[1].name].concat([dataItem[1].value])
  545. };
  546. })
  547. });
  548. });
  549. option = {
  550. tooltip: {
  551. trigger: 'item'
  552. },
  553. geo: {
  554. map: 'china',
  555. label: {
  556. emphasis: {
  557. show: false
  558. }
  559. },
  560. roam: true,
  561. itemStyle: {
  562. normal: {
  563. borderColor: 'rgba(147, 235, 248, 1)',
  564. borderWidth: 1,
  565. areaColor: {
  566. type: 'radial',
  567. x: 0.5,
  568. y: 0.5,
  569. r: 0.8,
  570. colorStops: [{
  571. offset: 0,
  572. color: 'rgba(175,238,238, 0)' // 0% 处的颜色
  573. }, {
  574. offset: 1,
  575. color: 'rgba(47,79,79, .1)' // 100% 处的颜色
  576. }],
  577. globalCoord: false // 缺省为 false
  578. },
  579. shadowColor: 'rgba(128, 217, 248, 1)',
  580. // shadowColor: 'rgba(255, 255, 255, 1)',
  581. shadowOffsetX: -2,
  582. shadowOffsetY: 2,
  583. shadowBlur: 10
  584. },
  585. emphasis: {
  586. areaColor: '#389BB7',
  587. borderWidth: 0
  588. }
  589. }
  590. },
  591. series: series
  592. };
  593. // 使用刚指定的配置项和数据显示图表。
  594. myChart.setOption(option);
  595. window.addEventListener("resize", function () {
  596. myChart.resize();
  597. });
  598. }
  599. //echart_3货物周转量
  600. function echart_3() {
  601. // 基于准备好的dom,初始化echarts实例
  602. var myChart = echarts.init(document.getElementById('chart_3'));
  603. myChart.clear();
  604. option = {
  605. title: {
  606. text: ''
  607. },
  608. tooltip: {
  609. trigger: 'axis'
  610. },
  611. legend: {
  612. data:['铁路货物','国家铁路货物','地方铁路货物','合资铁路货物','公路货物','水运货物'],
  613. textStyle:{
  614. color: '#fff'
  615. },
  616. top: '8%'
  617. },
  618. grid: {
  619. top: '40%',
  620. left: '3%',
  621. right: '4%',
  622. bottom: '3%',
  623. containLabel: true
  624. },
  625. color: ['#FF4949','#FFA74D','#FFEA51','#4BF0FF','#44AFF0','#4E82FF','#584BFF','#BE4DFF','#F845F1'],
  626. xAxis: {
  627. type: 'category',
  628. boundaryGap: false,
  629. data: ['2012年','2013年','2014年','2015年','2016年'],
  630. splitLine: {
  631. show: false
  632. },
  633. axisLine: {
  634. lineStyle: {
  635. color: '#fff'
  636. }
  637. }
  638. },
  639. yAxis: {
  640. name: '亿吨公里',
  641. type: 'value',
  642. splitLine: {
  643. show: false
  644. },
  645. axisLine: {
  646. lineStyle: {
  647. color: '#fff'
  648. }
  649. }
  650. },
  651. series: [
  652. {
  653. name:'铁路货物',
  654. type:'line',
  655. data:[3961.88, 4233.63, 4183.14, 3633.01, 3704.47]
  656. },
  657. {
  658. name:'国家铁路货物',
  659. type:'line',
  660. data:[3374.76, 3364.76, 3274.76, 3371.82, 3259.87]
  661. },
  662. {
  663. name:'地方铁路货物',
  664. type:'line',
  665. data:[14.77, 15.17, 13.17, 14.56, 15.84]
  666. },
  667. {
  668. name:'合资铁路货物',
  669. type:'line',
  670. data:[686.17,847.26,895.22,865.28,886.72]
  671. },
  672. {
  673. name:'公路货物',
  674. type:'line',
  675. data:[6133.47, 6577.89, 7019.56,6821.48,7294.59]
  676. },
  677. {
  678. name:'水运货物',
  679. type:'line',
  680. data:[509.60, 862.54, 1481.77,1552.79,1333.62]
  681. }
  682. ]
  683. };
  684. myChart.setOption(option);
  685. }
  686. //湖南高速公路
  687. function echart_4() {
  688. // 基于准备好的dom,初始化echarts实例
  689. var myChart = echarts.init(document.getElementById('chart_4'));
  690. myChart.setOption({
  691. series: [{
  692. type: 'map',
  693. mapType: 'hunan'
  694. }]
  695. });
  696. var geoCoordMap = {
  697. '怀化': [109.999867,27.518949],
  698. '吉首': [109.741528,28.332629],
  699. '张家界': [110.491722,29.112001],
  700. '常德': [111.701486,29.076683],
  701. '益阳': [112.348741,28.544124],
  702. '岳阳': [113.126486,29.382401],
  703. '长沙': [113.019455,28.200103],
  704. '株洲': [113.163141,27.8418],
  705. '湘潭': [112.91977,27.882141],
  706. '邵阳': [111.467859,27.21915],
  707. '娄底': [112.012438,27.745506],
  708. '衡阳': [112.63809,26.895225],
  709. '永州': [111.577632,26.460144],
  710. '郴州': [113.039396,25.81497]
  711. };
  712. var goData = [
  713. [{
  714. name: '张家界'
  715. }, {
  716. id: 1,
  717. name: '常德',
  718. value: 86
  719. }],
  720. [{
  721. name: '吉首'
  722. }, {
  723. id: 1,
  724. name: '常德',
  725. value: 86
  726. }],
  727. [{
  728. name: '常德'
  729. }, {
  730. id: 1,
  731. name: '益阳',
  732. value: 70
  733. }],
  734. [{
  735. name: '益阳'
  736. }, {
  737. id: 1,
  738. name: '长沙',
  739. value: 95
  740. }],
  741. [{
  742. name: '长沙'
  743. }, {
  744. id: 1,
  745. name: '岳阳',
  746. value: 70
  747. }],
  748. [{
  749. name: '长沙'
  750. }, {
  751. id: 1,
  752. name: '湘潭',
  753. value: 80
  754. }],
  755. [{
  756. name: '长沙'
  757. }, {
  758. id: 1,
  759. name: '株洲',
  760. value: 80
  761. }],
  762. [{
  763. name: '长沙'
  764. }, {
  765. id: 1,
  766. name: '衡阳',
  767. value: 80
  768. }],
  769. [{
  770. name: '衡阳'
  771. }, {
  772. id: 1,
  773. name: '郴州',
  774. value: 70
  775. }],
  776. [{
  777. name: '衡阳'
  778. }, {
  779. id: 1,
  780. name: '永州',
  781. value: 70
  782. }],
  783. [{
  784. name: '湘潭'
  785. }, {
  786. id: 1,
  787. name: '娄底',
  788. value: 60
  789. }],
  790. [{
  791. name: '娄底'
  792. }, {
  793. id: 1,
  794. name: '邵阳',
  795. value: 75
  796. }],
  797. [{
  798. name: '邵阳'
  799. }, {
  800. id: 1,
  801. name: '怀化',
  802. value: 75
  803. }],
  804. ];
  805. //值控制圆点大小
  806. var backData = [
  807. [{
  808. name: '常德'
  809. }, {
  810. id: 1,
  811. name: '张家界',
  812. value: 80
  813. }],
  814. [{
  815. name: '常德'
  816. }, {
  817. id: 1,
  818. name: '吉首',
  819. value: 66
  820. }],
  821. [{
  822. name: '益阳'
  823. }, {
  824. id: 1,
  825. name: '常德',
  826. value: 86
  827. }],
  828. [{
  829. name: '长沙'
  830. }, {
  831. id: 1,
  832. name: '益阳',
  833. value: 70
  834. }],
  835. [{
  836. name: '岳阳'
  837. }, {
  838. id: 1,
  839. name: '长沙',
  840. value: 95
  841. }],
  842. [{
  843. name: '湘潭'
  844. }, {
  845. id: 1,
  846. name: '长沙',
  847. value: 95
  848. }],
  849. [{
  850. name: '株洲'
  851. }, {
  852. id: 1,
  853. name: '长沙',
  854. value: 95
  855. }],
  856. [{
  857. name: '衡阳'
  858. }, {
  859. id: 1,
  860. name: '长沙',
  861. value: 95
  862. }],
  863. [{
  864. name: '郴州'
  865. }, {
  866. id: 1,
  867. name: '衡阳',
  868. value: 80
  869. }],
  870. [{
  871. name: '永州'
  872. }, {
  873. id: 1,
  874. name: '衡阳',
  875. value: 80
  876. }],
  877. [{
  878. name: '娄底'
  879. }, {
  880. id: 1,
  881. name: '湘潭',
  882. value: 80
  883. }],
  884. [{
  885. name: '邵阳'
  886. }, {
  887. id: 1,
  888. name: '娄底',
  889. value: 60
  890. }],
  891. [{
  892. name: '怀化'
  893. }, {
  894. id: 1,
  895. name: '邵阳',
  896. value: 75
  897. }],
  898. ];
  899. 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';
  900. var arcAngle = function(data) {
  901. var j, k;
  902. for (var i = 0; i < data.length; i++) {
  903. var dataItem = data[i];
  904. if (dataItem[1].id == 1) {
  905. j = 0.2;
  906. return j;
  907. } else if (dataItem[1].id == 2) {
  908. k = -0.2;
  909. return k;
  910. }
  911. }
  912. }
  913. var convertData = function(data) {
  914. var res = [];
  915. for (var i = 0; i < data.length; i++) {
  916. var dataItem = data[i];
  917. var fromCoord = geoCoordMap[dataItem[0].name];
  918. var toCoord = geoCoordMap[dataItem[1].name];
  919. if (dataItem[1].id == 1) {
  920. if (fromCoord && toCoord) {
  921. res.push([{
  922. coord: fromCoord,
  923. }, {
  924. coord: toCoord,
  925. value: dataItem[1].value //线条颜色
  926. }]);
  927. }
  928. } else if (dataItem[1].id == 2) {
  929. if (fromCoord && toCoord) {
  930. res.push([{
  931. coord: fromCoord,
  932. }, {
  933. coord: toCoord
  934. }]);
  935. }
  936. }
  937. }
  938. return res;
  939. };
  940. var color = ['#fff', '#FF1493', '#0000FF'];
  941. var series = [];
  942. [
  943. ['1', goData],
  944. ['2', backData]
  945. ].forEach(function(item, i) {
  946. series.push({
  947. name: item[0],
  948. type: 'lines',
  949. zlevel: 2,
  950. symbol: ['arrow', 'arrow'],
  951. //线特效配置
  952. effect: {
  953. show: true,
  954. period: 6,
  955. trailLength: 0.1,
  956. symbol: 'arrow', //标记类型
  957. symbolSize: 5
  958. },
  959. lineStyle: {
  960. normal: {
  961. width: 1,
  962. opacity: 0.4,
  963. curveness: arcAngle(item[1]), //弧线角度
  964. color: '#fff'
  965. }
  966. },
  967. edgeLabel: {
  968. normal: {
  969. show: true,
  970. textStyle: {
  971. fontSize: 14
  972. },
  973. formatter: function(params) {
  974. var txt = '';
  975. if (params.data.speed !== undefined) {
  976. txt = params.data.speed;
  977. }
  978. return txt;
  979. },
  980. }
  981. },
  982. data: convertData(item[1])
  983. }, {
  984. type: 'effectScatter',
  985. coordinateSystem: 'geo',
  986. zlevel: 2,
  987. //波纹效果
  988. rippleEffect: {
  989. period: 2,
  990. brushType: 'stroke',
  991. scale: 3
  992. },
  993. label: {
  994. normal: {
  995. show: true,
  996. color: '#fff',
  997. position: 'right',
  998. formatter: '{b}'
  999. }
  1000. },
  1001. //终点形象
  1002. symbol: 'circle',
  1003. //圆点大小
  1004. symbolSize: function(val) {
  1005. return val[2] / 8;
  1006. },
  1007. itemStyle: {
  1008. normal: {
  1009. show: true
  1010. }
  1011. },
  1012. data: item[1].map(function(dataItem) {
  1013. return {
  1014. name: dataItem[1].name,
  1015. value: geoCoordMap[dataItem[1].name].concat([dataItem[1].value])
  1016. };
  1017. })
  1018. });
  1019. });
  1020. option = {
  1021. title: {
  1022. text: '',
  1023. subtext: '',
  1024. left: 'center',
  1025. textStyle: {
  1026. color: '#fff'
  1027. }
  1028. },
  1029. tooltip: {
  1030. trigger: 'item',
  1031. formatter: '{b}'
  1032. },
  1033. //线颜色及飞行轨道颜色
  1034. visualMap: {
  1035. show: false,
  1036. min: 0,
  1037. max: 100,
  1038. color: ['#31A031','#31A031']
  1039. },
  1040. //地图相关设置
  1041. geo: {
  1042. map: 'hunan',
  1043. //视角缩放比例
  1044. zoom: 1,
  1045. //显示文本样式
  1046. label: {
  1047. normal: {
  1048. show: false,
  1049. textStyle: {
  1050. color: '#fff'
  1051. }
  1052. },
  1053. emphasis: {
  1054. textStyle: {
  1055. color: '#fff'
  1056. }
  1057. }
  1058. },
  1059. //鼠标缩放和平移
  1060. roam: true,
  1061. itemStyle: {
  1062. normal: {
  1063. // color: '#ddd',
  1064. borderColor: 'rgba(147, 235, 248, 1)',
  1065. borderWidth: 1,
  1066. areaColor: {
  1067. type: 'radial',
  1068. x: 0.5,
  1069. y: 0.5,
  1070. r: 0.8,
  1071. colorStops: [{
  1072. offset: 0,
  1073. color: 'rgba(175,238,238, 0)' // 0% 处的颜色
  1074. }, {
  1075. offset: 1,
  1076. color: 'rgba( 47,79,79, .2)' // 100% 处的颜色
  1077. }],
  1078. globalCoord: false // 缺省为 false
  1079. },
  1080. shadowColor: 'rgba(128, 217, 248, 1)',
  1081. // shadowColor: 'rgba(255, 255, 255, 1)',
  1082. shadowOffsetX: -2,
  1083. shadowOffsetY: 2,
  1084. shadowBlur: 10
  1085. },
  1086. emphasis: {
  1087. areaColor: '#389BB7',
  1088. borderWidth: 0
  1089. }
  1090. }
  1091. },
  1092. series: series
  1093. };
  1094. myChart.setOption(option);
  1095. }
  1096. //湖南省飞机场
  1097. function echart_5() {
  1098. // 基于准备好的dom,初始化echarts实例
  1099. var myChart = echarts.init(document.getElementById('chart_5'));
  1100. function showProvince() {
  1101. var geoCoordMap = {
  1102. '长沙黄花国际机场': [113.226512,28.192929],
  1103. '张家界荷花机场': [110.454598,29.107223],
  1104. '常德桃花源机场': [111.651508,28.921516],
  1105. '永州零陵机场': [111.622869,26.340994],
  1106. '怀化芷江机场': [109.714784,27.44615],
  1107. };
  1108. var data = [{
  1109. name: '长沙黄花国际机场',
  1110. value: 100
  1111. },
  1112. {
  1113. name: '张家界荷花机场',
  1114. value: 100
  1115. },
  1116. {
  1117. name: '常德桃花源机场',
  1118. value: 100
  1119. },
  1120. {
  1121. name: '永州零陵机场',
  1122. value: 100
  1123. },
  1124. {
  1125. name: '怀化芷江机场',
  1126. value: 100
  1127. }
  1128. ];
  1129. var max = 480,
  1130. min = 9; // todo
  1131. var maxSize4Pin = 100,
  1132. minSize4Pin = 20;
  1133. var convertData = function (data) {
  1134. var res = [];
  1135. for (var i = 0; i < data.length; i++) {
  1136. var geoCoord = geoCoordMap[data[i].name];
  1137. if (geoCoord) {
  1138. res.push({
  1139. name: data[i].name,
  1140. value: geoCoord.concat(data[i].value)
  1141. });
  1142. }
  1143. }
  1144. return res;
  1145. };
  1146. myChart.setOption(option = {
  1147. title: {
  1148. top: 20,
  1149. text: '',
  1150. subtext: '',
  1151. x: 'center',
  1152. textStyle: {
  1153. color: '#ccc'
  1154. }
  1155. },
  1156. legend: {
  1157. orient: 'vertical',
  1158. y: 'bottom',
  1159. x: 'right',
  1160. data: ['pm2.5'],
  1161. textStyle: {
  1162. color: '#fff'
  1163. }
  1164. },
  1165. visualMap: {
  1166. show: false,
  1167. min: 0,
  1168. max: 500,
  1169. left: 'left',
  1170. top: 'bottom',
  1171. text: ['高', '低'], // 文本,默认为数值文本
  1172. calculable: true,
  1173. seriesIndex: [1],
  1174. inRange: {
  1175. }
  1176. },
  1177. geo: {
  1178. show: true,
  1179. map:'hunan',
  1180. mapType: 'hunan',
  1181. label: {
  1182. normal: {
  1183. },
  1184. //鼠标移入后查看效果
  1185. emphasis: {
  1186. textStyle: {
  1187. color: '#fff'
  1188. }
  1189. }
  1190. },
  1191. //鼠标缩放和平移
  1192. roam: true,
  1193. itemStyle: {
  1194. normal: {
  1195. // color: '#ddd',
  1196. borderColor: 'rgba(147, 235, 248, 1)',
  1197. borderWidth: 1,
  1198. areaColor: {
  1199. type: 'radial',
  1200. x: 0.5,
  1201. y: 0.5,
  1202. r: 0.8,
  1203. colorStops: [{
  1204. offset: 0,
  1205. color: 'rgba(175,238,238, 0)' // 0% 处的颜色
  1206. }, {
  1207. offset: 1,
  1208. color: 'rgba( 47,79,79, .2)' // 100% 处的颜色
  1209. }],
  1210. globalCoord: false // 缺省为 false
  1211. },
  1212. shadowColor: 'rgba(128, 217, 248, 1)',
  1213. shadowOffsetX: -2,
  1214. shadowOffsetY: 2,
  1215. shadowBlur: 10
  1216. },
  1217. emphasis: {
  1218. areaColor: '#389BB7',
  1219. borderWidth: 0
  1220. }
  1221. }
  1222. },
  1223. series: [{
  1224. name: 'light',
  1225. type: 'map',
  1226. coordinateSystem: 'geo',
  1227. data: convertData(data),
  1228. itemStyle: {
  1229. normal: {
  1230. color: '#F4E925'
  1231. }
  1232. }
  1233. },
  1234. {
  1235. name: '点',
  1236. type: 'scatter',
  1237. coordinateSystem: 'geo',
  1238. symbol: 'pin',
  1239. symbolSize: function(val) {
  1240. var a = (maxSize4Pin - minSize4Pin) / (max - min);
  1241. var b = minSize4Pin - a * min;
  1242. b = maxSize4Pin - a * max;
  1243. return a * val[2] + b;
  1244. },
  1245. label: {
  1246. normal: {
  1247. // show: true,
  1248. // textStyle: {
  1249. // color: '#fff',
  1250. // fontSize: 9,
  1251. // }
  1252. }
  1253. },
  1254. itemStyle: {
  1255. normal: {
  1256. color: '#F62157', //标志颜色
  1257. }
  1258. },
  1259. zlevel: 6,
  1260. data: convertData(data),
  1261. },
  1262. {
  1263. name: 'light',
  1264. type: 'map',
  1265. mapType: 'hunan',
  1266. geoIndex: 0,
  1267. aspectScale: 0.75, //长宽比
  1268. showLegendSymbol: false, // 存在legend时显示
  1269. label: {
  1270. normal: {
  1271. show: false
  1272. },
  1273. emphasis: {
  1274. show: false,
  1275. textStyle: {
  1276. color: '#fff'
  1277. }
  1278. }
  1279. },
  1280. roam: true,
  1281. itemStyle: {
  1282. normal: {
  1283. areaColor: '#031525',
  1284. borderColor: '#FFFFFF',
  1285. },
  1286. emphasis: {
  1287. areaColor: '#2B91B7'
  1288. }
  1289. },
  1290. animation: false,
  1291. data: data
  1292. },
  1293. {
  1294. name: ' ',
  1295. type: 'effectScatter',
  1296. coordinateSystem: 'geo',
  1297. data: convertData(data.sort(function (a, b) {
  1298. return b.value - a.value;
  1299. }).slice(0, 5)),
  1300. symbolSize: function (val) {
  1301. return val[2] / 10;
  1302. },
  1303. showEffectOn: 'render',
  1304. rippleEffect: {
  1305. brushType: 'stroke'
  1306. },
  1307. hoverAnimation: true,
  1308. label: {
  1309. normal: {
  1310. formatter: '{b}',
  1311. position: 'right',
  1312. show: true
  1313. }
  1314. },
  1315. itemStyle: {
  1316. normal: {
  1317. color: '#05C3F9',
  1318. shadowBlur: 10,
  1319. shadowColor: '#05C3F9'
  1320. }
  1321. },
  1322. zlevel: 1
  1323. },
  1324. ]
  1325. });
  1326. }
  1327. showProvince();
  1328. // 使用刚指定的配置项和数据显示图表。
  1329. // myChart.setOption(option);
  1330. window.addEventListener("resize", function () {
  1331. myChart.resize();
  1332. });
  1333. }
  1334. //点击跳转
  1335. $('#chart_map').click(function(){
  1336. window.location.href = './page/index.html';
  1337. });
  1338. $('.t_btn2').click(function(){
  1339. window.location.href = "./page/index.html?id=2";
  1340. });
  1341. $('.t_btn3').click(function(){
  1342. window.location.href = "./page/index.html?id=3";
  1343. });
  1344. $('.t_btn4').click(function(){
  1345. window.location.href = "./page/index.html?id=4";
  1346. });
  1347. $('.t_btn5').click(function(){
  1348. window.location.href = "./page/index.html?id=5";
  1349. });
  1350. $('.t_btn6').click(function(){
  1351. window.location.href = "./page/index.html?id=6";
  1352. });
  1353. $('.t_btn7').click(function(){
  1354. window.location.href = "./page/index.html?id=7";
  1355. });
  1356. $('.t_btn8').click(function(){
  1357. window.location.href = "./page/index.html?id=8";
  1358. });
  1359. $('.t_btn9').click(function(){
  1360. window.location.href = "./page/index.html?id=9";
  1361. });
  1362. });