// echrts option.tooltip 配置
tooltip: {
confine: true,
show: true,
trigger: 'axis',
triggerOn: "click",
alwaysShowContent: true,
padding: 5,
backgroundColor: "#EBEBEB",
borderColor: "#E0E0E0",
axisPointer: {
type: "line",
z: -1,
lineStyle: {
color: "#f00",
width: 1,
type: "solid",
},
},
初始化图表后通过 dispatchAction
(type=showTip)可以将 tooltip 及连线(axisPointer) 展示出来:
之后通过绑定点击图表事件触发 dispatchAction(type=select)与 dispatchAction(type=showTip)
柱子可以被正常 select,tootip 也可以正常显示,但没有连线。但是,如果点击的是表中的柱子,连线也可以正常显示。
接下来,判断点击位置是否在系列柱状图上,如果点击位置不在柱子上就不 dispatchAction:
const pointInPixel = [params.offsetX, params.offsetY];
if (!MyChart.containPixel({seriesIndex: [0]}, pointInPixel)) {
return
}
但是,当我点击柱子上方空白位置或者横坐标下的空白位置,虽然没有触发 dispatchAction,但已经选中的 tooltip 的连线会消失。
请问:
- 如何在 dispatchAction(type=showTip) 出现连线呢?
- 或者如何在后一种情况下控制 tooltip 连线不消失呢?