index.vue 9.21 KB
Newer Older
zhangjianqian's avatar
zhangjianqian committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
<template>
  <div style="width: 100%">
    <div class="division">
      <div  style=" width: 500px;height: calc(50vh - 84px)">
        <div id="myChartone" style="text-align:center;width:80%;height:80%;margin:auto;padding-top:30px;"></div>
      </div>
      <div id="myChartfour" style=" width: 1000px;height: calc(50vh - 84px)"></div>
    </div>
    <div class="division">
      <div style=" width: 500px;height: calc(50vh - 84px)">
        <div id="myCharttwo" style="text-align:center;width:80%;height:80%;margin:auto;padding-top:30px;"></div>
      </div>
      <div id="myChartthree" style=" width: 1000px;height: calc(50vh - 84px)"></div>
    </div>
  </div>
</template>

<script>
  import {getStatistics  } from "@/api/system/alarm";
  import * as echarts from 'echarts';
    export default {
        name: "chartindex",
      data() {
        return {
          statistics:{}
        };
      },
      created() {
        this.getTong();
      },
      methods: {
        getTong() {
          getStatistics().then(response => {
            this.statistics = response.data;
            this.drawLine();
            this.drawLine2();
            this.drawLine3();
            this.drawLine4();
          });
        },
        drawLine() {
          console.log(this.statistics);
          // 基于准备好的dom,初始化echarts实例
          let myChart1 = this.$echarts.init(document.getElementById("myChartone"));
          // 绘制图表
          myChart1.setOption({
            color:['#ff0000',
              '#ff7744',
              '#ffaa33',
              '#bbbb00',
              '#ccff33'],
            tooltip: {
              trigger: 'item'
            },
            legend: {
              top: '0',
              left: 'center'
            },
            series: [
              {
                name: '报警级别',
                type: 'pie',
                radius: ['40%', '80%'],
                avoidLabelOverlap: false,

                //itemStyle: {
                //  borderRadius: 50,
                 // borderColor: '#fff',
                 // borderWidth: 5
                // },
                label: {
                  show: false,
                  position: 'center'
                },
                emphasis: {
                  label: {
                    show: true,
                    fontSize: '30',
                    fontWeight: 'bold'
                  }
                },
                labelLine: {
                  show: false
                },
                data:this.statistics.levelList
                // data: [
                //   { value: 1048, name: '高高报' },
                //   { value: 735, name: '高报' },
                //   { value: 580, name: '低报' },
                //   { value: 484, name: '低低报' },
                //   { value: 300, name: '开关量' }
                // ],
              }
            ]

          });
        },
        drawLine2() {
          // 基于准备好的dom,初始化echarts实例
          let myChart1 = this.$echarts.init(document.getElementById("myCharttwo"));
          // 绘制图表
          myChart1.setOption({
            color:['#109CF1','#ff0000'],
            angleAxis: {
              clockwise: false, // 刻度增长是否按顺时针,默认顺时针(true)。
              axisLine: {
                show: false
              },
              axisLabel: {
                show: false
              },
              splitLine: {
                show: false
              },
              axisTick: {
                show: false
              },
              min: 0,
              max: this.statistics.notProcessed+this.statistics.processed, //一圈的刻度值
              startAngle: 0 //初始角度
            },
            radiusAxis: {
              type: 'category',
              data: ['1', '2', '3', '4'], // 极坐标径向轴中的类目,这边有几个数,
              // 就代表径向轴分了几份,和series中的data对应,这样就可以撑开圆环
              z: 10,
              axisLine: {
                show: false
              },
              axisTick: {
                show: false
              },
              axisLabel: {
                show: false
              },
            },
            polar: {
            },
            series: [{
              type: 'bar',
              data: [0, 0, 0, this.statistics.processed],
              coordinateSystem: 'polar',
              name: '已处理',
              roundCap: true,
              stack: 'a',
              itemStyle: {
                borderRadius: 10,
                borderColor: '#fff',
                borderWidth: 3
              },
            }, {
              type: 'bar',
              data: [0, 0, 0, this.statistics.notProcessed], // 前面的0,累计还是0,这样径向轴上的对应的分区总数就是0,不会显示圆环
              coordinateSystem: 'polar',
              name: '未处理',
              stack: 'a',
              roundCap: true,
              itemStyle: {
                borderRadius: 10,
                borderColor: '#fff',
                borderWidth: 3
              },
            }
            ],
            legend: {
              show: true,
              top: '90%',
              // data: ['待整改', '已整改']
            }

          });
        },
        drawLine3() {
          // 基于准备好的dom,初始化echarts实例
          let myChart1 = this.$echarts.init(document.getElementById("myChartthree"));
          // 绘制图表
          myChart1.setOption({
            title: {
              text: '每天设备报警数量(30天)'
            },
            tooltip: {
              trigger: 'axis'
            },
            legend: {
              data: ['报警设备']
            },
            grid: {
              left: '3%',
              right: '4%',
              bottom: '3%',
              containLabel: true
            },
            toolbox: {
              feature: {
                saveAsImage: {}
              }
            },
            xAxis: {
              type: 'category',
              boundaryGap: false,
              data:this.statistics.dateLabel
            //   data: ['1', '2', '3', '4', '5', '6', '7','8', '9', '10', '10', '12', '13', '14',
            //     '15', '16', '17', '18', '19', '20','21', '22', '23', '24', '25', '26', '27', '28', '29', '30']
             },
            yAxis: {
              type: 'value'
            },
            series: [
              {
                name: '报警设备数量',
                type: 'line',
                stack: 'Total',
                data:this.statistics.dateNum
              //   data: [150, 230, 224, 218, 135, 147, 260, 230, 224, 218, 135, 147, 260, 230, 224, 218, 135, 147,
              //     230, 224, 218, 135, 147, 260, 230, 224, 218, 135, 147, 260]
               }
            ]

          });
        },
        drawLine4() {
          // 基于准备好的dom,初始化echarts实例
          let myChart1 = this.$echarts.init(document.getElementById("myChartfour"));
          // 绘制图表
          myChart1.setOption({
            legend: {},
            tooltip: {},
            dataset: {
              dimensions: ['product', '2015', '2016', '2017', '2018'],
              source: [
                { product: 'Matcha Latte', 2015: 43.3, 2016: 85.8, 2017: 93.7, 2018: 90.7 },
                { product: 'Milk Tea', 2015: 83.1, 2016: 73.4, 2017: 55.1 , 2018: 90.7},
                { product: 'Cheese Cocoa', 2015: 86.4, 2016: 65.2, 2017: 82.5, 2018: 90.7 },
                { product: 'Walnut Brownie', 2015: 72.4, 2016: 53.9, 2017: 39.1 , 2018: 90.7}
              ]
            },
            xAxis: { type: 'category' },
            yAxis: {},
            // Declare several bar series, each will be mapped
            // to a column of dataset.source by default.
            series: [{ type: 'bar' }, { type: 'bar' }, { type: 'bar' }, { type: 'bar' }]
            // title: {
            //   text: '不同类型设备报警数量(30天)',
            // },
            // tooltip: {
            //   trigger: 'axis',
            //   axisPointer: {
            //     type: 'shadow'
            //   }
            // },
            // grid: {
            //   left: '3%',
            //   right: '4%',
            //   bottom: '3%',
            //   containLabel: true
            // },
            // xAxis: [
            //   {
            //     type: 'category',
            //     //data: ['液位', '压力', '温度', '有毒气体', '可燃气体'],
            //     data:this.statistics.typeLabel,
            //     axisTick: {
            //       alignWithLabel: true
            //     }
            //   }
            // ],
            // yAxis: [
            //   {
            //     type: 'value'
            //   }
            // ],
            // series: [
            //   {
            //     name: '报警设备数',
            //     type: 'bar',
            //     barWidth: '60%',
            //     //data: [10, 52, 200, 334, 390, 330, 220]
            //     data: this.statistics.typeNum
            //   }
            // ]
          });
        },
      },
    }
</script>

<style scoped>
  .division{
    display:flex;
    flex-direction:row;
    justify-content:flex-start;
  }
</style>