statisticalSummaryPage.vue 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953
  1. <template>
  2. <div class="statisticalSummary" :class="!theme ? 'themeDark' : 'themeLight'">
  3. <div class="statistical_wind">
  4. <el-row class="windStstus">
  5. <el-col :span="24" class="scrollbar">
  6. <!-- <span class="scrollbarName">场站名称:</span> -->
  7. <el-scrollbar>
  8. <div class="scrollbar-flex-content">
  9. <p v-for="item in stationData" :key="item.no" class="scrollbar-demo-item"
  10. :class="item.showBac ? 'changeBacksty' : 'defaultBacksty'"
  11. @click="changeStation(item.no)">
  12. {{ item.stationName }}
  13. </p>
  14. </div>
  15. </el-scrollbar>
  16. </el-col>
  17. </el-row>
  18. </div>
  19. <div class="lineMain" v-loading="loading">
  20. <el-row>
  21. <el-col :span="12" :style="pageHeight" style="padding-right: 10px">
  22. <div class="lineStyle1">
  23. <div id="monthChartBar" :style="chartsHeight"></div>
  24. </div>
  25. <div class="lineStyle1">
  26. <el-row style="width: 100%; text-align: center">
  27. <el-col :span="3" v-for="item in showpieColor" :key="item.name">
  28. <span class="pieColorLine" :style="{ background: item.value }"></span>
  29. <span :style="!theme ? 'color: #fff' : ''"
  30. style="font-size: 12px; margin-left: 8px">{{ item.name }}</span>
  31. </el-col>
  32. </el-row>
  33. <div style="display: flex">
  34. <div id="pieChartY" :style="pieHeight"></div>
  35. <div id="pieChartS" :style="pieHeight"></div>
  36. </div>
  37. </div>
  38. </el-col>
  39. <el-col :span="12" :style="pageHeight">
  40. <div class="lineStyle1">
  41. <div id="yearChartBar" :style="chartsHeight"></div>
  42. <div :style="tableHeight">
  43. <div style="display: flex; margin: 10px 0">
  44. <!-- <el-button type="primary" disabled>年发电量报告</el-button> -->
  45. </div>
  46. <div class=" warn-table tablestyle">
  47. <el-table :data="tableData" border style="width: 100%"
  48. element-loading-background="rgba(0,0,0,.5)" :header-cell-style="{
  49. padding: '4px',
  50. fontSize: '10px',
  51. fontWeight: bold,
  52. border: '0.5px solid rgba(0,0,0,.5) !important',
  53. }" :cell-style="{
  54. height: '40px',
  55. padding: '3px',
  56. fontSize: '10px',
  57. 'border-top': '0px solid rgba(0,0,0,.5)',
  58. 'border-bottom': '1px solid rgba(0,0,0,.5)',
  59. 'border-right': '1px solid rgba(0,0,0,.5)',
  60. }">
  61. <el-table-column prop="name" label="月份" width="54" align="center">
  62. <template #default="scope">
  63. <span>{{scope.row.name.substring(0,2)}}</span><br>
  64. <span>{{scope.row.name.substring(2,scope.row.name.length)}}</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column :prop="item.value" width="60" :label="item.name"
  68. v-for="(item, index) in tableColumn" :key="index">
  69. </el-table-column>
  70. <el-table-column prop="statistic" width="60" label="合计" />
  71. </el-table>
  72. </div>
  73. </div>
  74. </div>
  75. </el-col>
  76. </el-row>
  77. </div>
  78. </div>
  79. </template>
  80. <script>
  81. import {
  82. apiGetStationDL,
  83. apiGetmonthlyPower,
  84. apiGetannualPower,
  85. } from "../../api/api";
  86. import jsonData from "./component/statisticalSummary.json";
  87. export default {
  88. data() {
  89. return {
  90. windTurbines: "",
  91. windTurbinesName: "",
  92. itemVal: "",
  93. stationData: [],
  94. tableData: [],
  95. pieColor: [],
  96. showpieColor: [],
  97. tableColumn: [],
  98. loading: false,
  99. echartsTheme: "",
  100. theme: null,
  101. };
  102. },
  103. watch: {
  104. "$store.state.theme": {
  105. handler: function (newVal, oldVal) {
  106. this.theme = newVal;
  107. this.echartsTheme = !newVal ? "dark" : "";
  108. // this.getStationData();
  109. },
  110. immediate: true,
  111. },
  112. },
  113. created() {
  114. // this.initPageData();
  115. this.getStationData();
  116. (this.pieColor = [{
  117. value: "",
  118. name: "一月",
  119. },
  120. {
  121. value: "",
  122. name: "二月",
  123. },
  124. {
  125. value: "",
  126. name: "三月",
  127. },
  128. {
  129. value: "",
  130. name: "四月",
  131. },
  132. {
  133. value: "",
  134. name: "五月",
  135. },
  136. {
  137. value: "",
  138. name: "六月",
  139. },
  140. {
  141. value: "",
  142. name: "七月",
  143. },
  144. {
  145. value: "",
  146. name: "八月",
  147. },
  148. {
  149. value: "",
  150. name: "九月",
  151. },
  152. {
  153. value: "",
  154. name: "十月",
  155. },
  156. {
  157. value: "",
  158. name: "十一月",
  159. },
  160. {
  161. value: "",
  162. name: "十二月",
  163. },
  164. {
  165. value: "",
  166. name: "未发电量",
  167. },
  168. ]),
  169. (this.tableColumn = [{
  170. value: "january",
  171. name: "一月",
  172. },
  173. {
  174. value: "february",
  175. name: "二月",
  176. },
  177. {
  178. value: "march",
  179. name: "三月",
  180. },
  181. {
  182. value: "april",
  183. name: "四月",
  184. },
  185. {
  186. value: "may",
  187. name: "五月",
  188. },
  189. {
  190. value: "june",
  191. name: "六月",
  192. },
  193. {
  194. value: "july",
  195. name: "七月",
  196. },
  197. {
  198. value: "august",
  199. name: "八月",
  200. },
  201. {
  202. value: "september",
  203. name: "九月",
  204. },
  205. {
  206. value: "october",
  207. name: "十月",
  208. },
  209. {
  210. value: "november",
  211. name: "十一月",
  212. },
  213. {
  214. value: "december",
  215. name: "十二月",
  216. },
  217. ]);
  218. },
  219. computed: {
  220. pageHeight() {
  221. return {
  222. height: document.documentElement.clientHeight - 100 + "px",
  223. };
  224. },
  225. chartsHeight() {
  226. let height = (document.documentElement.clientHeight - 140) / 2 + "px";
  227. return {
  228. width: "100%",
  229. height: height,
  230. };
  231. },
  232. pieHeight() {
  233. let height = (document.documentElement.clientHeight - 270) / 2 + "px";
  234. return {
  235. width: "100%",
  236. height: height,
  237. };
  238. },
  239. tableHeight() {
  240. let height = (document.documentElement.clientHeight - 150) / 2 + "px";
  241. return {
  242. width: "100%",
  243. height: height,
  244. };
  245. },
  246. },
  247. methods: {
  248. initPageData() {
  249. const that = this;
  250. that.stationData = []
  251. that.$nextTick(() => {
  252. that.stationData = jsonData.dlStationsAllData.list;
  253. let obj = {
  254. stationName: "全域数据",
  255. no: -1,
  256. itemVal: 0,
  257. };
  258. that.stationData.unshift(obj);
  259. that.windTurbines = jsonData.dlStationsAllData.list[0].no;
  260. that.windTurbinesName = jsonData.dlStationsAllData.list[0].stationName;
  261. that.itemVal = jsonData.dlStationsAllData.list[0].itemVal;
  262. this.stationData[0].showBac = true;
  263. {
  264. let xAxis = [];
  265. let series = [];
  266. let series1 = [];
  267. let legend = [];
  268. jsonData.monthlyPowerGenerationReportData.dateList.forEach((item) => {
  269. xAxis.push(item.substring(0, item.indexOf(" ") + 1));
  270. });
  271. jsonData.monthlyPowerGenerationReportData.dataFormatList.forEach(
  272. (iten, index) => {
  273. legend.push(iten.name);
  274. let seriesObj = {
  275. name: iten.name,
  276. type: "line",
  277. data: iten.data.map((it) => {
  278. return that.$utils.isHasNum(it);
  279. }),
  280. symbol: "none",
  281. };
  282. series.push(seriesObj);
  283. let seriesObj1 = {
  284. name: iten.name,
  285. type: "bar",
  286. barGap: "1",
  287. emphasis: {
  288. focus: "series",
  289. },
  290. data: iten.data.map((it) => {
  291. return that.$utils.isHasNum(it);
  292. }),
  293. };
  294. series1.push(seriesObj1);
  295. }
  296. );
  297. that.getPowerBar(
  298. "monthChartBar",
  299. "当月-日发电量",
  300. xAxis,
  301. legend,
  302. series1
  303. );
  304. }
  305. let monthLen = 0;
  306. monthLen = new Date().getMonth() + 1;
  307. // 表格数据处理
  308. that.getTableData2(jsonData.annualPowerGenerationReportData.list3);
  309. // 柱状图数据处理
  310. that.getBarData(
  311. jsonData.annualPowerGenerationReportData.list3,
  312. monthLen
  313. );
  314. //饼状图数据处理
  315. that.getPieData(
  316. jsonData.annualPowerGenerationReportData.list3,
  317. monthLen
  318. );
  319. that.loading = false;
  320. });
  321. },
  322. changeStation(val) {
  323. this.windTurbines = val;
  324. this.stationData.forEach((item) => {
  325. if (item.no === val) {
  326. this.windTurbinesName = item.stationName;
  327. item.showBac = true;
  328. } else {
  329. item.showBac = false;
  330. }
  331. });
  332. this.getWindSpeed();
  333. this.getYearData();
  334. },
  335. getStationData() {
  336. let that = this;
  337. that.loading = true;
  338. apiGetStationDL().then((datas) => {
  339. that.stationData = datas.data.list;
  340. let obj = {
  341. stationName: "全域数据",
  342. no: -1,
  343. itemVal: 0,
  344. };
  345. that.stationData.unshift(obj);
  346. that.windTurbines = datas.data.list[0].no;
  347. that.windTurbinesName = datas.data.list[0].stationName;
  348. that.itemVal = datas.data.list[0].itemVal;
  349. this.stationData[0].showBac = true;
  350. that.getWindSpeed("only");
  351. that.getYearData("only");
  352. });
  353. },
  354. // 月发电量及功率预测--曲线图
  355. getWindSpeed() {
  356. let that = this;
  357. let params = {
  358. stationNumber: that.windTurbines,
  359. itemVal: that.itemVal,
  360. };
  361. apiGetmonthlyPower(params).then((datas) => {
  362. if (datas && datas.data) {
  363. let xAxis = [];
  364. let series = [];
  365. let series1 = [];
  366. let legend = [];
  367. if (datas.data.dateList.length > 0) {
  368. datas.data.dateList.forEach((item) => {
  369. xAxis.push(item.substring(0, item.indexOf(" ") + 1));
  370. });
  371. }
  372. if (datas.data.dataFormatList.length > 0) {
  373. datas.data.dataFormatList.forEach((iten, index) => {
  374. legend.push(iten.name);
  375. let seriesObj = {
  376. name: iten.name,
  377. type: "line",
  378. data: iten.data.map((it) => {
  379. return that.$utils.isHasNum(it);
  380. }),
  381. symbol: "none",
  382. };
  383. series.push(seriesObj);
  384. let seriesObj1 = {
  385. name: iten.name,
  386. type: "bar",
  387. barGap: "1",
  388. emphasis: {
  389. focus: "series",
  390. },
  391. data: iten.data.map((it) => {
  392. return that.$utils.isHasNum(it);
  393. }),
  394. };
  395. series1.push(seriesObj1);
  396. });
  397. }
  398. that.getPowerBar(
  399. "monthChartBar",
  400. "当月-日发电量",
  401. xAxis,
  402. legend,
  403. series1
  404. );
  405. }
  406. });
  407. },
  408. // 获取年发电量数据
  409. getYearData() {
  410. let that = this;
  411. let params = {
  412. stationNumber: that.windTurbines,
  413. itemVal: that.itemVal,
  414. };
  415. apiGetannualPower(params).then((datas) => {
  416. if (datas && datas.data.list) {
  417. let monthLen = 0;
  418. monthLen = new Date().getMonth() + 1;
  419. // 表格数据处理
  420. that.getTableData2(datas.data.list);
  421. // 柱状图数据处理
  422. that.getBarData(datas.data.list, monthLen);
  423. //饼状图数据处理
  424. that.getPieData(datas.data.list, monthLen);
  425. that.loading = false;
  426. }
  427. });
  428. },
  429. // 处理当年月发电量表格数据
  430. getTableData(datas) {
  431. let proportion = {
  432. name: "当月占比",
  433. statistic: "-",
  434. };
  435. let proportionYear = {
  436. name: "全年占比",
  437. statistic: "-",
  438. };
  439. let monthName = [
  440. "january",
  441. "february",
  442. "march",
  443. "april",
  444. "may",
  445. "june",
  446. "july",
  447. "august",
  448. "september",
  449. "october",
  450. "november",
  451. "december",
  452. ];
  453. datas.forEach((item, index) => {
  454. if (index === 0 || index === 1) {
  455. item.statistic = 0;
  456. monthName.forEach((its) => {
  457. item[its] = item[its] ? Math.ceil(item[its]) : "-";
  458. });
  459. monthName.forEach((itv) => {
  460. item.statistic += item[itv] && item[itv] !== "-" ? item[itv] : 0;
  461. });
  462. if (index === 0) {
  463. item.name = "计划发电";
  464. } else if (index === 1) {
  465. item.name = "实际发电";
  466. }
  467. } else if (index === 2 || index === 3) {
  468. item.statistic = "-";
  469. monthName.forEach((itv) => {
  470. item[itv] =
  471. item[itv] && item[itv] !== null ?
  472. (item[itv] * 100).toFixed(2) + "%" :
  473. "-";
  474. });
  475. if (index === 2) {
  476. item.name = "短期准确率";
  477. } else if (index === 3) {
  478. item.name = "超短准确率";
  479. }
  480. }
  481. });
  482. // 当月占比
  483. monthName.forEach((itc) => {
  484. proportion[itc] = this.$utils.ratioCalculation(
  485. datas[1][itc],
  486. datas[0][itc]
  487. );
  488. });
  489. datas.splice(2, 0, proportion);
  490. // 全年占比
  491. monthName.forEach((itc) => {
  492. proportionYear[itc] = this.$utils.ratioCalculation(
  493. datas[1][itc],
  494. datas[0].statistic
  495. );
  496. });
  497. datas.splice(3, 0, proportionYear);
  498. let num = 0;
  499. let num2 = 0;
  500. let num3 = 0;
  501. monthName.forEach((itb, index) => {
  502. if (datas[4][itb] && datas[4][itb] !== "-") {
  503. num += 1;
  504. num2 += datas[4][itb].replace("%", "") / 100;
  505. }
  506. if (datas[5][itb] && datas[5][itb] !== "-") {
  507. num3 += datas[5][itb].replace("%", "") / 100;
  508. }
  509. });
  510. //全年占比统计
  511. proportionYear.statistic = this.$utils.ratioCalculation(
  512. datas[1].statistic,
  513. datas[0].statistic
  514. );
  515. //短期准确率统计
  516. datas[4].statistic = (num2 / num).toFixed(2) * 100 + "%";
  517. //超短期准确率统计
  518. datas[5].statistic = (num3 / num).toFixed(2) * 100 + "%";
  519. this.tableData = datas;
  520. },
  521. getTableData2(datas) {
  522. let nameArr = ["预测发电", "实际发电", "计划发电", "当月占比", "全年占比", "短期准确率", "超短准确率"]
  523. let monthName = [
  524. "january",
  525. "february",
  526. "march",
  527. "april",
  528. "may",
  529. "june",
  530. "july",
  531. "august",
  532. "september",
  533. "october",
  534. "november",
  535. "december",
  536. ];
  537. datas.forEach((it, idx) => {
  538. let statisticNum = 0
  539. it.name = nameArr[idx]
  540. if (it.name === "预测发电" || it.name === "实际发电" || it.name === "计划发电") {
  541. monthName.forEach(o => {
  542. if (it[o] !== null) {
  543. // it[o] = Number(it[o].toFixed(2))
  544. it[o] = Math.ceil(it[o])
  545. statisticNum = statisticNum + it[o]
  546. } else {
  547. statisticNum = statisticNum + 0
  548. }
  549. })
  550. it.statistic = Math.ceil(statisticNum)
  551. } else if (it.name === "当月占比" || it.name === "全年占比") {
  552. monthName.forEach(o => {
  553. if (it[o] !== null) {
  554. it[o] = Number(it[o].toFixed(2))
  555. statisticNum = statisticNum + it[o]
  556. } else {
  557. statisticNum = statisticNum + 0
  558. }
  559. })
  560. it.statistic = statisticNum.toFixed(2)
  561. }
  562. // it.statistic = Math.ceil(statisticNum)
  563. })
  564. this.tableData = datas;
  565. },
  566. //处理当年月发电量柱状图数据
  567. getBarData(datas, val) {
  568. let xAxisAll = [
  569. "一月",
  570. "二月",
  571. "三月",
  572. "四月",
  573. "五月",
  574. "六月",
  575. "七月",
  576. "八月",
  577. "九月",
  578. "十月",
  579. "十一月",
  580. "十二月",
  581. ];
  582. let xAxis = [];
  583. for (let i = 0; i < val; i++) {
  584. xAxis.push(xAxisAll[i]);
  585. }
  586. let legend = ["预测发电", "实际发电", "计划发电"];
  587. let series = [{
  588. name: "预测发电",
  589. type: "bar",
  590. barGap: "1",
  591. emphasis: {
  592. focus: "series",
  593. },
  594. data: []
  595. },
  596. {
  597. name: "实际发电",
  598. type: "bar",
  599. barGap: "1",
  600. emphasis: {
  601. focus: "series",
  602. },
  603. data: []
  604. },
  605. {
  606. name: "计划发电",
  607. type: "bar",
  608. barGap: "1",
  609. emphasis: {
  610. focus: "series",
  611. },
  612. data: []
  613. },
  614. ];
  615. datas.forEach((itn) => {
  616. let data = [
  617. itn.january,
  618. itn.february,
  619. itn.march,
  620. itn.april,
  621. itn.may,
  622. itn.june,
  623. itn.july,
  624. itn.august,
  625. itn.september,
  626. itn.october,
  627. itn.november,
  628. itn.december,
  629. ];
  630. if (itn.name === "计划发电") {
  631. series[2].data = data;
  632. } else if (itn.name === "实际发电") {
  633. series[1].data = data;
  634. } else if (itn.name === "预测发电") {
  635. series[0].data = data;
  636. }
  637. });
  638. this.getPowerBar(
  639. "yearChartBar",
  640. "当年-月发电量",
  641. xAxisAll,
  642. legend,
  643. series
  644. );
  645. },
  646. //处理当年月发电量饼状图数据
  647. getPieData(datas, val) {
  648. let activeval = 0;
  649. activeval += datas[1].january !== "-" ? datas[1].january * 1 : 0;
  650. activeval += datas[1].february !== "-" ? datas[1].february * 1 : 0;
  651. activeval += datas[1].march !== "-" ? datas[1].march * 1 : 0;
  652. activeval += datas[1].april !== "-" ? datas[1].april * 1 : 0;
  653. activeval += datas[1].may !== "-" ? datas[1].may * 1 : 0;
  654. activeval += datas[1].june !== "-" ? datas[1].june * 1 : 0;
  655. activeval += datas[1].july !== "-" ? datas[1].july * 1 : 0;
  656. activeval += datas[1].august !== "-" ? datas[1].august * 1 : 0;
  657. activeval += datas[1].september !== "-" ? datas[1].september * 1 : 0;
  658. activeval += datas[1].october !== "-" ? datas[1].october * 1 : 0;
  659. activeval += datas[1].november !== "-" ? datas[1].november * 1 : 0;
  660. activeval += datas[1].december !== "-" ? datas[1].december * 1 : 0;
  661. let obj = [{
  662. // value: data-activeval < 0 ? 0 : data-activeval,
  663. value: datas[0].statistic - activeval < 0 ?
  664. 0 : datas[0].statistic - activeval,
  665. name: "未发电量",
  666. }, ];
  667. for (let i = 0; i < datas.length; i++) {
  668. let seriesAll = [];
  669. let series = [];
  670. if (datas[i].name === "计划发电" || datas[i].name === "实际发电") {
  671. seriesAll = [{
  672. value: datas[i].january !== "-" ? datas[i].january * 1 : 0,
  673. name: "一月",
  674. nameEn: "january",
  675. },
  676. {
  677. value: datas[i].february !== "-" ? datas[i].february * 1 : 0,
  678. name: "二月",
  679. nameEn: "february",
  680. },
  681. {
  682. value: datas[i].march !== "-" ? datas[i].march * 1 : 0,
  683. name: "三月",
  684. nameEn: "march",
  685. },
  686. {
  687. value: datas[i].april !== "-" ? datas[i].april * 1 : 0,
  688. name: "四月",
  689. nameEn: "april",
  690. },
  691. {
  692. value: datas[i].may !== "-" ? datas[i].may * 1 : 0,
  693. name: "五月",
  694. nameEn: "may",
  695. },
  696. {
  697. value: datas[i].june !== "-" ? datas[i].june * 1 : 0,
  698. name: "六月",
  699. nameEn: "june",
  700. },
  701. {
  702. value: datas[i].july !== "-" ? datas[i].july * 1 : 0,
  703. name: "七月",
  704. nameEn: "july",
  705. },
  706. {
  707. value: datas[i].august !== "-" ? datas[i].august * 1 : 0,
  708. name: "八月",
  709. nameEn: "august",
  710. },
  711. {
  712. value: datas[i].september !== "-" ? datas[i].september * 1 : 0,
  713. name: "九月",
  714. nameEn: "september",
  715. },
  716. {
  717. value: datas[i].october !== "-" ? datas[i].october * 1 : 0,
  718. name: "十月",
  719. nameEn: "october",
  720. },
  721. {
  722. value: datas[i].november !== "-" ? datas[i].november * 1 : 0,
  723. name: "十一月",
  724. nameEn: "november",
  725. },
  726. {
  727. value: datas[i].december !== "-" ? datas[i].december * 1 : 0,
  728. name: "十二月",
  729. nameEn: "december",
  730. },
  731. ];
  732. }
  733. if (datas[i].name === "计划发电") {
  734. this.getPieChart("pieChartY", "计划发电", seriesAll);
  735. } else if (datas[i].name === "实际发电") {
  736. for (let i = 0; i < val; i++) {
  737. series.push(seriesAll[i]);
  738. }
  739. this.getPieChart("pieChartS", "实际发电", series.concat(obj), datas);
  740. }
  741. }
  742. },
  743. getPowerBar(name, title, xAxis, legend, series) {
  744. let option = {
  745. title: {
  746. text: this.windTurbinesName + title,
  747. textStyle: {
  748. fontSize: "16",
  749. fontWeight: "bold",
  750. },
  751. },
  752. tooltip: {
  753. trigger: "axis",
  754. axisPointer: {
  755. type: "shadow",
  756. },
  757. },
  758. grid: {
  759. left: title === "今日发电量预测" ? "7%" : "6%",
  760. right: "5%",
  761. bottom: "3%",
  762. containLabel: true,
  763. },
  764. legend: {
  765. // bottom: bott,
  766. right: "20",
  767. data: legend,
  768. },
  769. xAxis: [{
  770. type: "category",
  771. axisTick: {
  772. show: false,
  773. },
  774. data: xAxis,
  775. }, ],
  776. yAxis: [{
  777. type: "value",
  778. name: "万千瓦时(Wkw/h)",
  779. splitLine: {
  780. lineStyle: {
  781. color: this.theme ? "#000" : "#ccc",
  782. type: "dashed", // 修改为虚线
  783. opacity: 0.2,
  784. }
  785. }
  786. }, ],
  787. series: series,
  788. };
  789. if (!this.theme) {
  790. option.backgroundColor = "";
  791. }
  792. // 基于准备好的dom,初始化echarts实例
  793. let dom = document.getElementById(name);
  794. dom.removeAttribute("_echarts_instance_") ?
  795. dom.removeAttribute("_echarts_instance_") :
  796. "";
  797. let myChart = this.$echarts.init(dom, this.echartsTheme);
  798. myChart.setOption(option);
  799. window.addEventListener("resize", function () {
  800. myChart.resize();
  801. });
  802. },
  803. getPieChart(name, title, series, datas) {
  804. let actureData = null;
  805. if (name === "pieChartS") {
  806. datas.forEach((item) => {
  807. if (item.name === "计划发电") {
  808. actureData = item;
  809. }
  810. });
  811. }
  812. let option = {
  813. title: {
  814. text: title,
  815. bottom: 10,
  816. left: "center",
  817. },
  818. color: [
  819. "#5672c4",
  820. "#95cc7a",
  821. "#f7c75f",
  822. "#e96366",
  823. "#7ac1dd",
  824. "#47a274",
  825. "#f78254",
  826. "#9761b2",
  827. "#e57cca",
  828. "#5672c4",
  829. "#95cc7a",
  830. "#f7c75f",
  831. "#e96366",
  832. ],
  833. tooltip: {
  834. trigger: "item",
  835. formatter: (item) => {
  836. // debugger
  837. let str =
  838. `<span style="display:inline-block;margin-bottom:5px;">${item.seriesName}</span></br>`;
  839. let monthD = "";
  840. for (let i in actureData) {
  841. if (item.data.nameEn === i) {
  842. monthD = `<span style="display:inline-block;width: 55%">当月占比:</span>&nbsp;&nbsp;<span>${
  843. (item.data.value / actureData[i]).toFixed(2) * 100 + "%"
  844. }</span></br>`;
  845. }
  846. }
  847. let strMsg = `<div>
  848. <span style="display:inline-block;margin-right:4px;margin-top:3px;border-radius:10px;width:10px;height:10px;background-color:${
  849. item.color
  850. };\"></span>
  851. <span style="display:inline-block;width: 40%">${
  852. item.data.name
  853. }:</span>&nbsp;&nbsp;<span>${
  854. item.data.value
  855. }</span></br>
  856. ${monthD}
  857. <span style="display:inline-block;width: 55%">全年占比:</span>&nbsp;&nbsp;<span>${Math.ceil(
  858. item.percent
  859. )}%</span></br>
  860. </div>`;
  861. str = str + strMsg;
  862. return str;
  863. },
  864. },
  865. series: [{
  866. name: title,
  867. type: "pie",
  868. radius: "50%",
  869. center: ["50%", "50%"],
  870. data: series,
  871. emphasis: {
  872. itemStyle: {
  873. shadowBlur: 10,
  874. shadowOffsetX: 0,
  875. shadowColor: "rgba(0, 0, 0, 0.5)",
  876. },
  877. },
  878. }, ],
  879. };
  880. if (!this.theme) {
  881. option.backgroundColor = "";
  882. }
  883. // 基于准备好的dom,初始化echarts实例
  884. let dom = document.getElementById(name);
  885. dom.removeAttribute("_echarts_instance_") ?
  886. dom.removeAttribute("_echarts_instance_") :
  887. "";
  888. let myChart = this.$echarts.init(dom, this.echartsTheme);
  889. myChart.setOption(option);
  890. let op = myChart.getOption();
  891. if (name === "pieChartS") {
  892. this.changePieColor(op);
  893. }
  894. window.addEventListener("resize", function () {
  895. myChart.resize();
  896. });
  897. },
  898. changePieColor(op) {
  899. let showPie = [];
  900. op.series[0].data.forEach((item, index) => {
  901. let obj = {
  902. value: op.color[index],
  903. name: item.name,
  904. };
  905. showPie.push(obj);
  906. });
  907. this.showpieColor = showPie;
  908. },
  909. },
  910. };
  911. </script>
  912. <style lang="less">
  913. @import "../../viewsCss/statisticalSummarypageLess.less";
  914. .themeDark {
  915. .statistical_wind {
  916. .windStstus {
  917. background: #040c0b;
  918. }
  919. }
  920. .lineMain {
  921. background: #040c0b;
  922. .lineStyle1 {
  923. background: #161f1e;
  924. }
  925. }
  926. }
  927. .themeLight {
  928. .statistical_wind {
  929. .windStstus {
  930. // background: linear-gradient(0deg, transparent, #373590);
  931. }
  932. }
  933. .lineMain {
  934. background: #edeffb;
  935. .lineStyle1 {
  936. background: #fff;
  937. }
  938. }
  939. }
  940. </style>