master
2022-03-23 0da9c6652870390cd07bc90211aefe095445baf6
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
<template>
    <div class="category-ratio">
        <div class="category-ratio__header">
            <span>销售额类别占比</span>
        </div>
 
        <div class="category-ratio__container">
            <v-chart :option="chartOption" autoresize />
        </div>
    </div>
</template>
 
<script lang="ts">
import { defineComponent, reactive } from "vue";
 
export default defineComponent({
    setup() {
        const chartOption = reactive({
            tooltip: {
                trigger: "item",
                formatter: "{a} <br/>{b}: {c} ({d}%)"
            },
            legend: {
                bottom: 30,
                left: "center",
                data: ["手机", "相机", "耳机", "音箱", "手表"]
            },
            color: ["#3AA1FF", "#36CBCB", "#F2637B", "#975FE5", "#FBD437"],
            series: [
                {
                    name: "访问来源",
                    type: "pie",
                    radius: ["50%", "60%"],
                    center: ["50%", "40%"],
                    avoidLabelOverlap: false,
                    hoverAnimation: false,
                    label: {
                        show: false,
                        position: "center"
                    },
                    emphasis: {
                        label: {
                            show: true,
                            fontSize: "30",
                            fontWeight: "bold"
                        }
                    },
                    labelLine: {
                        show: false
                    },
                    data: [
                        { value: 335, name: "手机" },
                        { value: 310, name: "相机" },
                        { value: 234, name: "耳机" },
                        { value: 135, name: "音箱" },
                        { value: 500, name: "手表" }
                    ],
                    itemStyle: {
                        normal: {
                            borderColor: "#fff",
                            borderWidth: 4
                        }
                    },
                    roundCap: 1
                }
            ]
        });
 
        return {
            chartOption
        };
    }
});
</script>
 
<style lang="scss" scoped>
.category-ratio {
    &__header {
        display: flex;
        align-items: center;
        height: 50px;
        font-size: 15px;
        font-weight: bold;
        padding: 0 20px;
    }
 
    &__container {
        height: 415px;
        padding: 0 20px;
        box-sizing: border-box;
 
        .echarts {
            width: 100%;
        }
    }
}
</style>