Hi,
I’m trying to implement the DoubleTree layout example in my project. It works great for nodes but I am trying to get it working for groups also. I have updated the separatePartsByLayout method below to find all the groups for each side of the tree and adding these to the correct collection, however, the diagram is still rendering the tree ignoring the groups.
separatePartsByLayout(diagram, leftParts, rightParts): void {
var root = diagram.findNodesByExample({ isRoot: true }).first();
if (root === null) return;
var leftGroups = diagram.findNodesByExample({isGroup: true, dir: 'left'});
var rightGroups = diagram.findNodesByExample({isGroup: true, dir: 'right'});
// the ROOT node is shared by both subtrees!
leftParts.add(root);
rightParts.add(root);
// add the groups to the correct collection
leftParts.addAll(leftGroups);
rightParts.addAll(rightGroups);
// look at all of the immediate children of the ROOT node
root.findTreeChildrenNodes().each(function (child) {
// in what direction is this child growing?
var dir = child.data.dir;
var coll = (dir === "left") ? leftParts : rightParts;
// add the whole subtree starting with this child node
coll.addAll(child.findTreeParts());
// and also add the link from the ROOT node to this child node
coll.add(child.findTreeParentLink());
});
}
I don’t suppose you know what I might be doing wrong?
If I apply the same data to a normal tree (without running the DoubleTree code) it shows the nodes and groups correctly. I’ve added some screenshots below. They both have the same nodespacing and leyerspacing (50)
Rendered with single TreeLayout
Rendered with DoubleTree (left nodes only)
Thanks,
Gary