项目中对悬浮的值formatter进行了唯一给值,并没有针对每一个进行赋值
问题代码大致为:
formatter: (params) => {
return `${params[0].name} <br/>
${params[0].值1}
${params[0].值2} :
${params[0].value == 0 ? "-" : Number(params[0].value).toLocaleString()}单位`;`}
处理方式:
tooltip: {
trigger: 'axis',
formatter: function(params) {
let content = params[0].name + '<br/>';
params.forEach(function(item) {
content += item.值1+ ' ' + item.值2+ ' : ' + (item.value == 0 ? "-" : Number(item.value).toLocaleString()) + '单位';
});
return content;
}
},
标签:鼠标,悬浮,value,content,item,params,折线,formatter,echarts
From: https://www.cnblogs.com/hoper-development/p/18182675