index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <template>
  2. <div>
  3. <!-- <div>
  4. <panel :title="'偏航对风分析'" :showLine="false">
  5. <div style="height: 200px" class="chart" id="linechart"></div>
  6. </panel>
  7. </div> -->
  8. <div>
  9. <panel :title="'功率曲线拟合'" :showLine="false">
  10. <el-button @click="get()">查询</el-button>
  11. <ScatterLineChart
  12. xTitle="风速(m/s)"
  13. yTitle="功率(kw)"
  14. :showLegend="true"
  15. :height="'calc(70vh)'"
  16. :symbolSize="5"
  17. :data="scatterData"
  18. :lineData="lineData"
  19. ></ScatterLineChart>
  20. </panel>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. import Panel from "../../../components/coms/panel/panel.vue";
  26. import ScatterLineChart from "./scatter-line-chart.vue";
  27. import util from "@/helper/util.js";
  28. import partten from "@/helper/partten.js";
  29. import * as echarts from "echarts";
  30. export default {
  31. // 使用组件
  32. components: {
  33. Panel,
  34. ScatterLineChart,
  35. },
  36. data() {
  37. return {
  38. scatterData: [
  39. {
  40. title: "",
  41. value: [],
  42. },
  43. ],
  44. lineData: { legends: [], data: [[], []] },
  45. };
  46. },
  47. created() {
  48. // this.$nextTick(() => {
  49. // this.getPHAnalyse();
  50. // });
  51. },
  52. methods: {
  53. get() {
  54. // this.getPHAnalyse();
  55. this.getScatter();
  56. },
  57. //散点数据
  58. getScatter() {
  59. let that = this;
  60. that.API.requestData({
  61. method: "POST",
  62. baseURL: "http://192.168.10.5:9002/",
  63. subUrl: "scatter/list",
  64. data: {
  65. station: "NSS_FDC",
  66. wtId: "NG01_01",
  67. time: "2021-11",
  68. },
  69. success(res) {
  70. if (res.code == 200 && res.data) {
  71. let scatterArr = [
  72. {
  73. title: "NG01有用点",
  74. value: res.data.scatter,
  75. },
  76. ];
  77. that.scatterData = scatterArr;
  78. let lineArr = {
  79. legends: ["实际", "修正"],
  80. data: [[], []],
  81. };
  82. res.data.lineactual.forEach((ele) => {
  83. lineArr.data[0].push(ele[1]);
  84. });
  85. res.data.lineoptimal.forEach((ele) => {
  86. lineArr.data[1].push(ele[1]);
  87. });
  88. that.lineData = lineArr;
  89. }
  90. },
  91. });
  92. },
  93. //偏航对风分析
  94. getPHAnalyse() {
  95. let that = this;
  96. // that.API.requestData({
  97. // method: "POST",
  98. // baseURL: "http://192.168.10.5:9002/",
  99. // subUrl: "scatter/range",
  100. // data: {
  101. // station: "NSS_FDC",
  102. // wtId: "NG01_01",
  103. // time: "2021-11",
  104. // },
  105. // success(res) {
  106. // if (res.code == 200 && res.data) {
  107. const xData = [
  108. "-50",
  109. "-49",
  110. "-48",
  111. "-47",
  112. "-46",
  113. "-45",
  114. "-44",
  115. "-43",
  116. "-42",
  117. "-41",
  118. "-40",
  119. "-39",
  120. "-38",
  121. "-37",
  122. "-36",
  123. "-35",
  124. "-34",
  125. "-33",
  126. "-32",
  127. "-31",
  128. "-30",
  129. "-29",
  130. "-28",
  131. "-27",
  132. "-26",
  133. "-25",
  134. "-24",
  135. "-23",
  136. "-22",
  137. "-21",
  138. "-20",
  139. "-19",
  140. "-18",
  141. "-17",
  142. "-16",
  143. "-15",
  144. "-14",
  145. "-13",
  146. "-12",
  147. "-11",
  148. "-10",
  149. "-9",
  150. "-8",
  151. "-7",
  152. "-6",
  153. "-5",
  154. "-4",
  155. "-3",
  156. "-2",
  157. "-1",
  158. "0",
  159. "1",
  160. "2",
  161. "3",
  162. "4",
  163. "5",
  164. "6",
  165. "7",
  166. "8",
  167. "9",
  168. "10",
  169. "11",
  170. "12",
  171. "13",
  172. "14",
  173. "15",
  174. "16",
  175. "17",
  176. "18",
  177. "19",
  178. "20",
  179. "21",
  180. "22",
  181. "23",
  182. "24",
  183. "25",
  184. "26",
  185. "27",
  186. "28",
  187. "29",
  188. "30",
  189. "31",
  190. "32",
  191. "33",
  192. "34",
  193. "35",
  194. "36",
  195. "37",
  196. "38",
  197. "39",
  198. "40",
  199. "41",
  200. "42",
  201. "43",
  202. "44",
  203. "45",
  204. "46",
  205. "47",
  206. "48",
  207. "49",
  208. "50",
  209. ];
  210. const lData = [
  211. 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 4, 3, 3, 1, 3, 1, 2, 5, 5, 5, 5,
  212. 9, 15, 16, 25, 39, 42, 62, 77, 103, 108, 161, 189, 238, 309, 418, 480,
  213. 538, 635, 777, 877, 1021, 1170, 1224, 1341, 1409, 1421, 3016, 1493,
  214. 1437, 1389, 1334, 1177, 1135, 1031, 865, 693, 599, 538, 404, 318, 252,
  215. 207, 200, 140, 103, 81, 77, 66, 46, 32, 27, 16, 19, 9, 4, 9, 10, 5, 7,
  216. 7, 3, 1, 3, 2, 1, 1, 0, 0, 2, 2, 1, 1, 0, 1, 1, 0, 2,
  217. ];
  218. // const dataMap = res.data[0];
  219. // for (let key in dataMap) {
  220. // let tmpKey = key.replace(/r/, "");
  221. // tmpKey = tmpKey.replace(/f/, "-");
  222. // if (tmpKey < 100) {
  223. // xData.push(tmpKey);
  224. // lData.push(dataMap[key]);
  225. // }
  226. // }
  227. console.log(xData);
  228. console.log(lData);
  229. let option = {
  230. color: ["#05bb4c", "#4b55ae", "#fa8c16", "#f8de5b"],
  231. tooltip: {
  232. trigger: "axis",
  233. backgroundColor: "rgba(0,0,0,0.4)",
  234. borderColor: partten.getColor("gray"),
  235. textStyle: {
  236. color: "#fff",
  237. fontSize: util.vh(16),
  238. },
  239. },
  240. legend: {
  241. show: false,
  242. data: ["偏航次数"],
  243. right: 56,
  244. icon: "circle",
  245. itemWidth: 6,
  246. inactiveColor: "#606769",
  247. textStyle: {
  248. color: partten.getColor("grayl"),
  249. fontSize: 12,
  250. },
  251. },
  252. toolbox: {
  253. brush: {
  254. type: ["lineX", "clear"],
  255. },
  256. },
  257. //拖动选择属性
  258. brush: {
  259. xAxisIndex: "all",
  260. brushLink: "all",
  261. throttleDelay: 1,
  262. outOfBrush: {
  263. colorAlpha: 0.5,
  264. },
  265. },
  266. grid: {
  267. top: util.vh(40),
  268. left: util.vh(60),
  269. right: util.vh(130),
  270. bottom: util.vh(24),
  271. },
  272. xAxis: [
  273. {
  274. name: "对风偏差(度)",
  275. type: "category",
  276. boundaryGap: false,
  277. axisLabel: {
  278. formatter: "{value}",
  279. fontSize: util.vh(14),
  280. textStyle: {
  281. color: partten.getColor("gray"),
  282. },
  283. },
  284. data: xData,
  285. },
  286. ],
  287. yAxis: [
  288. {
  289. type: "value",
  290. name: "数量",
  291. axisLabel: {
  292. formatter: "{value}",
  293. fontSize: util.vh(14),
  294. },
  295. splitLine: {
  296. lineStyle: {
  297. color: partten.getColor("gray") + 55,
  298. type: "dashed",
  299. },
  300. },
  301. },
  302. ],
  303. series: [
  304. {
  305. name: "数量",
  306. type: "line",
  307. smooth: true,
  308. zlevel: 0,
  309. lineStyle: {
  310. normal: {
  311. color: "#05bb4c",
  312. width: 1,
  313. },
  314. },
  315. yAxisIndex: 0,
  316. data: lData,
  317. },
  318. ],
  319. };
  320. const chart = echarts.init(document.getElementById("linechart"));
  321. chart.clear();
  322. chart.setOption(option);
  323. //拖动选择属性
  324. chart.dispatchAction({
  325. type: "brush",
  326. areas: [
  327. {
  328. brushType: "lineX",
  329. coordRange: ["-15", "15"],
  330. xAxisIndex: 0,
  331. },
  332. ],
  333. });
  334. chart.on("brushSelected", function (params) {
  335. var mainSeries = params.batch[0].areas;
  336. var selectedItems = []; //选中区域的横纵标
  337. for (var i = 0; i < mainSeries.length; i++) {
  338. if (mainSeries[i].coordRange && mainSeries[i].coordRange.length > 0) {
  339. for (var j = 0; j < mainSeries[i].coordRange.length; j++) {
  340. selectedItems.push(mainSeries[i].coordRange[j]);
  341. }
  342. }
  343. }
  344. console.log(selectedItems);
  345. });
  346. this.resize = function () {
  347. chart.resize();
  348. };
  349. window.addEventListener("resize", this.resize);
  350. // }
  351. // },
  352. // });
  353. },
  354. },
  355. };
  356. </script>
  357. <style lang="less" scoped>
  358. </style>