dedsudiyu 1 dzień temu
rodzic
commit
a6c272b3b2
1 zmienionych plików z 76 dodań i 52 usunięć
  1. 76 52
      src/views/components/right.vue

+ 76 - 52
src/views/components/right.vue

@@ -124,17 +124,25 @@
           let glData = []
           let glTime = []
           let glBzData = []
+          let minTop = res.data.temperature[0].temperature;
+          let minBottom = res.data.humidity[0].humidity;
           //温度
           for (let i = 0; i < res.data.temperature.length; i++) {
             wdData.push(res.data.temperature[i].temperature)
             wdTime.push(res.data.temperature[i].time)
             wdBzData.push(res.data.wdMin)
+            if(minTop>res.data.temperature[i].temperature){
+              minTop = res.data.temperature[i].temperature;
+            }
           }
           //湿度
           for (let i = 0; i < res.data.humidity.length; i++) {
             sdData.push(res.data.humidity[i].humidity)
             sdTime.push(res.data.humidity[i].time)
             sdBzData.push(res.data.sdMin)
+            if(minBottom>res.data.humidity[i].humidity){
+              minBottom = res.data.humidity[i].humidity;
+            }
           }
           //功率
           for (let i = 0; i < res.data.power.length; i++) {
@@ -142,9 +150,19 @@
             glTime.push(res.data.power[i].time)
             glBzData.push(res.data.powerMin)
           }
-          this.eCharts1(wdData, wdTime, wdBzData)
-          this.eCharts2(sdData, sdTime, sdBzData)
-          this.eCharts3(glData, glTime, glBzData)
+          if(res.data.wdMin != 0){
+            if(minTop>res.data.wdMin){
+              minTop = res.data.wdMin;
+            }
+          }
+          if(res.data.sdMin != 0){
+            if(minBottom>res.data.sdMin){
+              minBottom = res.data.sdMin;
+            }
+          }
+          this.eCharts1(wdData, wdTime, wdBzData,minTop);
+          this.eCharts2(sdData, sdTime, sdBzData,minBottom);
+          this.eCharts3(glData, glTime, glBzData);
         })
       },
       iotCameraFindByCondition(obj) {
@@ -267,7 +285,7 @@
           }
         )
       },
-      eCharts1(Data, Time, BzData) {
+      eCharts1(Data, Time, BzData,min) {
         let colorA = this.$echarts.graphic.LinearGradient(
           0,
           0,
@@ -357,7 +375,7 @@
           },
           yAxis: {
             name: '',
-            min:0,
+            min:min,
             minInterval:1,
             nameTextStyle: {
               color: '#fff',
@@ -421,31 +439,33 @@
                 }
               }
             },
-            {
-              data: BzData,
+          ]
+        }
+        if(BzData[0] != 0){
+          option.series.push({
+            data: BzData,
               name: '',
-              type: 'line',
-              symbol: 'circle',
-              smooth: true,
-              symbolSize: 0,//不需要点就设置0
-              lineStyle: {
-                width: 2,
-                type: 'dashed'
-              },
-              itemStyle: {
-                borderWidth: 5,
+            type: 'line',
+            symbol: 'circle',
+            smooth: true,
+            symbolSize: 0,//不需要点就设置0
+            lineStyle: {
+            width: 2,
+              type: 'dashed'
+          },
+            itemStyle: {
+              borderWidth: 5,
                 borderColor: 'rgba(255,86,86,1)',
                 color: 'rgba(255,86,86,1)'
-              },
-              areaStyle: {
-                color: 'rgba(255,86,86,1)',
+            },
+            areaStyle: {
+              color: 'rgba(255,86,86,1)',
                 normal: {
-                  //线性渐变,前4个参数分别是x0,y0,x2,y2(范围0~1);
-                  color: colorB
-                }
+                //线性渐变,前4个参数分别是x0,y0,x2,y2(范围0~1);
+                color: colorB
               }
             }
-          ]
+          })
         }
         if (this.$echarts.getInstanceByDom(document.getElementById('right-eCharts-1'))) {
           this.$echarts.dispose(document.getElementById('right-eCharts-1'))
@@ -454,7 +474,7 @@
         this.eChartsData1.clear()
         this.eChartsData1.setOption(option)
       },
-      eCharts2(Data, Time, BzData) {
+      eCharts2(Data, Time, BzData,min) {
         let colorA = this.$echarts.graphic.LinearGradient(
           0,
           0,
@@ -544,7 +564,7 @@
           },
           yAxis: {
             name: '',
-            min:0,
+            min:min,
             minInterval:1,
             nameTextStyle: {
               color: '#fff',
@@ -608,31 +628,33 @@
                 }
               }
             },
-            {
-              data: BzData,
-              name: '',
-              type: 'line',
-              symbol: 'circle',
-              smooth: true,
-              symbolSize: 0,//不需要点就设置0
-              lineStyle: {
-                width: 2,
-                type: 'dashed'
-              },
-              itemStyle: {
-                borderWidth: 5,
-                borderColor: 'rgba(1,131,250,1)',
-                color: 'rgba(1,131,250,1)'
-              },
-              areaStyle: {
-                color: 'rgba(1,131,250,1)',
-                normal: {
-                  //线性渐变,前4个参数分别是x0,y0,x2,y2(范围0~1);
-                  color: colorB
-                }
+          ]
+        }
+        if(BzData[0] != 0){
+          option.series.push({
+            data: BzData,
+            name: '',
+            type: 'line',
+            symbol: 'circle',
+            smooth: true,
+            symbolSize: 0,//不需要点就设置0
+            lineStyle: {
+              width: 2,
+              type: 'dashed'
+            },
+            itemStyle: {
+              borderWidth: 5,
+              borderColor: 'rgba(1,131,250,1)',
+              color: 'rgba(1,131,250,1)'
+            },
+            areaStyle: {
+              color: 'rgba(1,131,250,1)',
+              normal: {
+                //线性渐变,前4个参数分别是x0,y0,x2,y2(范围0~1);
+                color: colorB
               }
             }
-          ]
+          })
         }
         if (this.$echarts.getInstanceByDom(document.getElementById('right-eCharts-2'))) {
           this.$echarts.dispose(document.getElementById('right-eCharts-2'))
@@ -795,7 +817,10 @@
                 }
               }
             },
-            {
+          ]
+        }
+        if(BzData[0] != 0){
+          option.series.push({
               data: BzData,
               name: '',
               type: 'line',
@@ -818,8 +843,7 @@
                   color: colorB
                 }
               }
-            }
-          ]
+            })
         }
         if (this.$echarts.getInstanceByDom(document.getElementById('right-eCharts-3'))) {
           this.$echarts.dispose(document.getElementById('right-eCharts-3'))