G2
G2 copied to clipboard
[Feat]: 柱状图hover到空白区域怎么不显示tooltip
Describe the feature / 功能描述
Are you willing to contribute? / 是否愿意参与贡献?
Please select / 请选择
官方图表示例地址:https://g2.antv.antgroup.com/examples/analysis/group#bar-stacked-diverging
需要新增参数来控制空白部分是否显示 tooltip
@mjhmjh666 有没有兴趣提个 PR 呀,可以加个 trigger 参数控制一下,默认是 plot,可配置为 element,在 tooltip 交互里面判断一下 event.target 。
https://github.com/antvis/g2/blob/v5/src/interaction/tooltip.ts
方案:
interaction.tooltip 新增 trigger 参数,默认是 plot,可选 element、plot
代码地址:https://github.com/antvis/G2/blob/v5/src/interaction/tooltip.ts
关键代码片段: