Hi, sorry if this question has been asked.
Here I have a network like below,
what I would like to achieve:
if not cluster, double click to cluster all the child nodes (top-down direction) to parent nodes
if cluster, double click the cluster to open the cluster
here my code
network.on("doubleClick", function (params) {
if (params.nodes.length == 1) {
if (network.isCluster(params.nodes[0]) == true) {
var openClusterObj = {};
openClusterObj.releaseFunction = function (clusterPosition, containedNodesPositions) {
return containedNodesPositions;
};
network.openCluster(params.nodes[0], openClusterObj);
} else {
var count_child = 0;
var clusterOptionsByData = {
joinCondition: function (childOptions) {
if (network.getConnectedNodes(params.nodes[0], "to").includes(childOptions.id)
|| params.nodes[0] == childOptions.id) {
count_child++;
return true;
}
return false;
},
clusterNodeProperties: {
label: (nodes_dataset.get(params.nodes[0]).label + " [" + network.getConnectedNodes(params.nodes[0], "to").length + "]"),
borderWidth: 3,
x: nodes_dataset.get(params.nodes[0]).x,
y: nodes_dataset.get(params.nodes[0]).y,
group: nodes_dataset.get(params.nodes[0]).group
}
};
network.cluster(clusterOptionsByData);
}
}
});
for the 1st layer (parent-child nodes) of cluster it works, like below:
but when I click on the 'grandpa' node, it behave like below:
I expecting like below:
How should I improve the joinCondition to crawl all the related nodes 'top-down' direction:
joinCondition: function (childOptions) {
if (network.getConnectedNodes(params.nodes[0], "to").includes(childOptions.id)
|| params.nodes[0] == childOptions.id) {
count_child++;
return true;
}
return false;
},
Hi, sorry if this question has been asked. Here I have a network like below,
what I would like to achieve:
here my code
for the 1st layer (parent-child nodes) of cluster it works, like below: but when I click on the 'grandpa' node, it behave like below: I expecting like below:
How should I improve the joinCondition to crawl all the related nodes 'top-down' direction:
Thank you