var data = [
{value:40, name:'货币'},
{value:20, name:'股票'},
{value:40, name:'债券'}
]
option = {
title: [
{
text: '交易总数',
x: "center",
top: "52%",
textStyle: {
color: "rgba(203, 221, 255, 1)",
fontSize: 20,
fontWeight: "bold",
},
},
{
text:'1223',
x: "center",
top: "44%",
textStyle: {
fontSize: "36",
color: "rgba(255, 255, 255, 1)",
//fontFamily: "siyuanyahei_yingwen_shuzi",
},
}
],
legend: {
orient: 'vertical',
right:0,
y: 'center',
itemGap:30,
itemWidth:8,
padding:10,
textStyle:{
fontSize: 12
},
align:'left',
data: [
{
name:'货币',
icon:'circle',
textStyle: {
color:'pink'
}
},
{
name:'股票',
icon:'circle',
textStyle: {
color:'yellow'
}
},{
name:'债券',
icon:'circle',
textStyle: {
color:'red'
}
}
],
formatter: function(name){
var total = 0;
var target;
for (var i = 0, l = data.length; i < l; i++) {
total += data[i].value;
if (data[i].name == name) {
target = data[i].value;
}
}
var arr = [
'{a|'+name+' :}{b|'+((target/total)*100).toFixed(2)+'个}'
]
return arr.join('\n')
},
textStyle:{
rich:{
a:{
fontSize:20,
align:'left',
padding:[0,0,0,10]
},
b:{
fontSize:20,
align:'right',
padding:[0,0,0,30],
lineHeight:25,
}
}
},
// backgroundColor: "red"
},
series: [{
type: 'pie',
center: ['50%', '50%'],
radius: ['24%', '45%'],
clockwise: true,
avoidLabelOverlap: true,
hoverOffset: 15,
hoverAnimation:false,
label: {
show: true,
position: 'outside',
formatter: '{a|{b}\n }{b|{d}%}',
rich: {
a: {
padding: [-5, 0, 0, 0]
},
b: {
padding: [-10, -10, 10, -10]
}
}
},
labelLine: {
normal: {
length: 20,
length2: 30,
lineStyle: {
width: 1
}
}
},
data: data
}]
};