Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not possible to update a @vx/grid scale in a performant way? #617

Closed
cilphex opened this issue Jan 31, 2020 · 2 comments
Closed

Not possible to update a @vx/grid scale in a performant way? #617

cilphex opened this issue Jan 31, 2020 · 2 comments

Comments

@cilphex
Copy link

cilphex commented Jan 31, 2020

I would like to update the scale on a Grid component every few milliseconds, in accordance with a mouse drag. I have this working already with plain d3, but I am attempting to rewrite it using react & vx.

You can manipulate a LinePath this way easily by using its innerRef instead of using setState.

But Grid has no innerRef. It looks like Grid just builds an SVG group that wraps a bunch of lines, which makes sense. But without a way to reference the inner refs, it seems that you must rely on setState to update the Grid scales, and this is really non-performant. It is laggy and for anything beyond about 2 updates per second.

Is there a way to update the xScale and yScale on a Grid in a performant way, so that it can be done without lag every few milliseconds?

@cilphex
Copy link
Author

cilphex commented Mar 11, 2020

@williaster Wondering if you might have any ideas?

@williaster
Copy link
Collaborator

Sorry for the delay, closing this as it should now be possible with AnimatedGrid from @vx/react-spring (added in 0.0.199), or using a similar approach if you don't want to use react-spring.

https://vx-demo.now.sh/axis includes a demo of AnimatedAxis + AnimatedGrid, and you can check out #787 where it was added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants