riku
2024-07-11 505798927f75c84693cc51becf16aa525503fc92
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
<template>
  <el-row justify="space-between">
    <div class="font-small">区域风险分布</div>
    <OptionTime v-model="time"></OptionTime>
  </el-row>
  <div ref="echart" class="line-chart"></div>
</template>
<script>
import * as echarts from 'echarts'
 
export default {
  methods: {
    refresh() {
      const fontSize = 12
      const option = {
        color: ['#f56c6c', '#e6a23c', '#67c23a'],
        legend: {
          data: ['高风险', '中风险', '低风险'],
          textStyle: {
            fontSize: fontSize,
            color: 'white'
          }
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          data: [
            '江宁路街道',
            '石门二路街道',
            '南京西路街道',
            '静安寺街道',
            '曹家渡街道',
            '天目西路街道',
            '北站街道',
            '宝山路街道',
            '共和新路街道',
            '大宁路街道',
            '彭浦新村街道',
            '临汾路街道',
            '芷江西路街道',
            '彭浦镇'
          ],
          axisLabel: {
            rotate: 45,
            textStyle: {
              fontSize: fontSize
            },
            color: '#ffffff',
            textBorderColor: '#fff'
          }
        },
        yAxis: {
          type: 'value',
          axisLabel: {
            textStyle: {
              fontSize: fontSize,
              color: 'white'
            }
          }
        },
        series: [
          {
            name: '高风险',
            type: 'bar',
            stack: 'risk',
            barWidth: 10,
            data: [2, 0, 4, 3, 1, 0, 2, 0, 4, 3, 1, 0, 2, 1]
          },
          {
            name: '中风险',
            type: 'bar',
            stack: 'risk',
            data: [3, 1, 5, 4, 2, 1, 3, 1, 5, 4, 2, 1, 3, 1]
          },
          {
            name: '低风险',
            type: 'bar',
            stack: 'risk',
            data: [1, 1, 6, 2, 0, 0, 0, 0, 3, 1, 0, 2, 1, 0]
          }
        ]
      }
      this.echart.setOption(option)
    }
  },
  mounted() {
    this.echart = echarts.init(this.$refs.echart)
    this.refresh()
  }
}
</script>
<style scoped>
.line-chart {
  /* width: 200px; */
  height: 220px;
}
</style>