比如示例图里的开车是91,那么图表展示就是91%,不让饼图自动计算百分比了。
配置项如下
option = {
tooltip : {
trigger: 'item',
formatter: "{a} <br/>"+
" <span style='display:inline-block;margin-right:5px;border-radius:10px;width:9px;height:9px;background-color:#ffe325'></span>"
+" {b}: {c}%"
},
legend: {
orient: 'horizontal',
left: 'center',
data: ['骑车','驾车','步行','公交']
},
series : [{
name: '通勤指数',
type: 'pie',
radius : ['25%', '70%'],//圆的内外半径
center: ['50%', '57%'],//圆的X,Y轴平移
data:[
{
value: '0',
name: '骑车',
itemStyle:{//圆形颜色
normal:{color:'#00b8ee'}
}
},
{
value: '91',
name: '驾车',
itemStyle:{
normal:{color:'#fe9e25'}
}
},
{
value: '1',
name: '步行',
itemStyle:{//圆形颜色
normal:{color:'#8fc320'}
}
},
{
value: '5',
name: '公交',
itemStyle:{
normal:{color:'#d2335b'}
}
}
],
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}]
}