echartCircle.vue
1.27 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 :id="coustomId" class="coustom-main"></div>
</template>
<script>
import * as echarts from 'echarts'
export default {
name: 'echartCircle',
props: {
coustomId: {
type: String,
default: ''
},
bgColor: {
type: String,
default: ''
},
lineData: {
type: Array
}
},
data() {
return {}
},
watch: {
lineData() {
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: ['rgba(0,0,0,.06)', this.bgColor],
label: {
show: false,
position: 'center'
},
labelLine: {
show: false
},
data: [{ value: (this.lineData[0] == 0 && this.lineData[1] == 0) ? 1 : this.lineData[1] },{ value: this.lineData[0] } ]
}
]
}
option && myChart.setOption(option)
}
},
}
</script>
<style lang="scss" scoped>
.coustom-main {
width: 64px;
height: 64px;
}
</style>