js.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  1. /* */
  2. $(window).load(function(){
  3. $(".loading").fadeOut()
  4. })
  5. $(function () {
  6. echarts_1();
  7. echarts_2();
  8. echarts_3();
  9. echarts_4();
  10. echarts_5();
  11. zb1();
  12. zb2();
  13. zb3();
  14. function echarts_1() {
  15. // 基于准备好的dom,初始化echarts实例
  16. var myChart = echarts.init(document.getElementById('echart1'));
  17. option = {
  18. tooltip : {
  19. trigger: 'item',
  20. formatter: "{b} : {c} ({d}%)"
  21. },
  22. legend: {
  23. right:0,
  24. top:30,
  25. height:160,
  26. itemWidth:10,
  27. itemHeight:10,
  28. itemGap:10,
  29. textStyle:{
  30. color: 'rgba(255,255,255,.6)',
  31. fontSize:12
  32. },
  33. orient:'vertical',
  34. data:['图例1','图例2','图例3','图例4','图例5']
  35. },
  36. calculable : true,
  37. series : [
  38. {
  39. name:' ',
  40. color: ['#62c98d', '#2f89cf', '#4cb9cf', '#53b666', '#62c98d', '#205acf', '#c9c862', '#c98b62', '#c962b9', '#7562c9','#c96262','#c25775','#00b7be'],
  41. type:'pie',
  42. radius : [30, 70],
  43. center : ['35%', '50%'],
  44. roseType : 'radius',
  45. label: {
  46. normal: {
  47. show: true
  48. },
  49. emphasis: {
  50. show: true
  51. }
  52. },
  53. lableLine: {
  54. normal: {
  55. show: true
  56. },
  57. emphasis: {
  58. show: true
  59. }
  60. },
  61. data:[
  62. {value:10, name:'图例1'},
  63. {value:5, name:'图例2'},
  64. {value:15, name:'图例3'},
  65. {value:25, name:'图例4'},
  66. {value:20, name:'图例5'},
  67. ]
  68. },
  69. ]
  70. };
  71. // 使用刚指定的配置项和数据显示图表。
  72. myChart.setOption(option);
  73. window.addEventListener("resize",function(){
  74. myChart.resize();
  75. });
  76. }
  77. /* */
  78. function echarts_2() {
  79. // 基于准备好的dom,初始化echarts实例
  80. var myChart = echarts.init(document.getElementById('echart2'));
  81. option = {
  82. tooltip: {
  83. trigger: 'item',
  84. formatter: "{b} : {c} ({d}%)"
  85. },
  86. legend: {
  87. top:'15%',
  88. data: ['图例1', '图例2', '图例3', '图例4', '图例5'],
  89. icon: 'circle',
  90. textStyle: {
  91. color: 'rgba(255,255,255,.6)',
  92. }
  93. },
  94. calculable: true,
  95. series: [{
  96. name: '',
  97. color: ['#62c98d', '#2f89cf', '#4cb9cf', '#53b666', '#62c98d', '#205acf', '#c9c862', '#c98b62', '#c962b9','#c96262'],
  98. type: 'pie',
  99. //起始角度,支持范围[0, 360]
  100. startAngle: 0,
  101. //饼图的半径,数组的第一项是内半径,第二项是外半径
  102. radius: [51, 100],
  103. //支持设置成百分比,设置成百分比时第一项是相对于容器宽度,第二项是相对于容器高度
  104. center: ['50%', '45%'],
  105. //是否展示成南丁格尔图,通过半径区分数据大小。可选择两种模式:
  106. // 'radius' 面积展现数据的百分比,半径展现数据的大小。
  107. // 'area' 所有扇区面积相同,仅通过半径展现数据大小
  108. roseType: 'area',
  109. //是否启用防止标签重叠策略,默认开启,圆环图这个例子中需要强制所有标签放在中心位置,可以将该值设为 false。
  110. avoidLabelOverlap: false,
  111. label: {
  112. normal: {
  113. show: true,
  114. // formatter: '{c}辆'
  115. },
  116. emphasis: {
  117. show: true
  118. }
  119. },
  120. labelLine: {
  121. normal: {
  122. show: true,
  123. length2: 1,
  124. },
  125. emphasis: {
  126. show: true
  127. }
  128. },
  129. data: [
  130. {value: 1,name: '图例1',},
  131. {value: 4,name: '图例2',},
  132. {value: 5,name: '图例3',},
  133. {value: 6,name: '图例4',},
  134. {value: 9,name: '图例5',},
  135. {value: 0, name: "",label: {show: false},labelLine: {show: false}},
  136. {value: 0, name: "",label: {show: false},labelLine: {show: false}},
  137. {value: 0, name: "",label: {show: false},labelLine: {show: false}},
  138. {value: 0, name: "",label: {show: false},labelLine: {show: false}},
  139. {value: 0, name: "",label: {show: false},labelLine: {show: false}},
  140. ]
  141. }]
  142. };
  143. // 使用刚指定的配置项和数据显示图表。
  144. myChart.setOption(option);
  145. window.addEventListener("resize",function(){
  146. myChart.resize();
  147. });
  148. }
  149. function echarts_3() {
  150. // 基于准备好的dom,初始化echarts实例
  151. var myChart = echarts.init(document.getElementById('echart3'));
  152. option = {
  153. tooltip: {
  154. trigger: 'axis',
  155. axisPointer: {
  156. lineStyle: {
  157. color: '#57617B'
  158. }
  159. }
  160. },
  161. legend: {
  162. //icon: 'vertical',
  163. data: ['销售额', '利润'],
  164. //align: 'center',
  165. // right: '35%',
  166. top:'0',
  167. textStyle: {
  168. color: "#fff"
  169. },
  170. // itemWidth: 15,
  171. // itemHeight: 15,
  172. itemGap: 20,
  173. },
  174. grid: {
  175. left: '0',
  176. right: '20',
  177. top:'10',
  178. bottom: '20',
  179. containLabel: true
  180. },
  181. xAxis: [{
  182. type: 'category',
  183. boundaryGap: false,
  184. axisLabel: {
  185. show: true,
  186. textStyle: {
  187. color: 'rgba(255,255,255,.6)'
  188. }
  189. },
  190. axisLine: {
  191. lineStyle: {
  192. color: 'rgba(255,255,255,.1)'
  193. }
  194. },
  195. data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
  196. }, {
  197. }],
  198. yAxis: [{
  199. axisLabel: {
  200. show: true,
  201. textStyle: {
  202. color: 'rgba(255,255,255,.6)'
  203. }
  204. },
  205. axisLine: {
  206. lineStyle: {
  207. color: 'rgba(255,255,255,.1)'
  208. }
  209. },
  210. splitLine: {
  211. lineStyle: {
  212. color: 'rgba(255,255,255,.1)'
  213. }
  214. }
  215. }],
  216. series: [{
  217. name: '销售额',
  218. type: 'line',
  219. smooth: true,
  220. symbol: 'circle',
  221. symbolSize: 5,
  222. showSymbol: false,
  223. lineStyle: {
  224. normal: {
  225. width: 2
  226. }
  227. },
  228. areaStyle: {
  229. normal: {
  230. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  231. offset: 0,
  232. color: 'rgba(24, 163, 64, 0.3)'
  233. }, {
  234. offset: 0.8,
  235. color: 'rgba(24, 163, 64, 0)'
  236. }], false),
  237. shadowColor: 'rgba(0, 0, 0, 0.1)',
  238. shadowBlur: 10
  239. }
  240. },
  241. itemStyle: {
  242. normal: {
  243. color: '#cdba00',
  244. borderColor: 'rgba(137,189,2,0.27)',
  245. borderWidth: 12
  246. }
  247. },
  248. data: [220, 182, 191, 134, 150, 120, 110, 125, 145, 122, 165, 122]
  249. }, {
  250. name: '利润',
  251. type: 'line',
  252. smooth: true,
  253. symbol: 'circle',
  254. symbolSize: 5,
  255. showSymbol: false,
  256. lineStyle: {
  257. normal: {
  258. width: 2
  259. }
  260. },
  261. areaStyle: {
  262. normal: {
  263. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  264. offset: 0,
  265. color: 'rgba(39, 122,206, 0.3)'
  266. }, {
  267. offset: 0.8,
  268. color: 'rgba(39, 122,206, 0)'
  269. }], false),
  270. shadowColor: 'rgba(0, 0, 0, 0.1)',
  271. shadowBlur: 10
  272. }
  273. },
  274. itemStyle: {
  275. normal: {
  276. color: '#277ace',
  277. borderColor: 'rgba(0,136,212,0.2)',
  278. borderWidth: 12
  279. }
  280. },
  281. data: [120, 110, 125, 145, 122, 165, 122, 220, 182, 191, 134, 150]
  282. }]
  283. };
  284. // 使用刚指定的配置项和数据显示图表。
  285. myChart.setOption(option);
  286. window.addEventListener("resize",function(){
  287. myChart.resize();
  288. });
  289. }
  290. function echarts_4() {
  291. // 基于准备好的dom,初始化echarts实例
  292. var myChart = echarts.init(document.getElementById('echart4'));
  293. option = {
  294. tooltip: {
  295. trigger: 'axis',
  296. axisPointer: {
  297. lineStyle: {
  298. color: '#57617B'
  299. }
  300. }
  301. },
  302. "legend": {
  303. "data": [
  304. {"name": "图例1"},
  305. {"name": "图例2"},
  306. {"name": "完成率"}
  307. ],
  308. "top": "0%",
  309. "textStyle": {
  310. "color": "rgba(255,255,255,0.9)"//图例文字
  311. }
  312. },
  313. "xAxis": [
  314. {
  315. "type": "category",
  316. data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
  317. axisLine: { lineStyle: {color: "rgba(255,255,255,.1)"}},
  318. axisLabel: { textStyle: {color: "rgba(255,255,255,.6)", fontSize: '14', },
  319. },
  320. },
  321. ],
  322. "yAxis": [
  323. {
  324. "type": "value",
  325. "name": "金额",
  326. "min": 0,
  327. "max": 50,
  328. "interval": 10,
  329. "axisLabel": {
  330. "show": true,
  331. },
  332. axisLine: {lineStyle: {color: 'rgba(255,255,255,.4)'}},//左线色
  333. },
  334. {
  335. "type": "value",
  336. "name": "完成率",
  337. "show": true,
  338. "axisLabel": {
  339. "show": true,
  340. },
  341. axisLine: {lineStyle: {color: 'rgba(255,255,255,.4)'}},//右线色
  342. splitLine: {show:true,lineStyle: {color:"#001e94"}},//x轴线
  343. },
  344. ],
  345. "grid": {
  346. "top": "10%",
  347. "right":"30",
  348. "bottom":"30",
  349. "left":"30",
  350. },
  351. "series": [
  352. {
  353. "name": "图例1",
  354. "type": "bar",
  355. "data": [4,6,36,6,8,6,4,6,30,6,8,12],
  356. "barWidth": "auto",
  357. "itemStyle": {
  358. "normal": {
  359. "color": {
  360. "type": "linear",
  361. "x": 0,
  362. "y": 0,
  363. "x2": 0,
  364. "y2": 1,
  365. "colorStops": [
  366. {
  367. "offset": 0,
  368. "color": "#609db8"
  369. },
  370. {
  371. "offset": 1,
  372. "color": "#609db8"
  373. }
  374. ],
  375. "globalCoord": false
  376. }
  377. }
  378. }
  379. },
  380. {
  381. "name": "图例2",
  382. "type": "bar",
  383. "data": [
  384. 4,2,34,6,8,6,4,2,32,6,8,18
  385. ],
  386. "barWidth": "auto",
  387. "itemStyle": {
  388. "normal": {
  389. "color": {
  390. "type": "linear",
  391. "x": 0,
  392. "y": 0,
  393. "x2": 0,
  394. "y2": 1,
  395. "colorStops": [
  396. {
  397. "offset": 0,
  398. "color": "#66b8a7"
  399. },
  400. {
  401. "offset": 1,
  402. "color": "#66b8a7"
  403. }
  404. ],
  405. "globalCoord": false
  406. }
  407. }
  408. },
  409. "barGap": "0"
  410. },
  411. {
  412. "name": "完成率",
  413. "type": "line",
  414. "yAxisIndex": 1,
  415. "data": [100,50,80,30,90,40, 70,33,100,40,80,20],
  416. lineStyle: {
  417. normal: {
  418. width: 2
  419. },
  420. },
  421. "itemStyle": {
  422. "normal": {
  423. "color": "#cdba00",
  424. }
  425. },
  426. "smooth": true
  427. }
  428. ]
  429. };
  430. // 使用刚指定的配置项和数据显示图表。
  431. myChart.setOption(option);
  432. window.addEventListener("resize",function(){
  433. myChart.resize();
  434. });
  435. }
  436. function echarts_5() {
  437. // 基于准备好的dom,初始化echarts实例
  438. var myChart = echarts.init(document.getElementById('echart5'));
  439. // 颜色
  440. var lightBlue = {
  441. type: 'linear',
  442. x: 0,
  443. y: 0,
  444. x2: 0,
  445. y2: 1,
  446. colorStops: [{
  447. offset: 0,
  448. color: 'rgba(41, 121, 255, 1)'
  449. }, {
  450. offset: 1,
  451. color: 'rgba(0, 192, 255, 1)'
  452. }],
  453. globalCoord: false
  454. }
  455. var option = {
  456. tooltip: {
  457. show: false
  458. },
  459. grid: {
  460. top: '0%',
  461. left: '65',
  462. right: '14%',
  463. bottom: '0%',
  464. },
  465. xAxis: {
  466. min: 0,
  467. max: 100,
  468. splitLine: {
  469. show: false
  470. },
  471. axisTick: {
  472. show: false
  473. },
  474. axisLine: {
  475. show: false
  476. },
  477. axisLabel: {
  478. show: false
  479. }
  480. },
  481. yAxis: {
  482. data: ['字段名称', '字段名称', '字段名称','字段名称','字段名称','字段名称','字段名称','字段名称','字段名称','字段名称','字段名称'],
  483. //offset: 15,
  484. axisTick: {
  485. show: false
  486. },
  487. axisLine: {
  488. show: false
  489. },
  490. axisLabel: {
  491. color: 'rgba(255,255,255,.6)',
  492. fontSize: 14
  493. }
  494. },
  495. series: [{
  496. type: 'bar',
  497. label: {
  498. show: true,
  499. zlevel: 10000,
  500. position: 'right',
  501. padding: 10,
  502. color: '#49bcf7',
  503. fontSize: 14,
  504. formatter: '{c}%'
  505. },
  506. itemStyle: {
  507. color:'#49bcf7'
  508. },
  509. barWidth: '15',
  510. data: [49, 80, 67, 99, 12, 19, 39, 84, 28, 47, 57, 100],
  511. z: 10
  512. }, {
  513. type: 'bar',
  514. barGap: '-100%',
  515. itemStyle: {
  516. color:'#fff',
  517. opacity: 0.1
  518. },
  519. barWidth: '15',
  520. data: [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],
  521. z: 5
  522. }],
  523. };
  524. // 使用刚指定的配置项和数据显示图表。
  525. myChart.setOption(option);
  526. window.addEventListener("resize",function(){
  527. myChart.resize();
  528. });
  529. }
  530. function zb1() {
  531. // 基于准备好的dom,初始化echarts实例
  532. var myChart = echarts.init(document.getElementById('zb1'));
  533. var v1=298//男消费
  534. var v2=523//女消费
  535. var v3=v1+v2//总消费
  536. option = {
  537. series: [{
  538. type: 'pie',
  539. radius: ['60%', '70%'],
  540. color:'#49bcf7',
  541. label: {
  542. normal: {
  543. position: 'center'
  544. }
  545. },
  546. data: [{
  547. value: v2,
  548. name: '女消费',
  549. label: {
  550. normal: {
  551. formatter: v2 +'',
  552. textStyle: {
  553. fontSize: 20,
  554. color:'#fff',
  555. }
  556. }
  557. }
  558. }, {
  559. value: v1,
  560. name: '男消费',
  561. label: {
  562. normal: {
  563. formatter : function (params){
  564. return '占比'+Math.round( v2/v3*100)+ '%'
  565. },
  566. textStyle: {
  567. color: '#aaa',
  568. fontSize: 12
  569. }
  570. }
  571. },
  572. itemStyle: {
  573. normal: {
  574. color: 'rgba(255,255,255,.2)'
  575. },
  576. emphasis: {
  577. color: '#fff'
  578. }
  579. },
  580. }]
  581. }]
  582. };
  583. myChart.setOption(option);
  584. window.addEventListener("resize",function(){
  585. myChart.resize();
  586. });
  587. }
  588. function zb2() {
  589. // 基于准备好的dom,初始化echarts实例
  590. var myChart = echarts.init(document.getElementById('zb2'));
  591. var v1=298//男消费
  592. var v2=523//女消费
  593. var v3=v1+v2//总消费
  594. option = {
  595. //animation: false,
  596. series: [{
  597. type: 'pie',
  598. radius: ['60%', '70%'],
  599. color:'#cdba00',
  600. label: {
  601. normal: {
  602. position: 'center'
  603. }
  604. },
  605. data: [{
  606. value: v1,
  607. name: '男消费',
  608. label: {
  609. normal: {
  610. formatter: v1 +'',
  611. textStyle: {
  612. fontSize: 20,
  613. color:'#fff',
  614. }
  615. }
  616. }
  617. }, {
  618. value: v2,
  619. name: '女消费',
  620. label: {
  621. normal: {
  622. formatter : function (params){
  623. return '占比'+Math.round( v1/v3*100)+ '%'
  624. },
  625. textStyle: {
  626. color: '#aaa',
  627. fontSize: 12
  628. }
  629. }
  630. },
  631. itemStyle: {
  632. normal: {
  633. color: 'rgba(255,255,255,.2)'
  634. },
  635. emphasis: {
  636. color: '#fff'
  637. }
  638. },
  639. }]
  640. }]
  641. };
  642. myChart.setOption(option);
  643. window.addEventListener("resize",function(){
  644. myChart.resize();
  645. });
  646. }
  647. /* */
  648. function zb3() {
  649. // 基于准备好的dom,初始化echarts实例
  650. var myChart = echarts.init(document.getElementById('zb3'));
  651. var v1=298//男消费
  652. var v2=523//女消费
  653. var v3=v1+v2//总消费
  654. option = {
  655. series: [{
  656. type: 'pie',
  657. radius: ['60%', '70%'],
  658. color:'#62c98d',
  659. label: {
  660. normal: {
  661. position: 'center'
  662. }
  663. },
  664. data: [{
  665. value: v2,
  666. name: '女消费',
  667. label: {
  668. normal: {
  669. formatter: v2 +'',
  670. textStyle: {
  671. fontSize: 20,
  672. color:'#fff',
  673. }
  674. }
  675. }
  676. }, {
  677. value: v1,
  678. name: '男消费',
  679. label: {
  680. normal: {
  681. formatter : function (params){
  682. return '占比'+Math.round( v2/v3*100)+ '%'
  683. },
  684. textStyle: {
  685. color: '#aaa',
  686. fontSize: 12
  687. }
  688. }
  689. },
  690. itemStyle: {
  691. normal: {
  692. color: 'rgba(255,255,255,.2)'
  693. },
  694. emphasis: {
  695. color: '#fff'
  696. }
  697. },
  698. }]
  699. }]
  700. };
  701. myChart.setOption(option);
  702. window.addEventListener("resize",function(){
  703. myChart.resize();
  704. });
  705. }
  706. })