echarts中legend的样式
时间: 2023-11-17 14:55:35 浏览: 93
在 Echarts 中,可以通过设置 legend 的属性来修改其样式。以下是一些常用的属性:
1. textStyle: 设置 legend 文本的样式,可以包括颜色、字体大小等。
示例:`textStyle: { color: '#333', fontSize: 12 }`
2. backgroundColor: 设置 legend 的背景颜色。
示例:`backgroundColor: 'rgba(0, 0, 0, 0.8)'`
3. borderColor: 设置 legend 的边框颜色。
示例:`borderColor: '#666'`
4. borderWidth: 设置 legend 的边框宽度。
示例:`borderWidth: 1`
5. borderRadius: 设置 legend 的边框圆角半径。
示例:`borderRadius: 5`
6. padding: 设置 legend 内容的内边距。
示例:`padding: [5, 10]`
7. itemWidth: 设置 legend 图例项的宽度。
示例:`itemWidth: 20`
8. itemHeight: 设置 legend 图例项的高度。
示例:`itemHeight: 10`
这些属性可以通过在 Echarts 的 option 中对 legend 进行配置来使用。例如:
```javascript
option = {
legend: {
textStyle: {
color: '#333',
fontSize: 12
},
backgroundColor: 'rgba(0, 0, 0, 0.8)',
borderColor: '#666',
borderWidth: 1,
borderRadius: 5,
padding: [5, 10],
itemWidth: 20,
itemHeight: 10
},
// 其他配置项...
};
```
阅读全文
相关推荐


















