new_file.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. /* */
  2. $(function(){
  3. pieChar();
  4. barChar([20,60,82,60]);
  5. linchar();
  6. barschar();
  7. radarchar();
  8. progress1char();
  9. progress2char();
  10. mapchar();
  11. });
  12. window.onresize = function(){
  13. pieChart.resize();
  14. barChart.resize(); //若有多个图表变动,可多写
  15. linchart.resize();
  16. barschart.resize();
  17. radarchart.resize();
  18. progress1chart.resize();
  19. progress2chart.resize();
  20. mapchart.resize()
  21. }
  22. //饼状图
  23. var pieChart="";
  24. function pieChar(){
  25. pieChart= echarts.init(document.getElementById("pie-chart"));
  26. option = {
  27. color:["#4f8bf9","#fea31e","#959595"],
  28. tooltip: {
  29. trigger: 'item',
  30. formatter: "{a} <br/>{b}: {c} ({d}%)"
  31. },
  32. series: [
  33. {
  34. name:'访问来源',
  35. type:'pie',
  36. selectedMode: 'single',
  37. radius: [0, '60%'],
  38. center:["50%","42%"],
  39. label: {
  40. normal: {
  41. position: 'outside',
  42. formatter: "{b}:{d}%"
  43. }
  44. },
  45. data:[
  46. {value:556, name:'正常'},
  47. {value:100, name:'告警',selected:true},
  48. {value:30, name:'离线'}
  49. ]
  50. }
  51. ]
  52. };
  53. pieChart.setOption(option);
  54. }
  55. //柱状图
  56. var barChart="";
  57. function barChar(data){
  58. barChart= echarts.init(document.getElementById("bar-chart"));
  59. option = {
  60. tooltip: {
  61. formatter:'{b}:{c}'
  62. },
  63. grid: {
  64. left: '15%',
  65. right: '15%',
  66. bottom: '20%',
  67. top: '20%',
  68. containLabel: true,
  69. z: 22
  70. },
  71. xAxis: {
  72. data: ["NHN","TP","NP","COD"], //横坐标
  73. axisLabel:{
  74. textStyle: {
  75. color:'#fff',
  76. fontSize:12,
  77. }
  78. },
  79. axisLine: {
  80. lineStyle: {
  81. type: 'solid',
  82. color:'#24214e',
  83. width:'1 ', //坐标线的宽度
  84. }
  85. },
  86. },
  87. yAxis: {
  88. name: "(数次)",
  89. nameTextStyle:{
  90. color:"#fff"
  91. },
  92. nameLocation:"center",
  93. nameGap:30,
  94. nameRotate:-270,
  95. axisLabel: {
  96. textStyle: {
  97. color: '#fff',
  98. fontSize:12,//坐标值得具体的颜色
  99. }
  100. },
  101. axisLine: {
  102. lineStyle: {
  103. type: 'solid',
  104. color:'#24214e',
  105. width:'1 ', //坐标线的宽度
  106. }
  107. },
  108. splitLine: {
  109. lineStyle: {
  110. color: "#24214e",
  111. }
  112. }
  113. },
  114. series: [{
  115. type: 'bar',
  116. barWidth:20,
  117. data:data,
  118. /*label: {
  119. normal: {
  120. show: true,
  121. position: "top",
  122. textStyle: {
  123. color: "#fffff",
  124. fontSize: 12
  125. }
  126. }
  127. },*/
  128. itemStyle: {
  129. normal: {
  130. color: new echarts.graphic.LinearGradient(
  131. 0, 0, 0, 1,
  132. [
  133. {offset: 0, color: '#4f92fa'}, //柱图渐变色
  134. {offset: 0.5, color: '#565cf8'}, //柱图渐变色
  135. {offset: 1, color: '#5d29f7'}, //柱图渐变色
  136. ]
  137. )
  138. }
  139. },
  140. }]
  141. };
  142. barChart.setOption(option)
  143. }
  144. //折线图
  145. var linchart="";
  146. function linchar(){
  147. linchart= echarts.init(document.getElementById("line-chart"));
  148. option = {
  149. tooltip: {
  150. formatter:'{b}&nbsp; {c}次'
  151. },
  152. grid: {
  153. left: '15%',
  154. right: '15%',
  155. bottom: '20%',
  156. top: '20%',
  157. containLabel: true,
  158. z: 22
  159. },
  160. xAxis: {
  161. data: ['00:00', '06:00', '12:00', '18:00','24:00'],
  162. axisLabel:{
  163. textStyle: {
  164. color:'#fff',
  165. fontSize:12,
  166. }
  167. },
  168. axisLine: {
  169. lineStyle: {
  170. type: 'solid',
  171. color:'#24214e',
  172. width:'1 ', //坐标线的宽度
  173. }
  174. },
  175. },
  176. yAxis: {
  177. name: "(数次)",
  178. nameTextStyle:{
  179. color:"#fff"
  180. },
  181. nameLocation:"center",
  182. nameGap:30,
  183. nameRotate:-270,
  184. axisLabel: {
  185. textStyle: {
  186. color: '#fff',
  187. fontSize:12,//坐标值得具体的颜色
  188. }
  189. },
  190. axisLine: {
  191. lineStyle: {
  192. type: 'solid',
  193. color:'#24214e',
  194. width:'1 ', //坐标线的宽度
  195. }
  196. },
  197. splitLine: {
  198. lineStyle: {
  199. color: "#24214e",
  200. }
  201. }
  202. },
  203. series: [{
  204. type: 'line',
  205. data:[40, 182, 191, 234, 290],
  206. itemStyle : {
  207. normal : {
  208. lineStyle:{
  209. width:3,//折线宽度
  210. },
  211. color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
  212. offset: 1,
  213. color: '#508ff6' // 0% 处的颜色
  214. }, {
  215. offset: 0,
  216. color: '#2c137a' // 100% 处的颜色
  217. }], false),
  218. opacity: 0.4
  219. }
  220. },
  221. }]
  222. };
  223. linchart.setOption(option)
  224. }
  225. //柱状图2
  226. var barschart=""
  227. function barschar(){
  228. barschart = echarts.init(document.getElementById("bars-chart"));
  229. option = {
  230. color:["#fd8f1e","#7cb5ec","#4280f1","#957bde"],
  231. tooltip: {
  232. trigger: 'axis',
  233. axisPointer: { // 坐标轴指示器,坐标轴触发有效
  234. type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  235. }
  236. },
  237. grid: {
  238. left: '10%',
  239. right: '15%',
  240. bottom: '20%',
  241. top: '20%',
  242. containLabel: true,
  243. z: 22
  244. },
  245. legend: {
  246. data: ['进样异常', '缺试剂A', '缺试剂B', '消解异常'],
  247. textStyle: {
  248. fontSize: 12,
  249. color:"#fff"
  250. },
  251. icon:"rect",
  252. itemWidth:10,
  253. itemHeight:10,
  254. bottom:"9%"
  255. },
  256. xAxis: {
  257. name:'次数',
  258. nameTextStyle:{
  259. color:"#fff"
  260. },
  261. axisLabel:{
  262. textStyle: {
  263. color:'#fff',
  264. fontSize:12,
  265. }
  266. },
  267. splitLine: {
  268. lineStyle: {
  269. color: "#24214e",
  270. }
  271. },
  272. axisLine: {
  273. lineStyle: {
  274. type: 'solid',
  275. color:'#24214e',
  276. width:'1 ', //坐标线的宽度
  277. }
  278. }
  279. },
  280. yAxis: {
  281. data: ['2018.11', '2018.12', '2019.01', '2019.02', '2019.03'],
  282. axisLabel: {
  283. textStyle: {
  284. color: '#fff',
  285. fontSize:12,//坐标值得具体的颜色
  286. }
  287. },
  288. axisLine: {
  289. lineStyle: {
  290. type: 'solid',
  291. color:'#24214e',
  292. width:'1 ', //坐标线的宽度
  293. }
  294. },
  295. },
  296. series: [{
  297. name: '进样异常',
  298. type: 'bar',
  299. stack: '总量',
  300. barWidth:20,
  301. label: {
  302. normal: {
  303. show: false,
  304. position: 'insideRight'
  305. }
  306. },
  307. data: [6, 4, 10, 8, 7]
  308. }, {
  309. name: '缺试剂A',
  310. type: 'bar',
  311. barWidth:20,
  312. stack: '总量',
  313. label: {
  314. normal: {
  315. show: false,
  316. position: 'insideRight'
  317. }
  318. },
  319. data: [8, 10, 4, 5, 6]
  320. }, {
  321. name: '缺试剂B',
  322. type: 'bar',
  323. stack: '总量',
  324. barWidth:20,
  325. label: {
  326. normal: {
  327. show: false,
  328. position: 'insideRight'
  329. }
  330. },
  331. data: [6, 4, 10, 8, 7]
  332. }, {
  333. name: '消解异常',
  334. type: 'bar',
  335. stack: '总量',
  336. barWidth:20,
  337. label: {
  338. normal: {
  339. show: false,
  340. position: 'insideRight'
  341. }
  342. },
  343. data: [6, 4, 10, 8, 7]
  344. },
  345. ]
  346. };
  347. barschart.setOption(option)
  348. };
  349. //雷达图
  350. var radarchart="";
  351. function radarchar(){
  352. radarchart = echarts.init(document.getElementById("radar-chart"));
  353. option = {
  354. color: ['#623ad1', '#3383fc'],
  355. tooltip: {},
  356. radar: [{
  357. indicator: [{
  358. text: '进样异常',
  359. max: 100
  360. },
  361. {
  362. text: '缺试剂A',
  363. max: 100
  364. },
  365. {
  366. text: '消解异常',
  367. max: 100
  368. },
  369. {
  370. text: '缺纯水',
  371. max: 100
  372. },
  373. {
  374. text: '缺试剂B',
  375. max: 100
  376. }
  377. ],
  378. center: ['50%', '60%'],
  379. radius: '65%',
  380. startAngle: 90,
  381. name: {
  382. formatter: '{value}',
  383. textStyle: {
  384. fontSize: 12, //外圈标签字体大小
  385. color: '#FFF' //外圈标签字体颜色
  386. }
  387. },
  388. splitArea: { // 坐标轴在 grid 区域中的分隔区域,默认不显示。
  389. show: true,
  390. areaStyle: { // 分隔区域的样式设置。
  391. color: [], // 分隔区域颜色。分隔区域会按数组中颜色的顺序依次循环设置颜色。默认是一个深浅的间隔色。
  392. }
  393. },
  394. axisLine: { //指向外圈文本的分隔线样式
  395. lineStyle: {
  396. color: '#24214e'
  397. }
  398. },
  399. splitLine: {
  400. lineStyle: {
  401. color: '#24214e', // 分隔线颜色
  402. width: 1, // 分隔线线宽
  403. }
  404. }
  405. }, ],
  406. series: [{
  407. name: '雷达图',
  408. type: 'radar',
  409. data: [
  410. {
  411. name: '2016',
  412. value: [85, 65, 55, 90, 82],
  413. areaStyle: {
  414. normal: { // 单项区域填充样式
  415. opacity: 1 // 区域透明度
  416. }
  417. },
  418. symbolSize: 0, // 单个数据标记的大小,可以设置成诸如 10 这样单一的数字,也可以用数组分开表示宽和高,例如 [20, 10] 表示标记宽为20,高为10。
  419. }, {
  420. name: '2017',
  421. value: [50, 80, 45, 30, 75],
  422. symbolSize:0,
  423. areaStyle: {
  424. normal: { // 单项区域填充样式
  425. color: {
  426. type: 'linear',
  427. x: 0, //右
  428. y: 0, //下
  429. x2: 1, //左
  430. y2: 1, //上
  431. colorStops: [{
  432. offset: 0,
  433. color: '#3cd2f3'
  434. },
  435. {
  436. offset: 1,
  437. color: '#306eff'
  438. }],
  439. globalCoord: false
  440. },
  441. opacity: 1 // 区域透明度
  442. }
  443. },
  444. }]
  445. }]
  446. };
  447. radarchart.setOption(option)
  448. }
  449. //进度条1
  450. var progress1chart="";
  451. function progress1char(){
  452. progress1chart = echarts.init(document.getElementById("progress1-chart"));
  453. var baifenbi = [0.333, 0.444, 0.555, 0.777, 0.888];
  454. var grayBar = [1, 1, 1, 1, 1, ];
  455. var paiming = [ 5, 4, 3, 2, 1];
  456. var xingm = ['宁波', '台州', '焦作', '邢台', '嘉兴'];
  457. option = {
  458. title: {
  459. text: '2019年 第一季度',
  460. left: '75%',
  461. top:"20",
  462. textStyle:{
  463. color:"#fff",
  464. fontSize:12
  465. }
  466. },
  467. grid: {
  468. left: '15%', //如果离左边太远就用这个......
  469. right: '15%',
  470. bottom: '5%',
  471. top: '20%',
  472. containLabel: true
  473. },
  474. xAxis: [{
  475. show: false,
  476. },
  477. {
  478. show: false,
  479. }
  480. ],
  481. yAxis: {
  482. type: 'category',
  483. axisLabel: {
  484. show: true, //让Y轴数据不显示
  485. },
  486. axisTick: {
  487. show: false, //隐藏Y轴刻度
  488. },
  489. axisLine: {
  490. show: false, //隐藏Y轴线段
  491. },
  492. },
  493. series: [
  494. //背景色
  495. {
  496. show: true,
  497. type: 'bar',
  498. barGap: '-100%',
  499. barWidth: '10%', //统计条宽度
  500. itemStyle: {
  501. normal: {
  502. barBorderRadius: 50,
  503. color: 'rgba(41, 55, 94)'
  504. },
  505. },
  506. z: 1,
  507. data: grayBar,
  508. },
  509. //蓝条
  510. {
  511. show: true,
  512. type: 'bar',
  513. barGap: '-100%',
  514. barWidth: '10%', //统计条宽度
  515. itemStyle: {
  516. normal: {
  517. barBorderRadius: 50, //统计条弧度
  518. color: {
  519. colorStops: [{
  520. offset: 0,
  521. color: '#5d29f7' // 0% 处的颜色
  522. }, {
  523. offset: 1,
  524. color: '#5093fb' // 100% 处的颜色
  525. }],
  526. globalCoord: false, // 缺省为 false
  527. }
  528. },
  529. },
  530. max: 1,
  531. label: {
  532. normal: {
  533. show: true,
  534. textStyle: {
  535. color: '#fff', //百分比颜色
  536. },
  537. position: [0, '-35'],
  538. rich: { //富文本
  539. yellow: {
  540. color: '#FEC735',
  541. }
  542. },
  543. formatter: function(data) {
  544. //富文本固定格式{colorName|这里填你想要写的内容}
  545. if(paiming[data.dataIndex] == 1||paiming[data.dataIndex] == 2||paiming[data.dataIndex] == 3){
  546. return '{yellow|' + paiming[data.dataIndex] + ' ' + xingm[data.dataIndex] + '}';
  547. }else{
  548. return paiming[data.dataIndex] + ' ' + xingm[data.dataIndex]
  549. }
  550. },
  551. }
  552. },
  553. data: baifenbi,
  554. },
  555. ]
  556. };
  557. progress1chart.setOption(option)
  558. }
  559. /* */
  560. //点击切换数据
  561. function DataSwitch(obj,num){
  562. $(obj).removeClass("Datasame");
  563. $(obj).siblings().addClass("Datasame")
  564. if(num==1){
  565. $(obj).parent().prev().addClass("Defaultgray");
  566. $(obj).parent().next().removeClass("Defaultgray");
  567. barChar([100,20,60,81])
  568. }else{
  569. barChar()
  570. $(obj).parent().prev().removeClass("Defaultgray");
  571. $(obj).parent().next().addClass("Defaultgray");
  572. barChar([10,20,50,81])
  573. }
  574. }