zmc
2023-10-12 f3acb8ce787f3df0eda633031473be4e6a9ff448
src/views/analysis/graph/AllRate.vue
@@ -1,10 +1,6 @@
<template>
  <div>
    <el-container>
      <!-- <el-header style="text-align:right; font-size:15px ">
         <i class="el-icon-s-data" style="font-size: 15px;color:rgb(226,207,207);margin-right:10px;"></i>
        <span style="color:rgb(226,207,207);">百分比数据</span>
        </el-header> -->
    <el-main> 
      <el-form :inline="true"  class="demo-form-inline">
@@ -41,13 +37,15 @@
    </el-form-item>
 
       <el-form-item>
        <el-button type="primary" @click="fetchData">展示图</el-button>
        <el-button type="primary" :loading="button.showChartButton" @click="fetchData">展示图</el-button>
     </el-form-item> 
     </el-form>
    <el-card>
      <div class="chart-container" ref="chart"></div>
    <el-card v-loading="loading">
      <div class="chart-container" ref="lineChart" v-show="!isNoData"></div>
      <el-empty v-show="isNoData" :image-size="200" />
    </el-card>
  </el-main>
</el-container>
  </div>
@@ -56,10 +54,17 @@
<script>
import * as echarts from 'echarts'
import axiosInstance from '../../../utils/request.js'
import axiosInstanceInstance from '../../../utils/request.js'
export default {
  data() {
    return {
      button:{
        // 展示图的按钮
        showChartButton:false,
      },
      isNoData:false,
      chart:null,
      loading:false,
      chartData: [],     //保存查询的结果
      //devId:'',          //设备编号
      begin:'2023-05-01',         //开始时间
@@ -192,6 +197,7 @@
  mounted(){
    //  默认加载付小姐在成都 5月1号到15号的
      this.fetchData()
      window.addEventListener('resize',this.updateChart)
    },
  methods: {
    
@@ -215,10 +221,20 @@
      if(this.end){
        params['end'] = this.end
      }
      axiosInstance.get('/data/id',{params:params})
      this.loading = true
      this.button.showChartButton = true
      axiosInstanceInstance.get('/data/id',{params:params})
        .then(response => {
          this.chartData = response.data.data
          this.loading = false
          this.button.showChartButton = false
        if(response.data.data.length==0){
          alert('该时段无数据')
          this.isNoData = true
          return
        }
        // 移除空数据状态
        this.isNoData = false
          this.drawChart()
        })
    },
@@ -271,12 +287,9 @@
        keyExceeding.push(item.keyExceedingRate.slice(0,-1))
      })
      let chart = echarts.init(this.$refs.chart)
      chart.setOption({
        title: {
          text: '比率',
          //left: 'center'
        },
      this.chart = echarts.init(this.$refs.lineChart)
      this.chart.setOption({
        grid: {
          left: '3%',
          right: '4%',
@@ -287,7 +300,7 @@
  
        legend: {
          data: ['净化器开启率','超标率','数据有效率','日在线率','中午在线率','晚上在线率','重点时段在线率','中午有效率','晚上有效率','重点时段有效率','中午开启率','晚上开启率','重点时段开启率','中午超标率','晚上超标率','重点时段超标率'],
          //type: "scroll"
        },
        toolbox: {    //工具栏
          top:20,
@@ -394,12 +407,12 @@
          type: 'line',
          data: keyExceeding
        },
      ]
      })
    },
    updateChart(){
      this.chart.resize()
    }
  }
}
@@ -407,17 +420,21 @@
<style scoped>
  .el-card {
    margin-top: 40px;
    margin-top: 50px;
    width:90%;
    border-radius: 9px;
  }
.chart-container {
    width: 100%;
    height: 600px;
    width:100%;
    height: 540px;
  }
  .el-header {
    background-color: #010408;
    color: #333;
    line-height: 60px;
  } 
:deep().el-form .el-form-item__label{
  color: #000000;
  font-weight: bold;
}
</style>