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