项目场景:
使用 legend显示不同类型(bar和line)的item样式
需实现的效果图:
解决方案:
-
legend
以数组的方式分区域显示item
-
设置方法如下:
legend: [
{
// right: 80,
x: 'right', // 可设定图例在左、右、居中
y: 'top', // 可设定图例在上、下、居中
padding: [0, 100, 0, 0], // 可设定图例[距上方距离,距右方距离,距下方距离,距左方距离]
data: ['投入数', '产出数'],
textStyle: {
color: '#B6CDE9',
fontSize: '14px',
fontFamily: 'Source Han Sans CN',
fontWeight: 400
},
itemWidth: 12,
itemHeight: 12
},
{
x: 'right', // 可设定图例在左、右、居中
y: 'top', // 可设定图例在上、下、居中
padding: [0, 30, 0, 0], // 可设定图例[距上方距离,距右方距离,距下方距离,距左方距离]
data: ['在制数'],
textStyle: {
color: '#B6CDE9',
fontSize: '14px',
fontFamily: 'Source Han Sans CN',
fontWeight: 400
},
itemWidth: 20,
itemHeight: 6
}
],