ex1.vue
3.75 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<template>
<div>
<div class="pie">
<div id="pie1">
<!-- 为 ECharts 准备一个具备大小(宽高)的 DOM -->
<div id="main1" style="width: 100%; height: 260px"></div>
</div>
</div>
</div>
</template>
<script>
// 引入基本模板
let echarts = require("echarts/lib/echarts");
// 引入饼状图组件
require("echarts/lib/chart/pie");
// 引入提示框和title组件
require("echarts/lib/component/tooltip");
require("echarts/lib/component/title");
export default {
created() {},
mounted() {
// this.initData();
},
methods: {
//初始化数据
initData(x, y) {
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById("main1"));
// 绘制图表
myChart.setOption({
title: {
text: "今日进件量分析",
subtext: "",
left: "center",
},
tooltip: {
trigger: "item",
formatter: "{a} <br/>{b} : {c} ({d}%)",
},
legend: {
orient: "vertical",
left: "left",
},
series: [
{
name: "今日进件数据分析",
type: "pie",
radius: "70%",
avoidLabelOverlap: true,
// roseType: "angle",
// label: {
// normal: {
// show: false,
// },
// },
// labelLine: {
// normal: {
// show: false,
// },
// },
data: [
{
value: y[0],
name: x[0],
itemStyle: {
normal: {
label: {
show: true,
formatter: function (params, option) {
if (params.data.value == 0) {
params.data.label.normal.show = false;
params.data.labelLine.normal.show = false;
}
},
},
labelLine: {
show: true,
},
},
},
},
{
value: y[1],
name: x[1],
itemStyle: {
normal: {
label: {
show: true,
formatter: function (params, option) {
if (params.data.value == 0) {
params.data.label.normal.show = false;
params.data.labelLine.normal.show = false;
}
},
},
labelLine: {
show: true,
},
},
},
},
{
value: y[2],
name: x[2],
itemStyle: {
normal: {
label: {
show: true,
formatter: function (params, option) {
if (params.data.value == 0) {
params.data.label.normal.show = false;
params.data.labelLine.normal.show = false;
}
},
},
labelLine: {
show: true,
},
},
},
},
],
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: "rgba(0, 0, 0, 0.5)",
},
},
},
],
});
},
},
};
</script>