incomeProductOption.js
2.46 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
const incomeProductOption = {
color: [
'rgba(9,71,198,0.8)',
'rgba(255,178,25,1)',
'rgba(255,178,25,0.8)',
'rgba(0,157,255,1)',
'rgba(0,157,255,0.8)',
'rgba(0,157,255,0.6)',
'rgba(0,228,115,1)',
'rgba(0,228,115,0.8)'
],
title: {
text: '累计收入\n555555元',
top: '50%',
left: '50%',
textAlign: 'center',
textStyle: {
color: '#485465',
width: '160px',
lineHeight: 20,
fontSize: 14
}
},
tooltip: {
trigger: 'item',
formatter: params => {
return `${insertTooltipBr(params.name)} : ${params.value}(${
params.percent
}%)`
},
position: [10, 10]
},
series: [
{
name: '毛利',
type: 'pie',
minAngle: 5,
avoidLabelOverlap: true,
radius: ['40%', '60%'],
center: ['50%', '60%'],
label: {
show: false
/* align: 'left',
normal:{
formatter(v) {
let text = v.name
return insertBr(text)
},
textStyle : {
fontSize : 10
}
} */
},
data: [
{ value: 335, name: '直接访问' },
{ value: 310, name: '邮件营销' },
{ value: 234, name: '联盟广告' },
{ value: 135, name: '视频广告' },
{ value: 1548, name: '搜索引擎' }
],
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
}
// function insertBr(text) {
// if (text.length <= 8) {
// return text
// } else if (text.length > 8 && text.length <= 16) {
// return (text = `${text.slice(0, 8)}\n${text.slice(8)}\n`)
// } else if (text.length > 16 && text.length <= 24) {
// return (text = `${text.slice(0, 8)}\n${text.slice(8, 16)}\n${text.slice(
// 16
// )}\n`)
// } else if (text.length > 24 && text.length <= 30) {
// return (text = `${text.slice(0, 8)}\n${text.slice(8, 16)}\n${text.slice(
// 16,
// 24
// )}\n${text.slice(24)}\n`)
// } else if (text.length > 30) {
// return (text = `${text.slice(0, 8)}\n${text.slice(8, 16)}\n${text.slice(
// 16,
// 24
// )}\n${text.slice(24, 30)}\n${text.slice(30)}\n`)
// }
// }
function insertTooltipBr(text) {
if (text.length <= 30) {
return text
} else if (text.length > 30) {
text = `${text.slice(0, 30)}</br>${text.slice(30)}`
return text
}
}
export default incomeProductOption