Echarts y轴数据重复导致tooltip显示文字重复

原因是在同一时间有两条数据,处理方式在tooltip的formatter把数据放到set数组进行去重。

    tooltip: {
      trigger: 'axis',
      formatter: function (params) {
        const a = [];
        const b =[];
        const c =[];
        var res = "

" + params[0].value[0] +"

"
; for (var i = 0; i < params.length; i++) { if (params[i].data != undefined) { a.push(params[i].marker); b.push(params[i].seriesName); c.push(params[i].value[1]); } } const seriesMakerList = [...new Set(a)]; const seriesNameList = [...new Set(b)]; const seriesValueList = [...new Set(c)]; for (let i = 0; i <3 ; i++) { res += "

" +seriesMakerList[i]+ seriesNameList[i] + ":" + seriesValueList[i] + "

"
; } return res; } },

你可能感兴趣的:(echarts,javascript,前端)