echarts tooltip trigger: 'axis'
没有作用?
鼠标移上图的时候根本没有显示提示语,也没有触发formatter.
如图:
代码如下:
export let netOption = {
tooltip: {
trigger: 'axis',
formatter: function (params) {
let time = params[0].axisValue
let res = '' + time + '<br>'
let solidMaker = '<span style="display:inline-block;margin-right:5px;width:13px;height:1px;border-top:1px solid #b96422;vertical-align: middle"></span>'
let dashMaker = '<span style="display:inline-block;margin-right:5px;width:13px;height:1px;border-top:1px dashed #b96422;vertical-align: middle"></span>'
params.forEach((o, i) => {
console.log("12312321"+i)
let maker = i === 0 ? dashMaker : solidMaker
res += `${maker} ${o.seriesName} : ${getValue(o.value)} <br> `
})
return res
}
},
legend: {
data: ['发送数据', '接收数据'],
textStyle: {
color: '#fff',
fontSize: 12
},
show: false
},
// animation: false,
grid: {
left: '0%',
right: '0%',
bottom: '0%',
top: '6%',
containLabel: true
},
xAxis: {
//show: true,
// show: false,
splitLine: {show: true, lineStyle: {color: '#eedecf', width: 1, type: 'solid'}},
splitArea: {show: false},
type: 'category',
boundaryGap: false,
axisLine: {
lineStyle: {
color: '#b96422',
width: 1
}
},
data: [],
axisLabel: {
show: true,
textStyle: {
color: '#fff'
}
}
},
yAxis: {
type: 'value',
splitLine: {show: true, lineStyle: {color: '#eedecf', width: 1}},
splitArea: {show: false},
axisLine: {
lineStyle: {
color: '#b96422',
width: 1
}
},
axisLabel: {
formatter: function (value) {
return getValue(value)
},
// show: false,
// textStyle: {
// color: '#fff'
// }
}
},
series: [
{
name: '发送数据',
type: 'line',
data: [],
symbol: 'none',
// smooth: true,
itemStyle: {
normal: {
color: '#b96422',
lineStyle: {type: 'dotted'}
}
},
areaStyle: {
normal: {
color: '#b96422',
opacity: '0.2'
}
}
// smooth:false
},
{
name: '接收数据',
type: 'line',
itemStyle: {
normal: {color: '#b96422'}
},
symbol: 'none',
data: [],
areaStyle: {
normal: {
color: '#b96422',
opacity: '0.2'
}
}
}
],
backgroundColor: 'transparent',
textStyle: {
color: '#fff',
fontSize: 14
},
}
我也遇到了一样的问题,找不到解决办法