Dim background onclick
Is there a way to dim the background when i zoom onto a node. For example : https://graphics.straitstimes.com/STI/STIMEDIA/Interactives/2018/04/marvel-cinematic-universe-whos-who-interactive/index.html
if you see this when you click a node it zooms onto that node and sort of dims the other nodes out
@rohankk2 that should be doable. On click event just call .nodeColor(node => ...)and set a lower alpha channel of the rgba for the nodes that you wish to dim.
Similar pattern to the highlight example: https://vasturiano.github.io/react-force-graph/example/highlight/
As for click to focus, there's another example for that: https://vasturiano.github.io/react-force-graph/example/click-to-focus/
But the onclick event only gives me access to the current node right ? how do i dim out the others ?
@rohankk2 you can set a "selectedNode" state, like so:
onNodeClick = { node => this.setState({ selectedNode: node }) }
and then set your nodeColor function to depend on that state, for example:
nodeColor={ node => node === this.state.selectedNode ? 'rgba(255,0,0,1)' : 'rgba(255,0,0,0.5)' }
But it considers only selected node at a time, how to dim neighbours and links @rohankk2
nodeColor function will get called for all the nodes in the graph