Browse Source

Update modeControl.vue

moccus 1 year ago
parent
commit
5a1f31b3f6
1 changed files with 38 additions and 22 deletions
  1. 38 22
      src/components/modeControl/modeControl.vue

+ 38 - 22
src/components/modeControl/modeControl.vue

@@ -284,11 +284,45 @@ methods: {
     let chartDom = document.getElementById("mainEcharts");
     let myChart = echarts.init(chartDom);
     let option;
+    const data1 = this.$store.state.currentStation
+      ? Number(
+          this.showDate?.stationOverviewInfos[
+            this.$store.state.currentStation
+          ]?.realTimePower?.value
+        )
+      : Number(this.showDate.realTimePower?.value);
+    const data2 = this.$store.state.currentStation
+      ? Number(
+          this.showDate?.stationOverviewInfos[
+            this.$store.state.currentStation
+          ]?.realTimePower?.value
+        ) *1.15
+      : Number(this.showDate.realTimePower?.value)*1.15;
+    const data3 = this.$store.state.currentStation
+      ? Number(
+          this.showDate?.stationOverviewInfos[
+            this.$store.state.currentStation
+          ]?.agcPowerSet?.value
+        )
+      : Number(this.showDate.agcPowerSet?.value);
+
+    
+    const ceilNumber = (number) => {
+      let bite = 0;
+      if(number < 100){
+        return 100;
+      }
+      while( number >= 100 ){
+        number /= 100;
+        bite += 1;
+      }
+      return Math.ceil(number) * Math.pow(100,bite);
+    }
     option = {
       series: [
           {
               type: "gauge",
-              max: 600,
+              max: ceilNumber(Math.max(data1,data2,data3)),
               splitNumber: 8,
               radius: '70%',
               anchor: {
@@ -374,27 +408,9 @@ methods: {
           },
       ],
     };
-    option.series[0].data[0].value = this.$store.state.currentStation
-      ? Number(
-          this.showDate?.stationOverviewInfos[
-            this.$store.state.currentStation
-          ]?.realTimePower?.value
-        )
-      : Number(this.showDate.realTimePower?.value);
-    option.series[0].data[1].value = this.$store.state.currentStation
-      ? Number(
-          this.showDate?.stationOverviewInfos[
-            this.$store.state.currentStation
-          ]?.realTimePower?.value
-        ) *1.15
-      : Number(this.showDate.realTimePower?.value)*1.15;
-    option.series[0].data[2].value = this.$store.state.currentStation
-      ? Number(
-          this.showDate?.stationOverviewInfos[
-            this.$store.state.currentStation
-          ]?.agcPowerSet?.value
-        )
-      : Number(this.showDate.agcPowerSet?.value);
+    option.series[0].data[0].value = data1
+    option.series[0].data[1].value = data2
+    option.series[0].data[2].value = data3
     myChart.setOption(option, true);
   },
   ChangeBar(values) {