react-d3-graph icon indicating copy to clipboard operation
react-d3-graph copied to clipboard

Question: Manually collapsing a particular node

Open onlyreddy opened this issue 4 years ago • 3 comments
trafficstars

Hi,

In my requirement, I need manually to collapse a node. I tried with collapsible property and with the mouse click on the node it's working.

But I need to do it manually so I tried to call onClickNode() by using the ref provided by the Graph component unfortunately it's not working. Then I checked in your project source code and there also's handled in onClickNode.

Can you help me to achieve this?

onlyreddy avatar Feb 17 '21 08:02 onlyreddy

But I need to do it manually so I tried to call onClickNode()

You mean programmatically? I'm afraid it might not be possible at the moment. I think you can try and look at the property isHidden in the codebase and try to figure a way to make it work properly. But I think it will only get you as far as hiding the connection and not the leaf node. Pull Requests are welcome.

danielcaldas avatar Mar 18 '21 11:03 danielcaldas

Today only I got the way to do with ref provided by graph. The User has to dynamically update the node click event based from graphref.

graphRef.current.onClickNode(history[currentNodeIndex]);

In my case I'm saving the history of every node then once user click on the prev and next buttons based current node index I'm updating the onClickNode.

onlyreddy avatar Mar 18 '21 11:03 onlyreddy

The above solution will not work if you have updated any state value.

onlyreddy avatar Mar 31 '21 06:03 onlyreddy