storeFlowOption.js
2.39 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
const storeFlowOption = {
color: ['rgba(9,71,198,1)', 'rgba(9,71,198,0.8)', 'rgba(9,71,198,0.6)','rgba(9,71,198,0.4)','rgba(9,71,198,0.3)'],
tooltip: {
trigger: 'item',
//formatter: '{a} <br/>{b} : {c} ({d}%)',
formatter: (params) => {
return `${insertTooltipBr(params.name)} : ${params.value}(${params.percent}%)`
},
position: [10, 10]
},
legend: {
orient: 'vertical',
right: 0,
data: [],
formatter: function (name) {
if(name.length>8) {
return name.substr(0,8)+'...'
}
return name
},
tooltip: {
show: true
},
textStyle: {
fontSize: '11'
}
},
series: [
{
name: '4s门店客流量',
type: 'pie',
minAngle: 5,
avoidLabelOverlap: true,
radius: '50%',
center: ['40%', '65%'],
label:{
show:false,
/* align: 'left',
normal:{
formatter(v) {
let text = v.name
return insertBr(text)
},
textStyle : {
fontSize : 10
}
} */
},
data: [
{
value: 335,
name: '直接访问',
},
{
value: 335,
name: '直接访问',
},
{
value: 335,
name: '直接访问',
itemStyle: {
color: 'rgba(9,71,198,0.6)'
},
},
],
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){
return text = `${text.slice(0,30)}</br>${text.slice(30)}`
}
}
export default storeFlowOption