echartCircle.vue
1.29 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
69
70
71
72
<template>
<div :id="coustomId" class="coustom-main"></div>
</template>
<script>
import * as echarts from "echarts";
export default {
name: "echartCircle",
props: {
coustomId: {
type: String,
default: "",
},
bgColor1: {
type: String,
default: "",
},
bgColor2: {
type: String,
default: "",
},
coustomCount: {
type: String,
},
},
data() {
return {};
},
watch: {
coustomCount() {
this.getEchart()
}
},
methods: {
getEchart() {
const chartDom = document.getElementById(this.coustomId);
const myChart = echarts.init(chartDom);
let option;
option = {
series: [
{
type: "pie",
radius: ["40%", "70%"],
hoverAnimation: false,
avoidLabelOverlap: false,
color: [this.bgColor1, this.bgColor2],
label: {
show: false,
position: "center",
},
labelLine: {
show: false,
},
data: [{ value: 100 }, { value: this.coustomCount}],
},
],
};
option && myChart.setOption(option);
},
}
};
</script>
<style lang="scss" scoped>
.coustom-main {
width: 74px;
height: 74px;
}
</style>