ZhangXianQiang
2024-04-10 1e891ef7bc8291562d27108e05196699d6229129
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
<template>
  <div class="data-container">
    <wrapper-title :title="'工单数据'" :path="'/monitorServe/car'"></wrapper-title>
 
    <div class="data-content">
      <div class="data-panel">
 
      </div>
      <div class="data-panel">
        <div class="panel-title">
          <div class="icon">
            <img src="@/assets/icons/arrow.png" alt="">
          </div>
          <div class="title">
            分区工单数
          </div>
        </div>
        <div class="echart-container">
          <div id="barChart" ref="barChart"></div>
        </div>
      </div>
    </div>
  </div>
</template>
 
<script>
import * as echarts from 'echarts';
import WrapperTitle from '../wrapper-title/index';
let chart = null;
export default {
  name: 'ScreenData',
  components: {
    WrapperTitle
  },
  data() {
    return {
      dataList: {
        name: ['富顺县', '荣县', '高新区', '自流井区', '贡井区', '大安区', '沿滩区'],
        data1: [210, 310, 40, 102, 111, 201, 123],
        data2: [20, 30, 10, 10, 11, 21, 5],
      },
    }
  },
  methods: {
    initEchart() {
      const option = {
        grid: {
          right: 0,
        },
        legend: {
          right: 0,
          textStyle: {
            color: '#447ED6'
          }
        },
        tooltip: {},
        xAxis: {
          type: 'category',
          axisLabel: {
            color: '#447ED6',
            rotate: 45
          },
          data: this.dataList.name
        },
        yAxis: {
          axisLabel: {
            color: '#4D76B0',
          },
        },
        series: [
          {
            type: 'bar',
            name: '已处理工单数',
            stack: 'total',
            itemStyle: {
              color: '#4ea8ff'
            },
            data: this.dataList.data1
          },
          {
            type: 'bar',
            name: '未处理工单数',
            stack: 'total',
            itemStyle: {
              color: '#dfc639'
            },
            data: this.dataList.data2
          },
        ]
      }
      chart.setOption(option, true);
 
    }
  },
  mounted() {
    chart = echarts.init(this.$refs.barChart);
    this.initEchart();
  }
}
</script>
 
<style lang="scss" scoped>
.data-container {
  width: 100%;
  height: 450px;
  display: flex;
  flex-direction: column;
 
  .data-content {
    flex: 1;
    background: rgba(67, 102, 155, 0.3);
    border: 1px solid rgba(47, 91, 157, 0.8);
    padding: 20px;
    box-sizing: border-box;
  }
}
 
.echart-container {
  width: 100%;
  height: 300px;
 
  #barChart {
    width: 100%;
    height: 100%;
  }
}
 
.panel-title {
  color: #b9b9b9;
  display: flex;
  align-items: center;
  .icon {
    width: 20px;
    margin-right: 5px;
    img {
      width: 100%;
      display: block;
    }
  }
}
</style>