G2
G2 copied to clipboard
Brush: 如何在框选之后获得框选的数据?
- G2 Version:
- Platform:
- Mini Showcase(like screenshots):
- CodePen Link:
您好 请教个问题: 想做一个框选的效果, 但是不是用g2自带的filter 而是想要拿到框选后的数据(准确说是x轴的时间),然后重新取发请求。目前通过回调函数能拿到context,以及通过context获得x,y坐标。请问我可以直接拿到框选后的数据吗?如果是要通过坐标自己计算的话,要如何计算呢? 谢谢
duplicate with: #3755
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);
});