forked from bailicangdu/vue2-manage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisitorPie.vue
More file actions
79 lines (75 loc) · 2.54 KB
/
visitorPie.vue
File metadata and controls
79 lines (75 loc) · 2.54 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
<template>
<div class="visitorpie">
<div id="visitorpie" class="" style="width: 90%;height:450px;"></div>
</div>
</template>
<script>
import echarts from 'echarts/lib/echarts';
// 引入柱状图
import 'echarts/lib/chart/pie';
import 'echarts/lib/component/title';
import 'echarts/lib/component/legend';
export default {
mounted(){
this.myChart = echarts.init(document.getElementById('visitorpie'));
this.initData();
},
props: ['pieData'],
methods: {
initData(){
const option = {
title : {
text: '用户分布',
subtext: '',
x:'center'
},
tooltip : {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
legend: {
orient: 'vertical',
left: 'left',
data: ['北京','上海','深圳','杭州','其他']
},
series : [
{
name: '访问来源',
type: 'pie',
radius : '55%',
center: ['50%', '60%'],
data:[
{value:this.pieData.beijing, name:'北京'},
{value:this.pieData.shanghai, name:'上海'},
{value:this.pieData.shenzhen, name:'深圳'},
{value:this.pieData.hangzhou, name:'杭州'},
{value:this.pieData.qita, name:'其他'}
],
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
};
this.myChart.setOption(option);
}
},
watch: {
pieData: function (){
this.initData()
}
}
}
</script>
<style lang="less">
@import '../style/mixin';
.visitorpie{
display: flex;
justify-content: center;
margin-top: 20px;
}
</style>