图片链接地址:Examples - Apache ECharts
官方文字颜色默认为黑色,只需在label标签内设置color值为auto即可。
实例代码:
var option = {
tooltip: {
trigger: 'item',
formatter: '{a} <br/>{b} : {c} ({d}%)'
},
color:[
'#006cff',
'#60cda0',
'#ed8884',
'#ff9f7f',
'#ff9f7f',
'#009f7f',
'#9fe6b8',
'#32c5e9',
'#1d9dff'],
textStyle:{
color:'auto'
},
series: [
{
name: '点位统计',
type: 'pie',
// 百分比需加引号
radius: ['10%', '70%'],
center: ['50%', '50%'],
roseType: 'radius',
itemStyle: {
borderRadius: 5,
},
data: [
{ value: 30, name: '云南' },
{ value: 28, name: '北京' },
{ value: 26, name: '山东' },
{ value: 24, name: '河北' },
{ value: 22, name: '江苏' },
{ value: 20, name: '浙江' },
{ value: 18, name: '四川' },
{ value: 16, name: '湖北' }
],
// 修饰文字大小的样式label对象
label:{
fontSize:10,
//增加区域
color:'auto'
},
labelLine:{
length:6,
length2:8
}
}
]
};
//3.配置项和数据给我们的实例化对象
myChart.setOption(option);
效果: