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

Graph Rerendering #51

Closed
ravisraval opened this issue Feb 15, 2018 · 3 comments
Closed

Graph Rerendering #51

ravisraval opened this issue Feb 15, 2018 · 3 comments
Labels
bug enhancement improving existent functionality or performance related

Comments

@ravisraval
Copy link

I'm a big fan of your work on the react-d3-graph, and I'd love a little help! I'm pretty new to programming in general, so apologies for any dumb questions. I'm trying to make a graph that displays & animates several tree traversals (bfs, etc.).

The graph doesn't rerender when I expect it to do so.
For instance, when I change the react component's state to designate the next node (during traversal) to highlight, the state properly updates, but the d3 graph doesn't change. I can see that it's getting the correct data / config, but what's rendered is still the old info. Here's a quick gif of this also happening when I try to change the input that builds the nodes: https://gyazo.com/2a677fc3983ce2acfe59bf7816527cd2

Another example: When I click the Level Order button, it runs the levelOrder function, which does update state.highlightedNode. Even though the state is changed, the node 5 is still green. So I suppose my question is - what exactly makes the graph refresh? Is there a way I can trigger this manually? https://gyazo.com/d71e37e860da27934ca7fa162df8ccd7

Also, I'm trying to get the nodes to render in specific positions, but I keep getting an error thrown when I set staticGraph: true. Does that mean that the only way to hardcode node positions is by removing the ability to add/remove nodes?

Here's the repo: https://github.com/ravisraval/teaching/tree/master
And the file in question: https://github.com/ravisraval/teaching/blob/master/src/components/algorithms/TreeTraversals.jsx

@danielcaldas
Copy link
Owner

danielcaldas commented Feb 15, 2018

Hello @ravisraval!

Somewhere along the road, I implemented a componenWillReceiveProps react hook in order to prepare data for updates and avoid updates when unchanged data is passed down. I decided to properly handle this by making a few changes
and release this asap as a bug fix.

So.. new expected behaviours should be

  • Clients are able to pass down graph (node, links) data and see the changes reflected in the graph
  • Clients are able to add/remove nodes and links to a static graph (happens when staticGraph is set to true)

@danielcaldas danielcaldas added bug enhancement improving existent functionality or performance related labels Feb 15, 2018
@ravisraval
Copy link
Author

Sweet! Looking forward to it.

@danielcaldas
Copy link
Owner

Fixed with release react-d3-graph@1.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug enhancement improving existent functionality or performance related
Projects
None yet
Development

No branches or pull requests

2 participants