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

Provide an onChange api when some properties from inputed data changes #404

Open
antoninklopp opened this issue Nov 29, 2020 · 3 comments
Open
Labels
documentation add documentation to the repository or the the code base feature request

Comments

@antoninklopp
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
This feature request will allow better connections between the graph and the user interactions.

Describe the solution you'd like
Provide an onChange method when a property involving data is changed, like changing an x or y coordinate by dragging a node. This is the only case that I can think of now but there could be more in the future.

An example could be the following

function App(){

  const [data, setData] = useState(myInitialData); 

  return (
    <Graph 
       id="my-graph"
       data={data}
       onChange={(data) => setData(data)}
  )
}

Describe your use case
If I want to save the state of my graph with the layout changed by a user.

Describe alternatives you've considered
I currently need to keep a reference over the graph and access it by ref.current.state.nodes which is not really the "react way" of doing things.

@danielcaldas danielcaldas added documentation add documentation to the repository or the the code base feature request labels Nov 30, 2020
@danielcaldas
Copy link
Owner

Perhaps you found a gap in the documentation. We already have onNodePositionChange. I understand this would be useful for some. Still, I would highly recommend us to keep our API with granular callback/hook functions such as onMouseOverNode, onMouseOverLink, onZoomChange, onNodePositionChange and so forth.

Nevertheless, let's keep this open to understanding if there are others interested in it.

@antoninklopp
Copy link
Collaborator Author

Thanks for pointing this method @danielcaldas , I did not see that it was accessible. I think I missed it because it is not used in the <Graph /> component in the documentation when every other available method is used.

@danielcaldas
Copy link
Owner

#405 was merged. But let's keep this open to see if anyone else stumbles upon this use case you've raised.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation add documentation to the repository or the the code base feature request
Projects
None yet
Development

No branches or pull requests

2 participants