antvis/G2

支持主动触发事件吗? #4458

Valar103769 posted onGitHub

场景: 多折线图,x是时间,tooltip:change 时, 右侧饼图显示当前日期的数据 <img width="1160" alt="image" src="https://user-images.githubusercontent.com/36926073/207256875-93c31058-c378-4870-b2d6-05c91e094d56.png">

 chart.on('tooltip:change', (ev) => {
    emit('tooltip:change', ev.data)
  })

饼图直接使用的ev.data中的数据结构 如何主动触发 tooltip:change 时间? 以让饼图有一个初始值


试试这个,不确定行。

chart.emit("tooltip:change", {})
posted by hustcc over 2 years ago

试试这个,不确定行。

chart.emit("tooltip:change", {})

感觉不太行的样子 至少得传个参数告诉下index吧

posted by Valar103769 over 2 years ago
// 拿到要触发展示的元素的坐标点
const box = plot.chart.geometries[0].elements[0].getBBox();
const point = { x: box.x + box.width / 2, y: box.y + box.height / 2 };
// 触发展示
chart.showTooltip(point);
posted by visiky over 2 years ago

Fund this Issue

$0.00
Funded

Pull requests