2023西安数博会CIM演示-【前端】-Web
AdaKing88
2023-08-21 bc03b832caa49bbcd2674fe4cae3701b5059bf95
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
<template>
  <div class="pie1">
    <div class="header">
      <span class="title1">城市应急事件统计</span>
    </div>
    <div class="chartPart">
      <chart :optionIn="option1" />
    </div>
  </div>
</template>
 
<script>
import chart from "@/components/chart.vue";
export default {
  components: {
    chart
  },
  name: "pie1",
  data() {
    return {
      chart: null,
      option1: {},
    }
  },
  watch: {
    option: {
      deep: true,
      handler(newVal) {
        this.setOptions(newVal)
      },
    },
  },
  mounted() {
    this.initChart()
  },
 
  methods: {
    initChart() {
      let color = ['#0385fd', '#00ffff', '#ffff00', '#c93333'];
      const OptionData = [
        { name: '一般事故', value: 30 },
        { name: '较大事故', value: 40 },
        { name: '重大事故', value: 5 },
        { name: '特别重大事故', value: 25 },
      ]
      let option = {
        color: color,
        legend: {
          bottom: '0%',
          type: 'plain',
          textStyle: {
            color: 'rgba(212, 232, 254, 1)',
            fontSize: 12
          },
          // itemGap: 1,
          itemWidth: 10,
          itemHeight: 10,
          icon: 'roundRect',
          data: ['一般事故', '较大事故', '重大事故', '特别重大事故']
        },
        polar: {
          radius: 120,
          center: ['50%', '50%']
        },
        grid: {
          left: '16px',
          right:'16px'
        },
        angleAxis: {
          axisLine: {
            show: false,
          },
          axisLabel: {
            show: false,
          },
        },
        radiusAxis: {
          show: false,
        },
        series: [
          {
            color: color,
            type: 'pie',
            radius: ['45%', '60%'],
            labelLine: {
              normal: {
                lineStyle: {
                  type: 'solid'
                }
              }
            },
            label: {
              normal: {
                formatter: (params) => {
                  return '{c|' + params.percent.toFixed(0) + '%}'
                },
                rich: {
                  c: {
                    fontSize: 20,
                    lineHeight: 20,
                    color: '#fff'
                  }
 
                }
              }
            },
            data: OptionData,
          },
          
        ]
      };
      this.option1 = option
    },
  },
 
 
}
</script>
 
<style scoped lang="less">
.pie1 {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
 
  .header {
    width: 304px;
    height: 27.5px;
    margin-left: 20px;
    margin-top: 20px;
    background-image: url("~@/assets/img/menuTitle1.png");
    background-repeat: no-repeat;
    background-size: 100% 100%;
    font-family: PangMenZhengDao;
    text-shadow: 0px 6px 9px #20618e;
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-shrink: 0;
    align-self: flex-start;
 
    .title1 {
      margin-left: 30px;
      font-size: 15px;
      color: #ffffff;
    }
 
  }
 
  .chartPart {
    width: 100%;
    height: 240px;
    position: relative;
  }
}
</style>