Sfoglia il codice sorgente

修改发电机转速桨距角展示范围

liujiejie 10 mesi fa
parent
commit
a70788f6a0

+ 5 - 5
src/views/overview/components/cp/index.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2025-01-09 18:05:58
- * @LastEditTime: 2025-06-06 16:17:37
+ * @LastEditTime: 2025-06-12 09:52:54
  * @LastEditors: bogon
  * @Description: In User Settings Edit
  * @FilePath: /performance-test/src/views/overview/components/cp/index.vue
@@ -55,9 +55,9 @@
         <lineAndChildLine
           v-if="item.batchCode && !item.fieldEngineCode"
           :setUpImgData="setUpImgData"
-          :key="`${new Date().getTime()}` + item.batchCode + index"
+          :key="item.batchCode + index"
           :index="`${new Date().getTime()}` + index"
-          :ref="`${new Date().getTime()}` + item.batchCode"
+          :ref="item.batchCode"
           :fileAddr="item.fileAddr"
         >
         </lineAndChildLine>
@@ -75,9 +75,9 @@
         <lineChartsFen
           v-if="item.fieldEngineCode"
           :setUpImgData="setUpImgData"
-          :key="`${new Date().getTime()}` + item.fieldEngineCode + index"
+          :key="item.fieldEngineCode + index"
           :index="`${new Date().getTime()}` + index"
-          :ref="`${new Date().getTime()}` + item.fieldEngineCode"
+          :ref="item.fieldEngineCode"
           :fieldEngineCode="item.fieldEngineCode"
           :fileAddr="item.fileAddr"
         >

+ 3 - 3
src/views/overview/components/wind_speed/index.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2025-01-10 09:11:23
- * @LastEditTime: 2025-03-17 13:59:21
+ * @LastEditTime: 2025-06-12 09:51:20
  * @LastEditors: bogon
  * @Description: In User Settings Edit
  * @FilePath: /performance-test/src/views/overview/components/wind_spee/index.vue
@@ -44,9 +44,9 @@
         <!-- {{ item.fileAddr }} -->
         <BarChart
           :setUpImgData="setUpImgData"
-          :key="`${new Date().getTime()}` + item.batchCode + index"
+          :key="item.batchCode + index"
           :inds="`${new Date().getTime()}` + index"
-          :ref="`${new Date().getTime()}` + item.batchCode"
+          :ref="item.batchCode"
           :fileAddr="item.fileAddr"
         ></BarChart>
         <!-- <BarChart

+ 7 - 1
src/views/performance/components/chartsCom/3DDrawingChart.vue

@@ -250,6 +250,12 @@ export default {
             // tickwidth: 2,
             tickcolor: "black",
             tickangle: -10,
+            // range:
+            //   this.chartData.xaixs === "发电机转速(r/min)" ||
+            //   this.chartData.xaixs === "发电机转速(r/min)"
+            //     ? [1000, 2000]
+            //     : undefined,
+            // range: this.chartData.xaixs === "桨距角(°)" ? [-1, 20] : undefined,
           },
           yaxis: {
             title: this.chartData.yaixs,
@@ -335,7 +341,7 @@ export default {
         ],
         modeBarButtonsToRemove: [
           "sendDataToCloud",
-          "autoScale2d",
+          // "autoScale2d",
           "hoverClosest3d",
           "resetCameraLastSave3d",
           "resetCameraDefault3d",

+ 2 - 2
src/views/performance/components/chartsCom/FaultAll.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2025-01-15 14:24:59
- * @LastEditTime: 2025-06-11 09:28:37
+ * @LastEditTime: 2025-06-12 18:06:31
  * @LastEditors: bogon
  * @Description: In User Settings Edit
  * @FilePath: /performance-test/src/views/performance/components/chartsCom/FaultAll.vue
@@ -74,7 +74,7 @@ export default {
       // 故障时长的折线图数据(右侧 Y 轴)
       const lineTrace = {
         x: this.faultTypes.slice(0, 10),
-        y: this.faultDurations.slice(0, 10),
+        y: this.faultDurations.slice(0, 10).map((item) => item.toFixed(2)),
         type: "scatter",
         mode: "lines+markers", // 线性图 + 点标记
         line: { color: "#1A295D" }, // 红色折线

+ 1 - 1
src/views/performance/components/chartsCom/FaultUnit.vue

@@ -40,7 +40,7 @@ export default {
       const combined = this.faultTypes.map((name, i) => ({
         name,
         count: this.faultCounts[i],
-        durationHour: this.faultDurations[i],
+        durationHour: this.faultDurations[i].toFixed(2),
       }));
 
       // 步骤 2:按 name 字符串排序

+ 93 - 3
src/views/performance/components/chartsCom/GeneratorTemperature.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2025-01-21 11:18:49
- * @LastEditTime: 2025-06-11 10:48:07
+ * @LastEditTime: 2025-06-13 09:10:36
  * @LastEditors: bogon
  * @Description: In User Settings Edit
  * @FilePath: /performance-test/src/views/performance/components/chartsCom/GeneratorTemperature.vue
@@ -91,7 +91,17 @@ export default {
       loading: false,
       isError: false,
       colors: [...colorSchemes[0].colors],
-      typeLine: ["solid", "dot", "dash", "longdash", "dashdot", "longdashdot"],
+      typeLine: [
+        "solid",
+        "solid",
+        "dot",
+        "dot",
+        "dash",
+        "solid",
+        // "longdash",
+        // "dashdot",
+        // "longdashdot",
+      ],
     };
   },
   computed: {
@@ -118,7 +128,14 @@ export default {
     if (this.fileAddr) {
       this.$nextTick(() => {
         this.getData();
-        this.color1 = this.colorSchemes[0].colors;
+        this.color1 = [
+          "#0000F5",
+          "#377E21",
+          "#0000F5",
+          "#377E21",
+          "#000000",
+          "#F2A93B",
+        ];
       });
     }
   },
@@ -204,6 +221,8 @@ export default {
           gridcolor: "rgb(255,255,255)",
           tickcolor: "rgb(255,255,255)",
           backgroundcolor: "#e5ecf6",
+          // range: [-20],
+          min: -20,
         },
         margin: {
           l: 50,
@@ -211,6 +230,77 @@ export default {
           t: 50,
           b: 50,
         },
+        shapes: [
+          {
+            type: "line",
+            xref: "paper",
+            x0: 0,
+            x1: 1,
+            yref: "y",
+            y0: 15,
+            y1: 15,
+            line: {
+              color: "red",
+              width: 2,
+              dash: "dash",
+            },
+          },
+          {
+            type: "line",
+            xref: "paper",
+            x0: 0,
+            x1: 1,
+            yref: "y",
+            y0: -15,
+            y1: -15,
+            line: {
+              color: "red",
+              width: 2,
+              dash: "dash",
+            },
+          },
+          {
+            type: "line",
+            xref: "paper",
+            x0: 0,
+            x1: 1,
+            yref: "y",
+            y0: 5,
+            y1: 5,
+            line: {
+              color: "#F9DD70",
+              width: 2,
+              dash: "dash",
+            },
+          },
+          {
+            type: "line",
+            xref: "paper",
+            x0: 0,
+            x1: 1,
+            yref: "y",
+            y0: -5,
+            y1: -5,
+            line: {
+              color: "#F9DD70",
+              width: 2,
+              dash: "dash",
+            },
+          },
+          {
+            type: "line",
+            xref: "paper",
+            x0: 0,
+            x1: 1,
+            yref: "y",
+            y0: 0,
+            y1: 0,
+            line: {
+              color: "#fff", // 设置为黑色
+              width: 2,
+            },
+          },
+        ],
         plot_bgcolor: "#e5ecf6",
         gridcolor: "#fff",
         bgcolor: "#e5ecf6", // 设置背景颜色

+ 7 - 1
src/views/performance/components/chartsCom/Time3DChart.vue

@@ -229,6 +229,12 @@ export default {
             tickcolor: "black",
             zeroline: false,
             tickangle: -10,
+            // range:
+            //   this.chartData.xaixs === "发电机转速(r/min)" ||
+            //   this.chartData.xaixs === "发电机转速(r/min)"
+            //     ? [1000, 2000]
+            //     : undefined,
+            // range: this.chartData.xaixs === "桨距角(°)" ? [-1, 20] : undefined,
           },
           // 对 Y 轴不显示默认标题,只保留 tick 标签,并适当加大 standoff 以防止标签挤在一起
           yaxis: {
@@ -337,7 +343,7 @@ export default {
         ],
         modeBarButtonsToRemove: [
           "sendDataToCloud",
-          "autoScale2d",
+          // "autoScale2d",
           "hoverClosest3d",
           "resetCameraLastSave3d",
           "resetCameraDefault3d",

+ 79 - 47
src/views/performance/components/chartsCom/lineAndChildLine.vue

@@ -89,15 +89,19 @@ export default {
   },
   watch: {
     themeColor: {
-      handler() {
-        this.color1 = this.themeColor;
-        this.updateChartColor();
+      handler(newVal, oldVal) {
+        if (JSON.stringify(newVal) !== JSON.stringify(oldVal)) {
+          this.color1 = newVal;
+          this.updateChartColor();
+        }
       },
       deep: true,
     },
     setUpImgData: {
-      handler(newType) {
-        this.drawChart();
+      handler(newVal, oldVal) {
+        if (JSON.stringify(newVal) !== JSON.stringify(oldVal)) {
+          this.drawChart();
+        }
       },
       deep: true,
     },
@@ -125,9 +129,9 @@ export default {
           // 使用 nextTick 来确保 DOM 渲染完成后绘制图表
           nextTick(() => {
             this.drawChart();
-            this.isError = false;
-            this.loading = false;
           });
+          this.isError = false;
+          this.loading = false;
         } catch (error) {
           console.error("Error loading data:", error);
           this.isError = true;
@@ -141,47 +145,54 @@ export default {
         return false;
       }
       const data = [];
-      this.chartData &&
-        this.chartData.data &&
-        this.chartData.data.forEach((turbine, index) => {
-          // 判断图表类型,根据类型调整绘制方式
-          const chartConfig = {
-            x: turbine.xData, // X 数据
-            y: turbine.yData, // Y 数据
-            name: turbine.engineName, // 使用机组名称
-            line: {
-              color:
-                this.color1.length > 0
-                  ? this.color1[index % this.color1.length]
-                  : this.colors[index % this.colors.length], // 为每个机组分配不同的颜色
-            },
-            marker: {
-              color:
-                this.color1.length > 0
-                  ? this.color1[index % this.color1.length]
-                  : this.colors[index % this.colors.length], // 为每个机组分配不同的颜色
-            },
-            hovertemplate:
-              `${this.chartData.xaixs}:` +
-              ` %{x} <br> ` +
-              `${this.chartData.yaixs}:` +
-              "%{y} <br>",
-          };
-          if (this.chartData.yaixs === "概率密度函数") {
-            console.log(this.color1[5], this.colors[5], "this.color1");
-            chartConfig.line.color =
-              this.color1.length > 0 ? this.color1[7] : this.colors[7]; // 为每个机组分配不同的颜色
-          }
-          if (this.chartType === "line") {
-            chartConfig.mode = "lines"; // 如果是折线图
-            chartConfig.fill = "none";
-          } else if (this.chartType === "bar") {
-            // chartConfig.type = "bar"; // 如果是柱状图
-            chartConfig.fill = "tonexty";
-          }
+      const newData =
+        this.chartData.analysisTypeCode === "风电机组叶尖速比和风速分析"
+          ? this.chartData &&
+            this.chartData.data &&
+            JSON.parse(JSON.stringify(this.chartData.data)).sort((a, b) => {
+              return a.engineName.localeCompare(b.engineName);
+            })
+          : JSON.parse(JSON.stringify(this.chartData.data));
+      newData.forEach((turbine, index) => {
+        // 判断图表类型,根据类型调整绘制方式
+        const chartConfig = {
+          x: turbine.xData, // X 数据
+          y: turbine.yData, // Y 数据
+          name: turbine.engineName, // 使用机组名称
+          line: {
+            color:
+              this.color1.length > 0
+                ? this.color1[index % this.color1.length]
+                : this.colors[index % this.colors.length], // 为每个机组分配不同的颜色
+          },
+          marker: {
+            color:
+              this.color1.length > 0
+                ? this.color1[index % this.color1.length]
+                : this.colors[index % this.colors.length], // 为每个机组分配不同的颜色
+          },
+          hovertemplate:
+            `${this.chartData.xaixs}:` +
+            ` %{x} <br> ` +
+            `${this.chartData.yaixs}:` +
+            "%{y} <br>",
+        };
+        if (this.chartData.yaixs === "概率密度函数") {
+          console.log(this.color1[5], this.colors[5], "this.color1");
+          chartConfig.line.color =
+            this.color1.length > 0 ? this.color1[7] : this.colors[7]; // 为每个机组分配不同的颜色
+        }
+        if (this.chartType === "line") {
+          chartConfig.mode = "lines"; // 如果是折线图
+          chartConfig.fill = "none";
+        } else if (this.chartType === "bar") {
+          // chartConfig.type = "bar"; // 如果是柱状图
+          chartConfig.fill = "tonexty";
+        }
+
+        data.push(chartConfig);
+      });
 
-          data.push(chartConfig);
-        });
       const layout = {
         title: {
           text: this.chartData.title || this.chartData.data[0].title,
@@ -195,12 +206,28 @@ export default {
           gridcolor: "rgb(255,255,255)",
           tickcolor: "rgb(255,255,255)",
           backgroundcolor: "#e5ecf6",
+          range:
+            this.chartData.analysisTypeCode === "风电机组风能利用系数分析" &&
+            this.chartData.contract_Cp_curve_xData
+              ? [
+                  0,
+                  Math.max(
+                    ...this.chartData.contract_Cp_curve_xData
+                      .map(Number)
+                      .filter((val) => !isNaN(val))
+                  ) * 0.9,
+                ]
+              : undefined,
         },
         yaxis: {
           title: this.chartData.yaixs || "Y轴", // 纵坐标标题
           gridcolor: "rgb(255,255,255)",
           tickcolor: "rgb(255,255,255)",
           backgroundcolor: "#e5ecf6",
+          range:
+            this.chartData.analysisTypeCode === "风电机组风能利用系数分析"
+              ? [0, 1.5]
+              : undefined,
         },
         margin: {
           l: 50,
@@ -274,6 +301,11 @@ export default {
       };
     },
   },
+  beforeUnmount() {
+    if (this.cancelToken) {
+      this.cancelToken.cancel("组件卸载,取消请求");
+    }
+  },
 };
 </script>
 

+ 40 - 21
src/views/performance/components/chartsCom/lineChartsFen.vue

@@ -64,8 +64,11 @@ export default {
   },
   watch: {
     setUpImgData: {
-      handler(newType) {
-        this.drawChart();
+      handler(newVal, oldVal) {
+        if (JSON.stringify(newVal) !== JSON.stringify(oldVal)) {
+          console.log("更新图表");
+          this.drawChart();
+        }
       },
       deep: true,
     },
@@ -117,22 +120,17 @@ export default {
     },
     // 绘制图表
     drawChart() {
-      const sortedData = this.chartData.data.sort((a, b) => {
-        if (
-          a.engineCode === this.fieldEngineCode &&
-          b.engineCode !== this.fieldEngineCode
-        ) {
-          return 1;
-        }
-        if (
-          a.engineCode !== this.fieldEngineCode &&
-          b.engineCode === this.fieldEngineCode
-        ) {
-          return -1;
-        }
-        return 0;
+      // 先整体排序:目标 engineCode 放最后,其他按 engineName 升序
+      const sortedData = [...this.chartData.data].sort((a, b) => {
+        const aIsTarget = a.engineCode === this.fieldEngineCode;
+        const bIsTarget = b.engineCode === this.fieldEngineCode;
+        // 如果 a 是目标、b 不是 => a 排后(返回 1)
+        if (aIsTarget && !bIsTarget) return 1;
+        // 如果 b 是目标、a 不是 => b 排后(返回 -1)
+        if (!aIsTarget && bIsTarget) return -1;
+        // 如果都不是目标项,按 engineName 升序排序
+        return a.engineName.localeCompare(b.engineName);
       });
-
       const data = [];
       const lineData = [];
 
@@ -146,10 +144,15 @@ export default {
           name: turbine.engineName,
           line: { color },
           marker: { color },
-          hovertemplate: `
-            ${this.chartData.xaixs}: %{x} <br>
-            ${this.chartData.yaixs}: %{y} <br>
-          `,
+          // hovertemplate: `
+          //   ${this.chartData.xaixs}: %{x} <br>
+          //   ${this.chartData.yaixs}: %{y} <br>
+          // `,
+          hovertemplate:
+            `${this.chartData.xaixs}:` +
+            ` %{x} <br> ` +
+            `${this.chartData.yaixs}:` +
+            "%{y} <br>",
         };
 
         if (this.chartType === "line") {
@@ -194,12 +197,28 @@ export default {
           gridcolor: "rgb(255,255,255)",
           tickcolor: "rgb(255,255,255)",
           backgroundcolor: "#e5ecf6",
+          range:
+            this.chartData.analysisTypeCode === "风电机组风能利用系数分析" &&
+            this.chartData.contract_Cp_curve_xData
+              ? [
+                  0,
+                  Math.max(
+                    ...this.chartData.contract_Cp_curve_xData
+                      .map(Number)
+                      .filter((val) => !isNaN(val))
+                  ) * 0.9,
+                ]
+              : undefined,
         },
         yaxis: {
           title: this.chartData.yaixs || "Y轴",
           gridcolor: "rgb(255,255,255)",
           tickcolor: "rgb(255,255,255)",
           backgroundcolor: "#e5ecf6",
+          range:
+            this.chartData.analysisTypeCode === "风电机组风能利用系数分析"
+              ? [0, 1]
+              : undefined,
         },
         margin: {
           l: 50,

+ 8 - 2
src/views/performance/components/chartsCom/powerMarkers2DCharts.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2024-09-11 14:32:12
- * @LastEditTime: 2025-06-11 10:49:13
+ * @LastEditTime: 2025-06-13 13:43:47
  * @LastEditors: bogon
  * @Description: In User Settings Edit
  * @FilePath: /performance-test/src/views/performance/components/chartsCom/powerMarkers2DCharts.vue
@@ -259,7 +259,7 @@ export default {
                   [1, "#1B2973"],
                 ], // 默认颜色渐变
             colorbar: {
-              title: data.colorbartitle, // 色标标题
+              title: data.colorbartitle || "月份", // 色标标题
               tickvals: tickvals, // 设置刻度值
               ticktext: ticktext, // 设置刻度文本
               tickmode: "array", // 使用数组模式
@@ -305,6 +305,11 @@ export default {
           tickcolor: "rgb(255,255,255)",
           backgroundcolor: "#e5ecf6",
           showbackground: true, // 显示背景
+          range:
+            this.chartData.xaixs === "发电机转速(r/min)" ||
+            this.chartData.xaixs === "发电机转速(r/min)"
+              ? [1000, 2000]
+              : undefined,
         },
         yaxis: {
           title: this.chartData.yaixs,
@@ -312,6 +317,7 @@ export default {
           tickcolor: "rgb(255,255,255)",
           backgroundcolor: "#e5ecf6",
           showbackground: true, // 显示背景
+          range: this.chartData.yaixs === "桨距角(°)" ? [-1, 20] : undefined,
         },
         showlegend: false,
         plot_bgcolor: "#e5ecf6",