echarts.js 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128
  1. $(function () {
  2. echarts_1();
  3. echarts_2();
  4. map();
  5. echarts_3();
  6. echarts_4();
  7. echarts_5();
  8. echarts_6();
  9. function echarts_1() {
  10. // 基于准备好的dom,初始化echarts实例
  11. var myChart = echarts.init(document.getElementById('echarts_1'));
  12. var data = [
  13. {value: 12,name: '行业一'},
  14. {value: 13,name: '行业二'},
  15. {value: 70,name: '行业三'},
  16. {value: 52,name: '行业四'},
  17. {value: 35,name: '行业五'}
  18. ];
  19. option = {
  20. backgroundColor: 'rgba(0,0,0,0)',
  21. tooltip: {
  22. trigger: 'item',
  23. formatter: "{b}: <br/>{c} ({d}%)"
  24. },
  25. color: ['#af89d6', '#4ac7f5', '#0089ff', '#f36f8a', '#f5c847'],
  26. legend: { //图例组件,颜色和名字
  27. x: '70%',
  28. y: 'center',
  29. orient: 'vertical',
  30. itemGap: 12, //图例每项之间的间隔
  31. itemWidth: 10,
  32. itemHeight: 10,
  33. icon: 'rect',
  34. data: ['行业一', '行业二', '行业三', '行业四', '行业五'],
  35. textStyle: {
  36. color: [],
  37. fontStyle: 'normal',
  38. fontFamily: '微软雅黑',
  39. fontSize: 12,
  40. }
  41. },
  42. series: [{
  43. name: '行业占比',
  44. type: 'pie',
  45. clockwise: false, //饼图的扇区是否是顺时针排布
  46. minAngle: 20, //最小的扇区角度(0 ~ 360)
  47. center: ['35%', '50%'], //饼图的中心(圆心)坐标
  48. radius: [50, 75], //饼图的半径
  49. avoidLabelOverlap: true, ////是否启用防止标签重叠
  50. itemStyle: { //图形样式
  51. normal: {
  52. borderColor: '#1e2239',
  53. borderWidth: 2,
  54. },
  55. },
  56. label: { //标签的位置
  57. normal: {
  58. show: true,
  59. position: 'inside', //标签的位置
  60. formatter: "{d}%",
  61. textStyle: {
  62. color: '#fff',
  63. }
  64. },
  65. emphasis: {
  66. show: true,
  67. textStyle: {
  68. fontWeight: 'bold'
  69. }
  70. }
  71. },
  72. data: data
  73. }, {
  74. name: '',
  75. type: 'pie',
  76. clockwise: false,
  77. silent: true,
  78. minAngle: 20, //最小的扇区角度(0 ~ 360)
  79. center: ['35%', '50%'], //饼图的中心(圆心)坐标
  80. radius: [0, 40], //饼图的半径
  81. itemStyle: { //图形样式
  82. normal: {
  83. borderColor: '#1e2239',
  84. borderWidth: 1.5,
  85. opacity: 0.21,
  86. }
  87. },
  88. label: { //标签的位置
  89. normal: {
  90. show: false,
  91. }
  92. },
  93. data: data
  94. }]
  95. };
  96. // 使用刚指定的配置项和数据显示图表。
  97. myChart.setOption(option);
  98. window.addEventListener("resize",function(){
  99. myChart.resize();
  100. });
  101. }
  102. function echarts_2() {
  103. // 基于准备好的dom,初始化echarts实例
  104. var myChart = echarts.init(document.getElementById('echarts_2'));
  105. option = {
  106. backgroundColor: 'rgba(0,0,0,0)',
  107. tooltip: {
  108. trigger: 'item',
  109. formatter: "{b} <br/>{c}辆"
  110. },
  111. legend: {
  112. x: 'center',
  113. y: '2%',
  114. data: ['车型一', '车型二', '车型三', '车型四', '车型五'],
  115. icon: 'circle',
  116. textStyle: {
  117. color: '#fff',
  118. }
  119. },
  120. calculable: true,
  121. series: [{
  122. name: '车型',
  123. type: 'pie',
  124. //起始角度,支持范围[0, 360]
  125. startAngle: 0,
  126. //饼图的半径,数组的第一项是内半径,第二项是外半径
  127. radius: [41, 110],
  128. //支持设置成百分比,设置成百分比时第一项是相对于容器宽度,第二项是相对于容器高度
  129. center: ['50%', '20%'],
  130. //是否展示成南丁格尔图,通过半径区分数据大小。可选择两种模式:
  131. // 'radius' 面积展现数据的百分比,半径展现数据的大小。
  132. // 'area' 所有扇区面积相同,仅通过半径展现数据大小
  133. roseType: 'area',
  134. //是否启用防止标签重叠策略,默认开启,圆环图这个例子中需要强制所有标签放在中心位置,可以将该值设为 false。
  135. avoidLabelOverlap: false,
  136. label: {
  137. normal: {
  138. show: true,
  139. formatter: '{c}辆'
  140. },
  141. emphasis: {
  142. show: true
  143. }
  144. },
  145. labelLine: {
  146. normal: {
  147. show: true,
  148. length2: 1,
  149. },
  150. emphasis: {
  151. show: true
  152. }
  153. },
  154. data: [{
  155. value: 600,
  156. name: '车型一',
  157. itemStyle: {
  158. normal: {
  159. color: '#f845f1'
  160. }
  161. }
  162. },
  163. {
  164. value: 1100,
  165. name: '车型二',
  166. itemStyle: {
  167. normal: {
  168. color: '#ad46f3'
  169. }
  170. }
  171. },
  172. {
  173. value: 1200,
  174. name: '车型三',
  175. itemStyle: {
  176. normal: {
  177. color: '#5045f6'
  178. }
  179. }
  180. },
  181. {
  182. value: 1300,
  183. name: '车型四',
  184. itemStyle: {
  185. normal: {
  186. color: '#4777f5'
  187. }
  188. }
  189. },
  190. {
  191. value: 1400,
  192. name: '车型五',
  193. itemStyle: {
  194. normal: {
  195. color: '#44aff0'
  196. }
  197. }
  198. },
  199. {
  200. value: 0,
  201. name: "",
  202. label: {
  203. show: false
  204. },
  205. labelLine: {
  206. show: false
  207. }
  208. },
  209. {
  210. value: 0,
  211. name: "",
  212. label: {
  213. show: false
  214. },
  215. labelLine: {
  216. show: false
  217. }
  218. },
  219. {
  220. value: 0,
  221. name: "",
  222. label: {
  223. show: false
  224. },
  225. labelLine: {
  226. show: false
  227. }
  228. },
  229. {
  230. value: 0,
  231. name: "",
  232. label: {
  233. show: false
  234. },
  235. labelLine: {
  236. show: false
  237. }
  238. },
  239. {
  240. value: 0,
  241. name: "",
  242. label: {
  243. show: false
  244. },
  245. labelLine: {
  246. show: false
  247. }
  248. }
  249. ]
  250. }]
  251. };
  252. // 使用刚指定的配置项和数据显示图表。
  253. myChart.setOption(option);
  254. window.addEventListener("resize",function(){
  255. myChart.resize();
  256. });
  257. }
  258. function map() {
  259. // 基于准备好的dom,初始化echarts实例
  260. var myChart = echarts.init(document.getElementById('map'));
  261. var nameColor = " rgb(55, 75, 113)"
  262. var name_fontFamily = '宋体'
  263. var name_fontSize = 35
  264. var mapName = 'china'
  265. var data = []
  266. var geoCoordMap = {};
  267. var toolTipData = [];
  268. /*获取地图数据*/
  269. myChart.showLoading();
  270. var mapFeatures = echarts.getMap(mapName).geoJson.features;
  271. myChart.hideLoading();
  272. mapFeatures.forEach(function(v) {
  273. // 地区名称
  274. var name = v.properties.name;
  275. // 地区经纬度
  276. geoCoordMap[name] = v.properties.cp;
  277. data.push({
  278. name: name,
  279. value: Math.round(Math.random() * 100 + 10)
  280. })
  281. toolTipData.push({
  282. name: name,
  283. value: [{
  284. name: "车型一",
  285. value: Math.round(Math.random() * 100 + 10) + '辆'
  286. },
  287. {
  288. name: "车型二",
  289. value: Math.round(Math.random() * 100 + 10)+ '辆'
  290. },
  291. {
  292. name: "车型三",
  293. value: Math.round(Math.random() * 100 + 10)+ '辆'
  294. },
  295. {
  296. name: "车型四",
  297. value: Math.round(Math.random() * 100 + 10)+ '辆'
  298. }
  299. ]
  300. })
  301. });
  302. var max = 480,
  303. min = 9; // todo
  304. var maxSize4Pin = 50,
  305. minSize4Pin = 20;
  306. var convertData = function(data) {
  307. var res = [];
  308. for (var i = 0; i < data.length; i++) {
  309. var geoCoord = geoCoordMap[data[i].name];
  310. if (geoCoord) {
  311. res.push({
  312. name: data[i].name,
  313. value: geoCoord.concat(data[i].value),
  314. });
  315. }
  316. }
  317. return res;
  318. };
  319. option = {
  320. tooltip: {
  321. trigger: 'item',
  322. formatter: function(params) {
  323. if (typeof(params.value)[2] == "undefined") {
  324. var toolTiphtml = ''
  325. for(var i = 0;i<toolTipData.length;i++){
  326. if(params.name==toolTipData[i].name){
  327. toolTiphtml += toolTipData[i].name+':<br>'
  328. for(var j = 0;j<toolTipData[i].value.length;j++){
  329. toolTiphtml+=toolTipData[i].value[j].name+':'+toolTipData[i].value[j].value+"<br>"
  330. }
  331. }
  332. }
  333. console.log(toolTiphtml)
  334. // console.log(convertData(data))
  335. return toolTiphtml;
  336. } else {
  337. var toolTiphtml = ''
  338. for(var i = 0;i<toolTipData.length;i++){
  339. if(params.name==toolTipData[i].name){
  340. toolTiphtml += toolTipData[i].name+':<br>'
  341. for(var j = 0;j<toolTipData[i].value.length;j++){
  342. toolTiphtml+=toolTipData[i].value[j].name+':'+toolTipData[i].value[j].value+"<br>"
  343. }
  344. }
  345. }
  346. console.log(toolTiphtml)
  347. // console.log(convertData(data))
  348. return toolTiphtml;
  349. }
  350. }
  351. },
  352. legend: {
  353. orient: 'vertical',
  354. y: 'bottom',
  355. x: 'right',
  356. data: ['credit_pm2.5'],
  357. textStyle: {
  358. color: '#fff'
  359. }
  360. },
  361. visualMap: {
  362. show: false,
  363. min: 0,
  364. max: 600,
  365. left: 'left',
  366. top: 'bottom',
  367. text: ['高', '低'], // 文本,默认为数值文本
  368. calculable: true,
  369. seriesIndex: [1],
  370. inRange: {
  371. // color: ['#3B5077', '#031525'] // 蓝黑
  372. // color: ['#ffc0cb', '#800080'] // 红紫
  373. // color: ['#3C3B3F', '#605C3C'] // 黑绿
  374. // color: ['#0f0c29', '#302b63', '#24243e'] // 黑紫黑
  375. // color: ['#23074d', '#cc5333'] // 紫红
  376. // color: ['#00467F', '#A5CC82'] // 蓝绿
  377. // color: ['#1488CC', '#2B32B2'] // 浅蓝
  378. // color: ['#00467F', '#A5CC82','#ffc0cb'] // 蓝绿红
  379. // color: ['#00467F', '#A5CC82'] // 蓝绿
  380. // color: ['#00467F', '#A5CC82'] // 蓝绿
  381. // color: ['#00467F', '#A5CC82'] // 蓝绿
  382. color: ['#22e5e8', '#0035f9','#22e5e8'] // 蓝绿
  383. }
  384. },
  385. /*工具按钮组*/
  386. toolbox: {
  387. show: false,
  388. orient: 'vertical',
  389. left: 'right',
  390. top: 'center',
  391. feature: {
  392. dataView: {
  393. readOnly: false
  394. },
  395. restore: {},
  396. saveAsImage: {}
  397. }
  398. },
  399. geo: {
  400. show: true,
  401. map: mapName,
  402. label: {
  403. normal: {
  404. show: false
  405. },
  406. emphasis: {
  407. show: false
  408. }
  409. },
  410. roam: true,
  411. itemStyle: {
  412. normal: {
  413. areaColor: '#031525',
  414. borderColor: '#097bba'
  415. },
  416. emphasis: {
  417. areaColor: '#2B91B7'
  418. }
  419. }
  420. },
  421. series: [{
  422. name: '散点',
  423. type: 'scatter',
  424. coordinateSystem: 'geo',
  425. data: convertData(data),
  426. symbolSize: function(val) {
  427. return val[2] / 10;
  428. },
  429. label: {
  430. normal: {
  431. formatter: '{b}',
  432. position: 'right',
  433. show: false
  434. },
  435. emphasis: {
  436. show: false
  437. }
  438. },
  439. itemStyle: {
  440. normal: {
  441. color: 'rgba(255,255,0,0.8)'
  442. }
  443. }
  444. },
  445. {
  446. type: 'map',
  447. map: mapName,
  448. geoIndex: 0,
  449. aspectScale: 0.75, //长宽比
  450. showLegendSymbol: false, // 存在legend时显示
  451. label: {
  452. normal: {
  453. show: true
  454. },
  455. emphasis: {
  456. show: false,
  457. textStyle: {
  458. color: '#fff'
  459. }
  460. }
  461. },
  462. roam: true,
  463. itemStyle: {
  464. normal: {
  465. areaColor: '#031525',
  466. borderColor: '#3B5077',
  467. },
  468. emphasis: {
  469. areaColor: '#2B91B7'
  470. }
  471. },
  472. animation: false,
  473. data: data
  474. },
  475. {
  476. name: '点',
  477. type: 'scatter',
  478. coordinateSystem: 'geo',
  479. symbol: 'pin', //气泡
  480. symbolSize: function(val) {
  481. var a = (maxSize4Pin - minSize4Pin) / (max - min);
  482. var b = minSize4Pin - a * min;
  483. b = maxSize4Pin - a * max;
  484. return a * val[2] + b;
  485. },
  486. label: {
  487. normal: {
  488. show: false,
  489. formatter:function (params) { return params.data.value[2] },
  490. textStyle: {
  491. color: '#fff',
  492. fontSize: 9,
  493. }
  494. }
  495. },
  496. itemStyle: {
  497. normal: {
  498. color: 'rgba(255,255,0,0)', //标志颜色
  499. }
  500. },
  501. zlevel: 6,
  502. data: convertData(data),
  503. },
  504. {
  505. name: 'Top 5',
  506. type: 'effectScatter',
  507. coordinateSystem: 'geo',
  508. data: convertData(data.sort(function(a, b) {
  509. return b.value - a.value;
  510. }).slice(0, 5)),
  511. symbolSize: function(val) {
  512. return val[2] / 10;
  513. },
  514. showEffectOn: 'render',
  515. rippleEffect: {
  516. brushType: 'stroke'
  517. },
  518. hoverAnimation: true,
  519. label: {
  520. normal: {
  521. formatter: '{b}',
  522. position: 'right',
  523. show: true
  524. }
  525. },
  526. itemStyle: {
  527. normal: {
  528. color: 'rgba(255,255,0,0.8)',
  529. shadowBlur: 10,
  530. shadowColor: '#05C3F9'
  531. }
  532. },
  533. zlevel: 1
  534. },
  535. ]
  536. };
  537. // 使用刚指定的配置项和数据显示图表。
  538. myChart.setOption(option);
  539. window.addEventListener("resize",function(){
  540. myChart.resize();
  541. });
  542. }
  543. function echarts_3() {
  544. // 基于准备好的dom,初始化echarts实例
  545. var myChart = echarts.init(document.getElementById('echarts_3'));
  546. option = {
  547. tooltip : {
  548. trigger: 'axis'
  549. },
  550. legend: {
  551. orient: 'vertical',
  552. data:['简易程序案件数']
  553. },
  554. grid: {
  555. left: '3%',
  556. right: '3%',
  557. top:'8%',
  558. bottom: '5%',
  559. containLabel: true
  560. },
  561. color:['#a4d8cc','#25f3e6'],
  562. toolbox: {
  563. show : false,
  564. feature : {
  565. mark : {show: true},
  566. dataView : {show: true, readOnly: false},
  567. magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
  568. restore : {show: true},
  569. saveAsImage : {show: true}
  570. }
  571. },
  572. calculable : true,
  573. xAxis : [
  574. {
  575. type : 'category',
  576. axisTick:{show:false},
  577. boundaryGap : false,
  578. axisLabel: {
  579. textStyle:{
  580. color: '#ccc',
  581. fontSize:'12'
  582. },
  583. lineStyle:{
  584. color:'#2c3459',
  585. },
  586. interval: {default: 0},
  587. rotate:50,
  588. formatter : function(params){
  589. var newParamsName = "";// 最终拼接成的字符串
  590. var paramsNameNumber = params.length;// 实际标签的个数
  591. var provideNumber = 4;// 每行能显示的字的个数
  592. var rowNumber = Math.ceil(paramsNameNumber / provideNumber);// 换行的话,需要显示几行,向上取整
  593. /**
  594. * 判断标签的个数是否大于规定的个数, 如果大于,则进行换行处理 如果不大于,即等于或小于,就返回原标签
  595. */
  596. // 条件等同于rowNumber>1
  597. if (paramsNameNumber > provideNumber) {
  598. /** 循环每一行,p表示行 */
  599. var tempStr = "";
  600. tempStr=params.substring(0,4);
  601. newParamsName = tempStr+"...";// 最终拼成的字符串
  602. } else {
  603. // 将旧标签的值赋给新标签
  604. newParamsName = params;
  605. }
  606. //将最终的字符串返回
  607. return newParamsName
  608. }
  609. },
  610. data: ['0时','1时','2时','3时','4时','5时','6时','7时','8时','9时','10时','11时','12时','13时','14时','15时','16时','17时'
  611. ,'18时','19时','20时','21时','22时','23时']
  612. }
  613. ],
  614. yAxis : {
  615. type : 'value',
  616. axisLabel: {
  617. textStyle: {
  618. color: '#ccc',
  619. fontSize:'12',
  620. }
  621. },
  622. axisLine: {
  623. lineStyle:{
  624. color:'rgba(160,160,160,0.3)',
  625. }
  626. },
  627. splitLine: {
  628. lineStyle:{
  629. color:'rgba(160,160,160,0.3)',
  630. }
  631. },
  632. }
  633. ,
  634. series : [
  635. {
  636. // name:'简易程序案件数',
  637. type:'line',
  638. areaStyle: {
  639. normal: {type: 'default',
  640. color: new echarts.graphic.LinearGradient(0, 0, 0, 0.8, [{
  641. offset: 0,
  642. color: '#25f3e6'
  643. }, {
  644. offset: 1,
  645. color: '#0089ff'
  646. }], false)
  647. }
  648. },
  649. smooth:true,
  650. itemStyle: {
  651. normal: {areaStyle: {type: 'default'}}
  652. },
  653. data:[710, 312, 321,754, 500, 830, 710, 521, 504, 660, 530, 410,710, 312, 321,754, 500, 830, 710, 521, 504, 660, 530, 410]
  654. }
  655. ]
  656. };
  657. // 使用刚指定的配置项和数据显示图表。
  658. myChart.setOption(option);
  659. window.addEventListener("resize",function(){
  660. myChart.resize();
  661. });
  662. }
  663. function echarts_4() {
  664. // 基于准备好的dom,初始化echarts实例
  665. var myChart = echarts.init(document.getElementById('echarts_4'));
  666. option = {
  667. tooltip : {
  668. trigger: 'item',
  669. formatter: "{b}: <br/> {c} ({d}%)"
  670. },
  671. toolbox: {
  672. show : false,
  673. feature : {
  674. mark : {show: true},
  675. dataView : {show: true, readOnly: false},
  676. magicType : {
  677. show: true,
  678. type: ['pie', 'funnel']
  679. },
  680. restore : {show: true},
  681. saveAsImage : {show: true}
  682. }
  683. },
  684. calculable : true,
  685. series : [
  686. {
  687. name:'排名',
  688. type:'pie',
  689. color: ['#af89d6', '#f5c847', '#ff999a', '#0089ff','#25f3e6'],
  690. radius : [20, 100],
  691. center : ['50%', '50%'],
  692. roseType : 'area',
  693. data:[
  694. {value:70, name:'NO.4'},
  695. {value:90, name:'NO.3'},
  696. {value:110, name:'NO.2'},
  697. {value:150, name:'NO.1'},
  698. {value:40, name:'NO.5'}
  699. ]
  700. }
  701. ]
  702. };
  703. // 使用刚指定的配置项和数据显示图表。
  704. myChart.setOption(option);
  705. window.addEventListener("resize",function(){
  706. myChart.resize();
  707. });
  708. }
  709. function echarts_5() {
  710. // 基于准备好的dom,初始化echarts实例
  711. var myChart = echarts.init(document.getElementById('echarts_5'));
  712. var xData = function() {
  713. var data = ['NO.1','NO.2','NO.3','NO.4','NO.5'];
  714. return data;
  715. }();
  716. var data = [28, 22, 20, 16, 12]
  717. option = {
  718. // backgroundColor: "#141f56",
  719. tooltip: {
  720. show: "true",
  721. trigger: 'item',
  722. backgroundColor: 'rgba(0,0,0,0.4)', // 背景
  723. padding: [8, 10], //内边距
  724. // extraCssText: 'box-shadow: 0 0 3px rgba(255, 255, 255, 0.4);', //添加阴影
  725. formatter: function(params) {
  726. if (params.seriesName != "") {
  727. return params.name + ' : ' + params.value + ' 辆';
  728. }
  729. },
  730. },
  731. grid: {
  732. borderWidth: 0,
  733. top: 20,
  734. bottom: 35,
  735. left:55,
  736. right:30,
  737. textStyle: {
  738. color: "#fff"
  739. }
  740. },
  741. xAxis: [{
  742. type: 'category',
  743. axisTick: {
  744. show: false
  745. },
  746. axisLine: {
  747. show: true,
  748. lineStyle: {
  749. color: '#363e83',
  750. }
  751. },
  752. axisLabel: {
  753. inside: false,
  754. textStyle: {
  755. color: '#bac0c0',
  756. fontWeight: 'normal',
  757. fontSize: '12',
  758. },
  759. // formatter:function(val){
  760. // return val.split("").join("\n")
  761. // },
  762. },
  763. data: xData,
  764. }, {
  765. type: 'category',
  766. axisLine: {
  767. show: false
  768. },
  769. axisTick: {
  770. show: false
  771. },
  772. axisLabel: {
  773. show: false
  774. },
  775. splitArea: {
  776. show: false
  777. },
  778. splitLine: {
  779. show: false
  780. },
  781. data: xData,
  782. }],
  783. yAxis: {
  784. type: 'value',
  785. axisTick: {
  786. show: false
  787. },
  788. axisLine: {
  789. show: true,
  790. lineStyle: {
  791. color: '#32346c',
  792. }
  793. },
  794. splitLine: {
  795. show: true,
  796. lineStyle: {
  797. color: '#32346c ',
  798. }
  799. },
  800. axisLabel: {
  801. textStyle: {
  802. color: '#bac0c0',
  803. fontWeight: 'normal',
  804. fontSize: '12',
  805. },
  806. formatter: '{value}',
  807. },
  808. },
  809. series: [{
  810. // name: '生师比(%)',
  811. type: 'bar',
  812. itemStyle: {
  813. normal: {
  814. show: true,
  815. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  816. offset: 0,
  817. color: '#00c0e9'
  818. }, {
  819. offset: 1,
  820. color: '#3b73cf'
  821. }]),
  822. barBorderRadius: 50,
  823. borderWidth: 0,
  824. },
  825. emphasis: {
  826. shadowBlur: 15,
  827. shadowColor: 'rgba(105,123, 214, 0.7)'
  828. }
  829. },
  830. zlevel: 2,
  831. barWidth: '20%',
  832. data: data,
  833. },
  834. {
  835. name: '',
  836. type: 'bar',
  837. xAxisIndex: 1,
  838. zlevel: 1,
  839. itemStyle: {
  840. normal: {
  841. color: '#121847',
  842. borderWidth: 0,
  843. shadowBlur: {
  844. shadowColor: 'rgba(255,255,255,0.31)',
  845. shadowBlur: 10,
  846. shadowOffsetX: 0,
  847. shadowOffsetY: 2,
  848. },
  849. }
  850. },
  851. barWidth: '20%',
  852. data: [30, 30, 30, 30, 30]
  853. }
  854. ]
  855. }
  856. // 使用刚指定的配置项和数据显示图表。
  857. myChart.setOption(option);
  858. window.addEventListener("resize",function(){
  859. myChart.resize();
  860. });
  861. }
  862. function echarts_6() {
  863. // 基于准备好的dom,初始化echarts实例
  864. var myChart = echarts.init(document.getElementById('echarts_6'));
  865. var data = {
  866. "chart": [{
  867. month: "NO.1",
  868. value: 600,
  869. },
  870. {
  871. month: "NO.2",
  872. value: 500,
  873. },
  874. {
  875. month: "NO.3",
  876. value: 614,
  877. },
  878. {
  879. month: "NO.4",
  880. value: 442,
  881. },
  882. {
  883. month: "NO.5",
  884. value: 322
  885. }
  886. ]
  887. }
  888. var xAxisMonth = [],
  889. barData = [],
  890. lineData = [];
  891. for (var i = 0; i < data.chart.length; i++) {
  892. xAxisMonth.push(data.chart[i].month);
  893. barData.push({
  894. "name": xAxisMonth[i],
  895. "value": data.chart[i].value
  896. });
  897. lineData.push({
  898. "name": xAxisMonth[i],
  899. "value": data.chart[i].ratio
  900. });
  901. }
  902. option = {
  903. // backgroundColor: "#020d22",
  904. title: '',
  905. grid: {
  906. top: '10%',
  907. left: '18%',
  908. bottom: '3%',
  909. right:'5%',
  910. containLabel: true
  911. },
  912. tooltip: {
  913. trigger: 'axis',
  914. axisPointer: {
  915. type: 'none'
  916. },
  917. formatter: function(params) {
  918. return params[0]["data"].name + "<br/>" + '报警次数: ' + params[1]["data"].value+'次' ;
  919. }
  920. },
  921. xAxis: [{
  922. type: 'category',
  923. show: false,
  924. data: ['NO.1', 'NO.2', 'NO.3', 'NO.4', 'NO.5'],
  925. axisLabel: {
  926. textStyle: {
  927. color: '#b6b5ab'
  928. }
  929. }
  930. },
  931. {
  932. type: 'category',
  933. position: "bottom",
  934. data: xAxisMonth,
  935. boundaryGap: true,
  936. // offset: 40,
  937. splitLine: {
  938. show: false,
  939. lineStyle: {
  940. color: "rgba(255,255,255,0.2)"
  941. }
  942. },
  943. axisTick: {
  944. show: false
  945. },
  946. axisLine: {
  947. show: true,
  948. color: "rgba(255,255,255,0.2)"
  949. },
  950. axisLabel: {
  951. textStyle: {
  952. color: '#b6b5ab'
  953. }
  954. }
  955. }
  956. ],
  957. yAxis: [{
  958. show: true,
  959. offset: 52,
  960. splitLine: {
  961. show: false,
  962. lineStyle: {
  963. color: "rgba(255,255,255,0.2)"
  964. }
  965. },
  966. axisTick: {
  967. show: false
  968. },
  969. axisLine: {
  970. show: true,
  971. color: "rgba(255,255,255,0.2)"
  972. },
  973. axisLabel: {
  974. show: true,
  975. color: '#b6b5ab'
  976. }
  977. }, {
  978. show: false,
  979. type: "value",
  980. // name: "合格率(%)",
  981. nameTextStyle: {
  982. color: '#ccc'
  983. },
  984. axisLabel: {
  985. color: '#ccc'
  986. },
  987. splitLine: {
  988. show: false
  989. },
  990. axisLine: {
  991. show: true
  992. },
  993. axisTick: {
  994. show: true
  995. }
  996. }],
  997. color: ['#e54035'],
  998. series: [{
  999. name: '训练人次',
  1000. type: 'pictorialBar',
  1001. xAxisIndex: 1,
  1002. barCategoryGap: '-80%',
  1003. // barCategoryGap: '-5%',
  1004. symbol: 'path://d="M150 50 L130 130 L170 130 Z"',
  1005. itemStyle: {
  1006. normal: {
  1007. color: function(params) {
  1008. var colorList = [
  1009. 'rgba(13,177,205,0.8)', 'rgba(29,103,182,0.6)',
  1010. 'rgba(13,177,205,0.8)', 'rgba(29,103,182,0.6)',
  1011. 'rgba(13,177,205,0.8)', 'rgba(29,103,182,0.6)'
  1012. ];
  1013. return colorList[params.dataIndex];
  1014. }
  1015. },
  1016. emphasis: {
  1017. opacity: 1
  1018. }
  1019. },
  1020. data: barData,
  1021. },
  1022. {
  1023. symbol: 'image://data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAAAvCAYAAABzJ5OsAAAGDUlEQVRogbWaPWxcRRDHf/fO92Ffgk2MrXygBEJACCiQkCgQcoPSIAVXoYCKFBRIKegpQJHSBokehIgoiBBFrEiAQuEKgoQiPiIQEIRANnFI7ODYvvP5fBQ74zdvb/e9y9keafV27+3Hf2ZnZmf2XYlulx2kClAFVqS9V57LO7mIUmmb4H2wO90/l7YLfru0LWYGAd8A1oF2dM4wFS1UB8oFc3sLbV/yMbD9kF1cd6EDNPtbuBh8BUiAVmacP09+21+kqN0XDSL5UuQZ+w2y4LqRp18fwalPVIWGckBWvIE+yJJXz2PKAg3VtV0y9TbOBgYCnwSA+4ATD7zPSAj8pgFui+1XokDqrlOx2oQkbIEnpsQYUICb5rkZ+C2kUnWp9xixL/kKbqu0Ywh44pWy97SMPQ78A9w2ADsGfEf6bRqwm/KbqlHTMJAhX/INUleVB7xsypCpPwncBO6QlbyCfQyYkz6dQMnbhULw2Xdx4EOmPCiLLRtGtK8u3hVwG15pm7plwNqFZaAsfYC4wYY8iwVeMeUO7nBpSFsZ0HEKXMG3cafoOnAMuAEsBDBYVQqS9SiNAAMxqU8CR3G6OIzzyS8DM8B9wMPAi8DzwCjwEHAROCnrjMi4FeB+w7Rv+BYLGKn74Ne9jpYBX+qTOCkq8HEB+ouA7QA/AX8BYzJmBjgF7DEMNHH6XyVVw5DnslSX+YI6H5K4gq4CNbISfwd4Hxe7q4dQr6WeZEOE0wLWgNPA18Cn0j6M80i/Sz+1Aav/yFM1ZCXvkFJGfJVRJurA2x7IESMZH3wLJ+khATkNXJL3i2S9loJWDFbC69KHEt2uH1P7qlI2gI+JhEZw278fp7Mdaasuqxoo+LYAX5N17uK807LU7wKr8r5Ferpa9+mHEwzJQr6+W10Lucgq8BZwXvo0BHxjCg6/Ac895YyWFqx/AVffhW9uOAkjoNoilBeAT2TeI8BvZFXXlzy43W0mIomiAEwZmDcMPC3jEplseAqOnIOTChygBtUT8Ox5eIV0Z4bdKxrAa6QqM0q+sWYoyXvpTXKY7A58Rurra0DtLJyouV3poQMwftoxXMP1qeJs4XtS9bxJ2FVaPCDhS0Ka4cc6an0f2Z24gjlpp+DgWHwuAI7DE2ZMWcCfM4CXcoD3UEzyscGx8Lc0FgmeLHXDYfQlD/CeAgxK5YTwnUroSP6B1OI/Bm6Zdnepj7yzFI7nIeBJIhgypMYWIj/LOYQzqC7wAc7oEiSwmoW5ecdQlL6Ea/QGYl8FGOorN02QozaHAS0jwIQsOIPb1iGcx2kBrTPweSt1uxm6DnPvwVXpq4FZGzhLNqL8L4cB+1snoTfV8iWuWz0vE6vkTgHP4NSlCazNwp9vwoUf4Q+dYAmWL8KVl5yq6UG0Jq+Pk4bFe4ED5BxKhurgJGd1VWMTO1CP6n9xJ+EIqdSmgcuYUGAWrs/C3+SfsGsyZp+Zaz9O7fpRoQrQ1MCsTjb102KzJQ3KxmWBhpRDpL69n9hmlTREWJGiO9I0zKhd6M6rcLeoKDCzybKfCWnGdAv4ELiAixSbEfDrMt/rAvYMaSyjgP10sAewJfXzvpvzt82CXyQb3t4GvsPlp9pnSfotSn0Jl3FtAI8C35JKegJ4hGwYHFIZrW8lTbEcNi+L0gjzKE5aa0h4gDO6j6RcJk1SpoFXSb1My5QJYXKBXumHdmDrMsyCt7e/NrrUE9Hqv2ZTkzjjrJLGOf3msJM4r+TreCgJj0g4BR+L64tuDypeu5/bg3Gc3i9wb7cHUfC973qZiN3bPAAcBH41fWxsMopTj2uGiXu9t6mRvakOgq+TJguD3piN4/z2z4QNfzNQt8At6B5dzwOvurtqgPsMWFvY7bvKKPV7P18KPEPhbSwDsmBit8Qh16ifeoLfrIoOKT15bdhgSS9KLWD/6YP36yEp+7cFQSqSfOh6OQ9k6LcYsCLQhTToBzUfXFG7KNGw7dA3sAiI/sHXSCPE7ByD00CSUyq6PbDUQm6qAgD6yYDyjLNC70VvIW3nO2zRx+Rdp536fB/9bhShHWF8t/574P/bY1d26X/PtooMr/p/9AAAAABJRU5ErkJggg==',
  1024. symbolSize: 42,
  1025. name: "完成率",
  1026. type: "line",
  1027. yAxisIndex: 1,
  1028. data: lineData,
  1029. itemStyle: {
  1030. normal: {
  1031. borderWidth: 5,
  1032. color: {
  1033. colorStops: [{
  1034. offset: 0,
  1035. color: '#821eff'
  1036. },
  1037. {
  1038. offset: 1,
  1039. color: '#204fff'
  1040. }
  1041. ],
  1042. }
  1043. }
  1044. }
  1045. }
  1046. ]
  1047. }
  1048. // 使用刚指定的配置项和数据显示图表。
  1049. myChart.setOption(option);
  1050. window.addEventListener("resize",function(){
  1051. myChart.resize();
  1052. });
  1053. }
  1054. })