Closed JamieZhang2016 closed 8 years ago
The group "Unknown Role" is the open cluster example in my question. Picture 2 shows all nodes are Crowded together when I call openCluster().
Below is my codes:
network.on('doubleClick', function (properties) {
var clickedNodeId = properties.nodes;
if (clickedNodeId.toString().indexOf('cluster') != -1) {
if (properties.nodes.length == 1) {
if (network.isCluster(properties.nodes[0]) == true) {
network.openCluster(properties.nodes[0]);
}
}
}
});
Make sure the network's physics are enabled. Seems to work fine. Here is example of clustering you can view: https://jsfiddle.net/jfycv5ar/
Thanks dragonzone, I know why they crowded together after un-cluster, because I set the physics as false, because I don't want the nodes are jumping when drag them or open cluster.
So if I need to set physics as true, do you know how to avoid the "jumping" on the nodes? I've read the document for a while but didn't find the solution. Thanks a lot!
Basically what I want is to keep the chart the same as before when I set physics as false. But since I met the problem in the screen shots, I need to set physics to true, I think perhaps there are some setting in physics options can achieve my goal.
If you are turning the physics off & want to preserve all the nodes in the same position after they are un-clustered, then the only way I can come up with is the following:
1) Before clustering all the nodes into parent node, you will need to get & set the current X & Y coordinates of all those nodes (as in one of your old post: https://github.com/almende/vis/issues/2017) 2) Do you clustering to create the parent node 3) When user un-cluster the parent node, you will need to redraw the network. Note: since the network has the exact X & Y coord of all the nodes, it will place them exactly are they were before clustering.
Hope this helps!
After doing some more research, you can do the following, which was in the vis network doc. Here is the code:
https://jsfiddle.net/r4ks0hk7/
Basically, vis network has a method called openCluster() (http://visjs.org/docs/network/#methods), which allows you to pass the options, where the options will be the original x & y coord of the nodes before they were clustered. This works even when the physics are disabled.
dragonzone, really appreciate your detailed information! I will try your solution.
I was facing same issue. Thanks dragonzone. I think when physics is disabled, using containedNodePositions should be done by default in openCluster in library.
I think when physics is disabled, using containedNodePositions should be done by default in openCluster in library.
Doable. I'd like a consensus on this. Anybody else have an opinion? 👍 or 👎 will do (agree/disagree).
Please see my screen shots:
After I open cluster on a specific group in my Network chart, the nodes are Crowded together, I couldn't see how many nodes there and need to drag them one by one. Is there a way to automatically organize them after open cluster one of the groups? (not for all groups, I know I can call declusterAll() if I want to open all groups.)