echarts自定义tooltip
tooltip配置
tooltip: {
show: true,
trigger: 'axis',
formatter: params => {
let result = `<div>${params[0].axisValue}</div>`
params.forEach(item => {
if (item.seriesType === 'line') {
result += `<div style="display: flex; width: 100%; margin-top: 4px; justify-content: space-between; align-items: center;">
<div>${item.marker}${item.seriesName}</div>
<div style="margin-left: 12px; color: #666; font-weight: 900;">${(item.value * 100).toFixed(2) + '%'}</div>
</div>`
} else {
result += `<div style="display: flex; width: 100%; margin-top: 4px; justify-content: space-between; align-items: center;">
<div>${item.marker}${item.seriesName}</div>
<div style="margin-left: 12px; color: #666; font-weight: 900;">${item.value}</div>
</div>`
}
})
return result
}
},
本文来自博客园,作者:hong_li,转载请注明原文链接:https://www.cnblogs.com/hong1/p/18546490