echarts 中设置lengend样式不生效问题

我想通过rich设置总投入三个字为红色的样式,以下是代码

legend: [
{
data: ['投入的数据'],
top: 16,
right: 5,
itemHeight: 14,
textStyle: {
color: '#a9ddee',
fontSize: 14
},
rich: {
total: {
color: 'red'
}
},
formatter: (name) => {
return name + ' {total|总投入:}' + $drawData.MaxInLineVal
}
}
]

但是实际运行结果如下图

img


想应用名为total的样式,该如何做

将span标签拼接成字符串即可,代码如下:


rich: {
total: {
color: 'red'
}
},
formatter: (name) => {
return name + ' {'+'<span style="color:red;"> total </span>'+'|总投入:}' + $drawData.MaxInLineVal
}
}

若有帮助,谢谢采纳~