echarts legend的字体颜色怎么改变
时间: 2023-11-17 16:00:38 浏览: 32
要修改Echarts图表中legend的字体颜色,可以按照以下步骤进行操作:
1. 找到legend的配置项,一般在option对象的legend属性中。
2. 在textStyle属性中设置字体大小和颜色,例如:textStyle: {fontSize: 18, color: '#ffffff'}。
3. 保存修改后的配置项,重新渲染图表即可。
示例代码如下:
```javascript
option = {
legend: {
textStyle: {
fontSize: 18,
color: '#ffffff'
},
data: []
},
xAxis: [{
type: 'category',
data: [],
axisLabel: {
show: true,
textStyle: {
color: '#ffffff'
}
}
}],
yAxis: [{
type: 'value',
name: '',
axisLabel: {
textStyle: {
color: '#ffffff'
}
}
}]
};
// 重新渲染图表
myChart.setOption(option);
```