echartsToolzm_20210423161147.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. import EC from 'echarts'
  2. import BASE from '@tools/base';
  3. const color = ["#00FFF0","#014EB5","#A800FF","#e82edb","#B5454C","#443bff","#e8cb25","#3dffb0","#e8a425","#ff7aab","#e84b1e","#552ce2","#ffae21","#e8861e","#d441ff","#35e8e4","#9c7aff","#e86fd8","#ffee38"];
  4. /*
  5. * 柱状图(非堆叠柱状图)
  6. * id: 元素ID
  7. * data 数据
  8. * [
  9. {
  10. name: "限电损失电量(单位:万kwh)",
  11. type: "bar",
  12. data: this.histogram.xdss,
  13. },
  14. {
  15. name: "故障损失电量(单位:万kwh)",
  16. type: "bar",
  17. data: this.histogram.gzss,
  18. },
  19. ,
  20. {
  21. name: "检修损失电量(单位:万kwh)",
  22. type: "bar",
  23. data: this.histogram.jxss,
  24. },
  25. {
  26. name: "性能损失电量(单位:万kwh)",
  27. type: "bar",
  28. data: this.histogram.xnss,
  29. },
  30. {
  31. name: "受累损失电量(单位:万kwh)",
  32. type: "bar",
  33. data: this.histogram.slss,
  34. },
  35. ]
  36. * xdata : 横坐标数据
  37. * */
  38. export function getBar_fdd(id, data , xdata) {
  39. if(data === undefined){
  40. message.error("没有找到报表数据,请检查!");
  41. return;
  42. }
  43. var myChart = EC.init(document.getElementById(id));
  44. var option = {
  45. title: {
  46. text: "损失电量分析",
  47. },
  48. tooltip: {
  49. trigger: "axis",
  50. axisPointer: {
  51. type: "shadow",
  52. },
  53. },
  54. legend: {
  55. data: [
  56. "限电损失电量(单位:万kwh)",
  57. "故障损失电量(单位:万kwh)",
  58. "检修损失电量(单位:万kwh)",
  59. "性能损失电量(单位:万kwh)",
  60. "受累损失电量(单位:万kwh)",
  61. ],
  62. },
  63. grid: {
  64. left: "3%",
  65. right: "4%",
  66. bottom: "3%",
  67. containLabel: true,
  68. },
  69. yAxis: {
  70. type: "value",
  71. boundaryGap: [0, 0.01],
  72. },
  73. xAxis: {
  74. type: "category",
  75. data: xdata,
  76. },
  77. series: data,
  78. };
  79. myChart.setOption(option, true);
  80. }
  81. /**
  82. * 对标分析弹出雷达图--->
  83. * @param {id名称} id
  84. * @param {第一台风机数据} value1
  85. * @param {第一台风机名字} name1
  86. * @param {第二台风机数据} value2
  87. * @param {第二台风机名字} name2
  88. * @returns
  89. */
  90. export function leida_tc(id , value1 , name1 , value2 , name2) {
  91. if(value1 === undefined || value2 === undefined){
  92. message.error("没有找到报表数据,请检查!");
  93. return;
  94. }
  95. var myChart = EC.init(document.getElementById(id));
  96. var option;
  97. option = {
  98. title: {
  99. text: "对标排名分析",
  100. left: 400,
  101. top: -5,
  102. textStyle: {
  103. fontSize: 13,
  104. },
  105. },
  106. grid: {
  107. top: "10%",
  108. left: "10%",
  109. right: "10%",
  110. bottom: "0",
  111. },
  112. tooltip: {},
  113. legend: {
  114. orient: "vertical",
  115. x: "left", //可设定图例在左、右、居中
  116. y: "0", //可设定图例在上、下、居中
  117. padding: [0, 50, 0, 0],
  118. },
  119. radar: {
  120. // shape: 'circle',
  121. name: {
  122. textStyle: {
  123. color: "#fff",
  124. backgroundColor: "#999",
  125. borderRadius: 3,
  126. padding: [3, 5],
  127. },
  128. },
  129. indicator: [
  130. { name: "风能利用率", max: 100 },
  131. { name: "故障损失率", max: 100 },
  132. { name: "检修损失率", max: 100 },
  133. { name: "弃风率", max: 100 },
  134. { name: "性能损失率", max: 100 },
  135. { name: "受累损失率", max: 100 },
  136. { name: "复位及时率", max: 100 },
  137. { name: "状态转换率", max: 100 },
  138. { name: "消缺及时率", max: 100 },
  139. ],
  140. },
  141. series: [
  142. {
  143. name: "预算 vs 开销(Budget vs spending)",
  144. type: "radar",
  145. // areaStyle: {normal: {}},
  146. data: [
  147. {
  148. value: value1,
  149. name: name1,
  150. },
  151. {
  152. value: value2,
  153. name: name2,
  154. },
  155. ],
  156. },
  157. ],
  158. };
  159. myChart.setOption(option, true);
  160. }
  161. /**
  162. *
  163. * @param {id名称} id
  164. * @param {第一台风机数据} value1
  165. * @param {第二台风机数据} value2
  166. * @returns
  167. */
  168. export function bar_tc(id , value1 , value2) {
  169. if(value1 === undefined || value2 === undefined){
  170. message.error("没有找到报表数据,请检查!");
  171. return;
  172. }
  173. var myChart = EC.init(document.getElementById(id));
  174. var option;
  175. option = {
  176. tooltip: {
  177. trigger: "axis",
  178. axisPointer: {
  179. type: "cross",
  180. crossStyle: {
  181. color: "#999",
  182. },
  183. },
  184. },
  185. title: {
  186. text: "损失电量分析",
  187. left: 100,
  188. top: 8,
  189. textStyle: {
  190. fontSize: 13,
  191. },
  192. },
  193. grid: {
  194. top: "90",
  195. left: "10%",
  196. right: "10%",
  197. bottom: "30",
  198. },
  199. legend: {
  200. orient: "vertical",
  201. x: "right", //可设定图例在左、右、居中
  202. y: 0, //可设定图例在上、下、居中
  203. padding: [0, 50, 200, 0],
  204. data: [
  205. "限电损失电量(单位:万kwh)",
  206. "故障损失电量(单位:万kwh)",
  207. "检修损失电量(单位:万kwh)",
  208. "性能损失电量(单位:万kwh)",
  209. "受累损失电量(单位:万kwh)",
  210. ],
  211. },
  212. xAxis: [
  213. {
  214. type: "category",
  215. data: [
  216. BASE.getBzDate(new Date(value1.recordDate),0),
  217. BASE.getBzDate(new Date(value2.recordDate),0),
  218. ],
  219. axisPointer: {
  220. type: "shadow",
  221. },
  222. },
  223. ],
  224. yAxis: [
  225. {
  226. type: "value",
  227. name: "电量",
  228. interval: 50,
  229. axisLabel: {
  230. formatter: "{value} 万kw",
  231. },
  232. },
  233. ],
  234. series: [
  235. {
  236. name: "限电损失电量(单位:万kwh)",
  237. type: "bar",
  238. yAxisIndex: 0,
  239. data: [value1.xdss, value2.xdss],
  240. },
  241. {
  242. name: "故障损失电量(单位:万kwh)",
  243. type: "bar",
  244. yAxisIndex: 0,
  245. data: [value1.zzss, value2.gzss],
  246. },
  247. {
  248. name: "检修损失电量(单位:万kwh)",
  249. type: "bar",
  250. yAxisIndex: 0,
  251. data: [value1.jxss, value2.jxss],
  252. },
  253. {
  254. name: "性能损失电量(单位:万kwh)",
  255. type: "bar",
  256. yAxisIndex: 0,
  257. data: [value1.xnss, value2.xnss],
  258. },
  259. {
  260. name: "受累损失电量(单位:万kwh)",
  261. type: "bar",
  262. yAxisIndex: 0,
  263. data: [value1.slss, value2.slss],
  264. },
  265. ],
  266. };
  267. myChart.setOption(option, true);
  268. }
  269. /**
  270. *
  271. * @param {id名称} id
  272. * @param {数据} value
  273. * @returns
  274. */
  275. export function bar_tc_2(id , value) {
  276. if(value === undefined){
  277. message.error("没有找到报表数据,请检查!");
  278. return;
  279. }
  280. var myChart = EC.init(document.getElementById(id));
  281. let option = {
  282. legend: {
  283. orient: "vertical",
  284. left: "right",
  285. },
  286. tooltip: {},
  287. dataset: {
  288. dimensions: [
  289. "product",
  290. "限电损失电量单位:万KWh",
  291. "故障损失电量单位:万KWh",
  292. "检修损失电量单位:万KWh",
  293. "性能损失电量单位:万KWh",
  294. "受累损失电量单位:万KWh",
  295. ],
  296. source: value,
  297. },
  298. xAxis: { type: "category" },
  299. yAxis: {},
  300. // Declare several bar series, each will be mapped
  301. // to a column of dataset.source by default.
  302. series: [
  303. {
  304. // barGap:'100%',/*多个并排柱子设置柱子之间的间距*/
  305. type: "bar",
  306. barWidth: 30,
  307. itemStyle: {
  308. normal: {
  309. color: "#D201D8",
  310. },
  311. },
  312. },
  313. {
  314. type: "bar",
  315. barWidth: 30,
  316. itemStyle: {
  317. normal: {
  318. color: "#FD0100",
  319. },
  320. },
  321. },
  322. {
  323. type: "bar",
  324. barWidth: 30,
  325. itemStyle: {
  326. normal: {
  327. color: "#FF7B16",
  328. },
  329. },
  330. },
  331. {
  332. type: "bar",
  333. barWidth: 30,
  334. itemStyle: {
  335. normal: {
  336. color: "#8085E9",
  337. },
  338. },
  339. },
  340. {
  341. type: "bar",
  342. barWidth: 30,
  343. itemStyle: {
  344. normal: {
  345. color: "#A6A6A6",
  346. },
  347. },
  348. },
  349. ],
  350. };
  351. myChart.setOption(option, true);
  352. }
  353. /**
  354. * 用在单机饱和度分体 表格内雷达图
  355. * @param {id名称} id
  356. * @param {雷达图数据} value
  357. * @param {雷达图名称} name
  358. * @returns
  359. */
  360. export function leida_djbhd(id , value , name) {
  361. if(value === undefined){
  362. message.error("没有找到报表数据,请检查!");
  363. return;
  364. }
  365. var myChart = EC.init(document.getElementById(id));
  366. myChart.resize({ height: 300 });
  367. let option = {
  368. tooltip: {},
  369. legend: {
  370. top: "93%",
  371. left: "10%",
  372. },
  373. tooltip: {
  374. triggerOn: "none",
  375. alwaysShowContent: true,
  376. position: function (pt) {
  377. return [pt[0], 130];
  378. },
  379. },
  380. radar: {
  381. name: {
  382. textStyle: {
  383. color: "#fff",
  384. backgroundColor: "#999",
  385. borderRadius: 3,
  386. padding: [3, 5],
  387. },
  388. },
  389. indicator: [
  390. { name: "北", max: 99 },
  391. { name: "北北东", max: 99 },
  392. { name: "北东", max: 99 },
  393. { name: "东北东", max: 99 },
  394. { name: "东", max: 99 },
  395. { name: "东南东", max: 99 },
  396. { name: "南东", max: 99 },
  397. { name: "南南东", max: 99 },
  398. { name: "南", max: 99 },
  399. { name: "南南西", max: 99 },
  400. { name: "南西", max: 99 },
  401. { name: "西南西", max: 99 },
  402. { name: "西", max: 99 },
  403. { name: "西北西", max: 99 },
  404. { name: "北西", max: 99 },
  405. { name: "北北西", max: 99 },
  406. ],
  407. },
  408. series: [
  409. {
  410. type: "radar",
  411. // areaStyle: {normal: {}},
  412. data: [
  413. {
  414. value: value,
  415. name: name,
  416. label: {
  417. show: true,
  418. position: "insideBottomRight",
  419. distance: 14.5,
  420. //rotate: -45,
  421. offset: [11, 0],
  422. formatter:function(params){
  423. let list = ["北","北北东","北东","东北东","东","东南东","南东","南南东","南","南南西","南西","西南西","西","西北西","北西","北北西"]
  424. if(params.value<10){
  425. return ''
  426. }else{
  427. return list[params.dimensionIndex]+':'+params.value;
  428. }
  429. }
  430. },
  431. areaStyle: {
  432. opacity: 0.9,
  433. color: new EC.graphic.RadialGradient(0.5, 0.5, 1, [
  434. {
  435. color: "#B8D3E4",
  436. offset: 0,
  437. },
  438. {
  439. color: "#72ACD1",
  440. offset: 1,
  441. },
  442. ]),
  443. },
  444. },
  445. ],
  446. itemStyle: { normal: { label: { show: true } } },
  447. },
  448. ],
  449. tooltip: {
  450. show:false,
  451. position: function (p) {
  452. //其中p为当前鼠标的位置
  453. return [p[0] + 10, p[1] - 100];
  454. },
  455. // formatter: function (params) {
  456. // //其中p为当前鼠标的位置
  457. // debugger
  458. // let fanhui = [];
  459. // let str ='';
  460. // let list = ["北","北北东","北东","东北东","东","东南东","南东","南南东","南","南南西","南西","西南西","西","西北西","北西","北北西"]
  461. // for(let i=1;i<Object.keys(params.value).length;i++){
  462. // if(params.value[i]>10){
  463. // fanhui.push(params.value[i]+':'+list[i]);
  464. // }
  465. // }
  466. // for(let j = 1 ;j<fanhui.length;j++){
  467. // str.concat(fanhui[j]);
  468. // }
  469. // return str;
  470. // },
  471. textStyle: {
  472. fontWeight: "16px",
  473. fontSize: 16,
  474. lineHeight: 0,
  475. },
  476. },
  477. };
  478. myChart.setOption(option, true);
  479. }
  480. /**
  481. * 单机饱和度---->
  482. * @param {id名称} id
  483. * @param {风机集合} fj
  484. * @param {曲线数据} lineDate
  485. * @returns
  486. */
  487. export function bar_djbhd(id , fj , lineDate) {
  488. if(lineDate === undefined){
  489. message.error("没有找到报表数据,请检查!");
  490. return;
  491. }
  492. var myChart = EC.init(document.getElementById(id));
  493. let option = {
  494. title: {
  495. text: "日功率曲线",
  496. },
  497. tooltip: {
  498. trigger: "axis",
  499. },
  500. legend: {
  501. data: fj,
  502. },
  503. grid: {
  504. left: "3%",
  505. right: "4%",
  506. bottom: "3%",
  507. containLabel: true,
  508. },
  509. toolbox: {
  510. feature: {
  511. saveAsImage: {},
  512. },
  513. },
  514. xAxis: {
  515. type: "category",
  516. boundaryGap: false,
  517. data: lineDate.speed,
  518. },
  519. yAxis: {
  520. type: "value",
  521. },
  522. series: [
  523. {
  524. name: fj[0],
  525. type: "line",
  526. stack: "总量",
  527. smooth: true,
  528. data: lineDate.value1,
  529. },
  530. {
  531. name: fj[1],
  532. type: "line",
  533. stack: "总量",
  534. smooth: true,
  535. data: lineDate.value2,
  536. },
  537. {
  538. name: fj[2],
  539. type: "line",
  540. stack: "总量",
  541. smooth: true,
  542. data: lineDate.value3,
  543. },
  544. {
  545. name: fj[3],
  546. type: "line",
  547. stack: "总量",
  548. smooth: true,
  549. data: lineDate.value3,
  550. },
  551. {
  552. name: fj[4],
  553. type: "line",
  554. stack: "总量",
  555. smooth: true,
  556. data: lineDate.value4,
  557. },
  558. ],
  559. };
  560. myChart.setOption(option, true);
  561. }
  562. /**
  563. * 用于单机性能分析--->可定义显示属性位置
  564. * @param {id名称} id
  565. * @param {数据} value
  566. * @param {名} name
  567. * @returns
  568. */
  569. export function bar_DJXNFX(id , value , name) {
  570. if(value === undefined){
  571. message.error("没有找到报表数据,请检查!");
  572. return;
  573. }
  574. var myChart = EC.init(document.getElementById(id));
  575. var option;
  576. option = {
  577. title: {},
  578. tooltip: {},
  579. legend: {
  580. top: "93%",
  581. left: "10%",
  582. },
  583. radar: {
  584. // shape: 'circle',
  585. name: {
  586. textStyle: {
  587. color: "#fff",
  588. backgroundColor: "#999",
  589. borderRadius: 3,
  590. padding: [3, 5],
  591. },
  592. },
  593. indicator: [
  594. { name: "北", max: 99 },
  595. { name: "北北东", max: 99 },
  596. { name: "北东", max: 99 },
  597. { name: "东北东", max: 99 },
  598. { name: "东", max: 99 },
  599. { name: "东南东", max: 99 },
  600. { name: "南东", max: 99 },
  601. { name: "南南东", max: 99 },
  602. { name: "南", max: 99 },
  603. { name: "南南西", max: 99 },
  604. { name: "南西", max: 99 },
  605. { name: "西南西", max: 99 },
  606. { name: "西", max: 99 },
  607. { name: "西北西", max: 99 },
  608. { name: "北西", max: 99 },
  609. { name: "北北西", max: 99 },
  610. ],
  611. },
  612. series: [
  613. {
  614. type: "radar",
  615. // areaStyle: {normal: {}},
  616. data: [
  617. {
  618. value: value,
  619. name: name,
  620. // label: {
  621. // show: true,
  622. // formatter: function (params) {
  623. // return params.value;
  624. // },
  625. // },
  626. areaStyle: {
  627. opacity: 0.9,
  628. color: new EC.graphic.RadialGradient(0.5, 0.5, 1, [
  629. {
  630. color: "#B8D3E4",
  631. offset: 0,
  632. },
  633. {
  634. color: "#72ACD1",
  635. offset: 1,
  636. },
  637. ]),
  638. },
  639. },
  640. ],
  641. },
  642. ],
  643. tooltip: {
  644. position:function(p){ //其中p为当前鼠标的位置
  645. return [p[0] + 10, p[1] - 100];
  646. },
  647. textStyle: {
  648. fontWeight: "16px",
  649. fontSize: 16,
  650. lineHeight: 0,
  651. }
  652. // formatter: (params) => {
  653. // for(var i=0;i<Object.keys(params.data.value).length;i++){
  654. // return params.data.name[0]+':'+params.data.value[0];
  655. // }
  656. // },
  657. },
  658. };
  659. myChart.setOption(option, true);
  660. }
  661. /**
  662. *
  663. * 用于单机性能分析--->
  664. * @param {id名称} id
  665. * @param {数据} value
  666. * @returns
  667. */
  668. export function qt_DJXNFX(id , value) {
  669. if(value === undefined){
  670. message.error("没有找到报表数据,请检查!");
  671. return;
  672. }
  673. var myChart = EC.init(document.getElementById(id));
  674. var option;
  675. option = {
  676. title: {
  677. text: "",
  678. },
  679. tooltip: {
  680. trigger: "item",
  681. },
  682. grid: {
  683. left: 99,
  684. top: 66,
  685. },
  686. legend: {
  687. orient: "vertical",
  688. left: "left",
  689. },
  690. series: [
  691. {
  692. type: "pie",
  693. radius: ["35%", "70%"],
  694. center: ["58%", "50%"],
  695. data: value,
  696. emphasis: {
  697. itemStyle: {
  698. shadowBlur: 10,
  699. shadowOffsetX: 0,
  700. shadowColor: "rgba(0, 0, 0, 0.5)",
  701. },
  702. },
  703. },
  704. ],
  705. };
  706. myChart.setOption(option, true);
  707. }
  708. export default {
  709. getBar_fdd,
  710. leida_tc,
  711. bar_tc,
  712. bar_tc_2,
  713. leida_djbhd,
  714. bar_djbhd,
  715. bar_DJXNFX,
  716. qt_DJXNFX,
  717. color,
  718. }