echartsToolzm_20210421155036.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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. export function leida_djbhd(id , value , name) {
  354. if(value === undefined){
  355. message.error("没有找到报表数据,请检查!");
  356. return;
  357. }
  358. var myChart = EC.init(document.getElementById(id));
  359. myChart.resize({ height: 300 });
  360. let option = {
  361. tooltip: {},
  362. legend: {
  363. top: "93%",
  364. left: "10%",
  365. },
  366. tooltip: {
  367. triggerOn: "none",
  368. alwaysShowContent: true,
  369. position: function (pt) {
  370. return [pt[0], 130];
  371. },
  372. },
  373. radar: {
  374. name: {
  375. textStyle: {
  376. color: "#fff",
  377. backgroundColor: "#999",
  378. borderRadius: 3,
  379. padding: [3, 5],
  380. },
  381. },
  382. indicator: [
  383. { name: "北", max: 99 },
  384. { name: "北北东", max: 99 },
  385. { name: "北东", max: 99 },
  386. { name: "东北东", max: 99 },
  387. { name: "东", max: 99 },
  388. { name: "东南东", max: 99 },
  389. { name: "南东", max: 99 },
  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. ],
  400. },
  401. series: [
  402. {
  403. type: "radar",
  404. // areaStyle: {normal: {}},
  405. data: [
  406. {
  407. value: value,
  408. name: name,
  409. label: {
  410. show: true,
  411. position: "insideBottomRight",
  412. distance: 14.5,
  413. //rotate: -45,
  414. offset: [11, 0],
  415. formatter:function(params){
  416. let list = ["北","北北东","北东","东北东","东","东南东","南东","南南东","南","南南西","南西","西南西","西","西北西","北西","北北西"]
  417. if(params.value<10){
  418. return ''
  419. }else{
  420. return list[params.dimensionIndex]+':'+params.value;
  421. }
  422. }
  423. },
  424. areaStyle: {
  425. opacity: 0.9,
  426. color: new EC.graphic.RadialGradient(0.5, 0.5, 1, [
  427. {
  428. color: "#B8D3E4",
  429. offset: 0,
  430. },
  431. {
  432. color: "#72ACD1",
  433. offset: 1,
  434. },
  435. ]),
  436. },
  437. },
  438. ],
  439. itemStyle: { normal: { label: { show: true } } },
  440. },
  441. ],
  442. tooltip: {
  443. show:false,
  444. position: function (p) {
  445. //其中p为当前鼠标的位置
  446. return [p[0] + 10, p[1] - 100];
  447. },
  448. // formatter: function (params) {
  449. // //其中p为当前鼠标的位置
  450. // debugger
  451. // let fanhui = [];
  452. // let str ='';
  453. // let list = ["北","北北东","北东","东北东","东","东南东","南东","南南东","南","南南西","南西","西南西","西","西北西","北西","北北西"]
  454. // for(let i=1;i<Object.keys(params.value).length;i++){
  455. // if(params.value[i]>10){
  456. // fanhui.push(params.value[i]+':'+list[i]);
  457. // }
  458. // }
  459. // for(let j = 1 ;j<fanhui.length;j++){
  460. // str.concat(fanhui[j]);
  461. // }
  462. // return str;
  463. // },
  464. textStyle: {
  465. fontWeight: "16px",
  466. fontSize: 16,
  467. lineHeight: 0,
  468. },
  469. },
  470. };
  471. myChart.setOption(option, true);
  472. }
  473. export default {
  474. getBar_fdd,
  475. leida_tc,
  476. bar_tc,
  477. bar_tc_2,
  478. leida_djbhd,
  479. color,
  480. }