G2 icon indicating copy to clipboard operation
G2 copied to clipboard

Brush: 如何在框选之后获得框选的数据?

Open imyuxh opened this issue 3 years ago • 1 comments

  • G2 Version:
  • Platform:
  • Mini Showcase(like screenshots):
  • CodePen Link:

您好 请教个问题: 想做一个框选的效果, 但是不是用g2自带的filter 而是想要拿到框选后的数据(准确说是x轴的时间),然后重新取发请求。目前通过回调函数能拿到context,以及通过context获得x,y坐标。请问我可以直接拿到框选后的数据吗?如果是要通过坐标自己计算的话,要如何计算呢? 谢谢

imyuxh avatar Mar 14 '22 06:03 imyuxh

duplicate with: #3755

visiky avatar Jun 14 '22 04:06 visiky

Sorry, due to problems in the program's architecture design, we are unable to effectively fix the issues. But it fixed in G2 5.0, you can have a try.

chart.on('brush:filter', (event) => {
  const { selection } = event.data;
  const [domainX, domainY] = selection;
  const [minX, maxX] = domainX;
  const [minY, maxY] = domainY;
  console.log(minX, maxX, minY, maxY);
});

hustcc avatar Aug 22 '23 13:08 hustcc