antvis / G2Plot

:dango: An interactive and responsive charting library based on G2.
https://g2plot.antv.antgroup.com
MIT License
2.56k stars 605 forks source link

【求助】交互响应事件或图表更新事件 #1114

Closed whatthehan closed 4 years ago

whatthehan commented 4 years ago

在使用一些交互时,如何能获取到响应事件获取图表更新时间呢? 比如 我用了面积图,同时配置brush框选,我想要拿到框选之后的 坐标轴两端的数据 该如何做呢 翻了一下午文档都没找到有相关的说明😭😭😭😭

paleface001 commented 4 years ago

框选行为触发数据的更新,可以在框选结束之后拿到对应scale的values。不过G2Plot应该是没有开brush才对.... 你是怎么用的?

whatthehan commented 4 years ago

框选行为触发数据的更新,可以在框选结束之后拿到对应scale的values。不过G2Plot应该是没有开brush才对.... 你是怎么用的?

@paleface001 试了一下可以啦

events: {
    onPlotMouseup: () => {
        console.log(areaPlot.getXScale());
    },
},

bursh是我记着G2有这个配置就试了一下,原因就不知道了🤔 我是这样写的

interactions: [
    {
        type: 'brush-x',
    },
],

https://codesandbox.io/s/laughing-engelbart-ngyqz?file=/index.html 感谢大佬啦

paleface001 commented 4 years ago

看来前段时间支持上去的图表方法还是有用的~

timadevelop commented 4 years ago

@paleface001 do you have any plans to preserve interaction types like brush, brush-x, etc, or they're going to be deleted?

I'm choosing between g2 and g2plot, but I need these interactions.

timadevelop commented 4 years ago

@paleface001 g2plot is based on g2. Does it mean that I could use G2 API directly anytime I need to make something special? For example if I need to introduce (register) a new interaction using g2?