age.vue
1.38 KB
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
<template>
<div class="user-box">
<div class="title title-icon">
<span class="icon"></span>
<span>客户年龄分布</span>
</div>
<div class="user-container flex">
<pie-chart ref="pieChart" :id="chart.id" :size="chart.size" :list="ageData" :keys="chart.keys" :radius="chart.radius" height="6.1vh" @pieAction="pieAction"></pie-chart>
<div class="legend-item flex">
<span :style="{ background: descColor }"></span>
{{ selectData && selectData.name }}
</div>
</div>
</div>
</template>
<script>
export default {
name: 'Age',
data() {
return {
chart: {
id: 'user-age',
keys: ['name', 'num'],
radius: ['56%', '85%'],
size: '8px'
},
selectData: '',
descColor: '',
ageData: []
}
},
created() {
this.$bus.$on('userData', data => {
this.ageData = data.ageData
})
},
methods: {
pieAction(data) {
this.descColor = this.$refs.pieChart.descColor
this.selectData = data
}
}
}
</script>
<style lang="scss" scoped>
.user-box {
.title {
font-size: 10px;
}
.legend-item {
width: 4.65vw;
height: 1.83vh;
background: #0d133b;
font-weight: 400;
font-size: 9px;
color: #fff;
span {
width: 5px;
height: 5px;
border-radius: 50%;
margin: 4px;
display: inline-block;
}
}
}
</style>