equity-echart.vue
2.98 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
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
111
112
113
114
115
116
117
118
119
120
121
122
<template>
<div class="output-panel">
<div :id="echartId" class="echart-view"></div>
</div>
</template>
<script>
import * as echarts from 'echarts'
export default {
name: 'echartOutput',
data() {
return {}
},
props: {
outputCircle: {
type: Object
},
echartId: {
type: String,
default: ''
},
},
watch: {
outputCircle: {
handler(value) {
this.getOutput()
},
deep: true
}
},
methods: {
getOutput() {
var chartDom = document.getElementById(this.echartId)
var myChart = echarts.init(chartDom)
var option
option = {
tooltip: {
trigger: 'item',
formatter: function (params) {
return '占比 ' + params.value + '%' + '<br>' + params.data.name + ': ' + params.data.ratio
}
},
legend: {
left: 'center',
top: '2%',
icon: 'stack',
itemHeight: 2,
itemWidth: 12,
data: [
{
name: '商城'
},
{
name: '门店服务套餐'
},
{
name: '精品升级'
},
{
name: '其他'
}
]
},
color: ['#5850FF', '#64C0A2', '#FACD67', '#F7A7B3', '#34911A'],
series: [
{
name: '访问来源',
type: 'pie',
radius: '70%',
center: ['50%', '53%'],
data: [
{ value: this.outputCircle.shopmallTotalOutputValueRadio, name: '商城', unit: '%', ratio: this.outputCircle.shopmallTotalOutputValue },
{ value: this.outputCircle.equityTotalOutputValueRadio, name: '门店服务套餐', unit: '%', ratio: this.outputCircle.equityTotalOutputValue },
{ value: this.outputCircle.boutiqueUpgradeTotalOutputValueRadio, name: '精品升级', unit: '%', ratio: this.outputCircle.boutiqueUpgradeTotalOutputValue },
{ value: this.outputCircle.otherTotalOutputValueRadio, name: '其他', unit: '%', ratio: this.outputCircle.otherTotalOutputValue }
],
itemStyle: {
normal: {
label: {
show: true
},
labelLine: {
show: true,
length: 10
}
}
}
}
]
}
option && myChart.setOption(option)
myChart.on('click', res => {
let url
switch (res.data.name) {
case '精品升级':
url = '/services/inSale/upgrade'
break
case '商城':
url = '/marketing/orderManage/index'
break
case '会员套餐':
url = '/marketing/memberCenter/setmeal'
break
}
this.$history.push(url)
})
}
}
}
</script>
<style lang="scss" scoped>
.output-panel {
width: 100%;
}
.echart-view {
height: 260px;
}
</style>>