ECharts 饼图 Legend 字设置不同颜色示例
以下是一个 ECharts 饼图 legend 字设置不同颜色的示例代码:
option = {
legend: {
textStyle: {
color: ['#FF0000', '#00FF00', '#0000FF']
},
data:['A','B','C']
},
series : [
{
name: '访问来源',
type: 'pie',
radius : '55%',
center: ['50%', '60%'],
data:[
{value:335, name:'A'},
{value:310, name:'B'},
{value:234, name:'C'}
],
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
};
在 legend 的 textStyle 属性中,可以使用一个数组来设置每个 legend 字的颜色。在本示例中,legend 有三个数据项,分别为'A'、'B'、'C',所以在 textStyle 的 color 属性中设置了一个长度为 3 的数组,每个元素分别代表一个数据项的颜色。
原文地址: https://www.cveoy.top/t/topic/lxVF 著作权归作者所有。请勿转载和采集!