sim51 / react-sigma

Sigma React component
https://sim51.github.io/react-sigma/
MIT License
172 stars 27 forks source link

[website] example on forward sigma ref #36

Closed sim51 closed 1 year ago

sim51 commented 1 year ago

ie. external state

BaherZ commented 1 year ago

Looking forward to this

sim51 commented 1 year ago

Take a look here : https://github.com/sim51/react-sigma/blob/main/project/packages/examples/src/views/external.tsx

The example project is what I use to test the dev. But for now there is no documentation about it. Moreover, this feature is not yet published in a release.

ian-j-stewart commented 1 year ago

Can this approach be used to access node events like onClickNode? The old version of the react sigma module allowed this as shown in the code below which called a function. But I have not seen documentation for this version of the module to get node events like this.

                <Sigma  graph={data}  onClickNode={onClickNode} 

                }}

cheers

sim51 commented 1 year ago

The best way (and for now the only way) to do that is to use the hook useRegisterEvents in a component that is child of SigmaContainer. Take a look at the documentation here : https://sim51.github.io/react-sigma/docs/example/events

The next release of react-sigma will ship the forward ref feature for the sigma instance. So you will have a direct access to the sigma instance, and then you will be able to do what ever you want with it. With this method, you have to know the sigma api, there no react sugar / helper, you have to do everything by yourself. But it allows you to control sigma outside the SigmaContainer

sim51 commented 1 year ago

This feature has been released in the v3.1.0

sim51 commented 1 year ago

https://sim51.github.io/react-sigma/docs/example/external_state/