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
| <template>
| <div class="hola-container">
| <div class="hola-content" ref="hola"></div>
| </div>
| </template>
|
| <script>
| import * as echarts from 'echarts';
| let holaChart = null;
|
| const config = {
| tooltip: {
| trigger: 'item'
| },
| legend: {
| top: '5%',
| left: 'center'
| },
| series: [
| {
| type: 'pie',
| radius: ['40%', '70%'],
| avoidLabelOverlap: false,
| itemStyle: {
| borderRadius: 10,
| borderColor: '#fff',
| borderWidth: 2
| },
| label: {
| show: false,
| position: 'center'
| },
| emphasis: {
| label: {
| show: false,
| fontSize: 40,
| fontWeight: 'bold'
| }
| },
| labelLine: {
| show: false
| },
| data: []
| }
| ]
| }
|
| const nameList = {
| data1: '工单数',
| data2: '恢复数',
| data3: '待恢复数',
| data4: '产生违约事项数',
| data5: '产生违约责任数',
| }
| export default {
| props: {
| activeData: {
| type: Object,
| default: () => { },
| }
| },
| data() {
| return {
|
| }
| },
| methods: {
| changeConfig(data) {
| if (data) {
| let temp = [];
| Object.keys(data).filter(key => key !== 'name').forEach(key => {
| temp.push({
| name: nameList[key],
| value: data[key]
| });
| });
| config.series[0].data = temp;
| holaChart.setOption(config, true);
| }
|
| }
| },
| watch: {
| activeData: {
| handler(newVal, oldVal) {
| this.$nextTick(() => {
| this.changeConfig(newVal);
| })
| },
| immediate: true,
| }
| },
| mounted() {
| holaChart = echarts.init(this.$refs.hola);
| holaChart.setOption(config, true);
| }
| }
| </script>
|
| <style lang="scss" scoped>
| .hola-container {
| width: 100%;
| height: 100%;
|
| .hola-content {
| width: 100%;
| height: 100%;
| }
| }
| </style>
|
|