zhaobao 1 year ago
parent
commit
54def04ac0
1 changed files with 43 additions and 7 deletions
  1. 43 7
      src/views/bigScreen/home/components/SensorStatus.vue

+ 43 - 7
src/views/bigScreen/home/components/SensorStatus.vue

@@ -45,14 +45,18 @@ export default {
           type: 'category',
           boundaryGap: [0, 0.01],
           axisLabel: {
-            color: '#fff'
+            color: '#fff',
+            rotate: -60,
+            fontSize: 10,
+            interval: 0
           },
           axisLine: {
             show: true
           },
           splitLine: {
             show: false
-          }
+          },
+          data: []
         },
         yAxis: {
           type: 'value',
@@ -72,21 +76,21 @@ export default {
             type: 'line',
             symbol: 'none',
             smooth: true,
-            data: [12, 32, 101, 300, 130, 80, 20]
+            data: []
           },
           {
-            name: 'C级报警',
+            name: '一般报警',
             type: 'line',
             symbol: 'none',
             smooth: true,
-            data: [20, 182, 191, 434, 290, 330, 10]
+            data: []
           },
           {
-            name: 'D级报警',
+            name: '重大报警',
             type: 'line',
             symbol: 'none',
             smooth: true,
-            data: [30, 332, 301, 334, 390, 330, 30]
+            data: []
           }
         ]
       }
@@ -114,9 +118,41 @@ export default {
     reload() {
       this.$nextTick(() => {
         this.init()
+        const currentMonthDays = this.currentMonthDays()
+        const xAxis = []
+        var date = new Date()
+        // var year = date.getFullYear()
+        // var month = date.getMonth() + 1
+        var now = date.getDate()
+
+        const level_1 = []
+        const level_2 = []
+        const level_3 = []
+        for (let i = 0; i < currentMonthDays; i++) {
+          // xAxis.push(`${year}/${month}/${i + 1}`)
+          xAxis.push(`${i + 1}`)
+          if (i <= now) {
+            level_1.push(Math.ceil(300 * Math.random()))
+            if (i % 5 === 0) { level_2.push(Math.ceil(100 * Math.random())) } else { level_2.push(0) }
+            if (i % 8 === 0) { level_3.push(Math.ceil(30 * Math.random())) } else { level_3.push(0) }
+          }
+        }
+        this.option.xAxis.data = xAxis
+        this.option.series[0].data = level_1
+        this.option.series[1].data = level_2
+        this.option.series[2].data = level_3
+        this.myChart.setOption(this.option)
         // this.goafdevstatis()
       })
     },
+
+    currentMonthDays() {
+      var date = new Date()
+      var year = date.getFullYear()
+      var month = date.getMonth() + 1
+      var d = new Date(year, month, 0)
+      return d.getDate()
+    },
     goafdevstatis() {
       const option = JSON.parse(JSON.stringify(this.option))
       goafdevstatis().then((res) => {