Is it possible to get bottom (last) generation in genogram?
I need to display one node that should not have any links connected nothing but unlinked nodes. Those links are displayed at the below of last generation of genogram.
Yes. Here’s a stand-alone example of a LayeredDigraphLayout that puts all of the singleton nodes in a column to the right or a row underneath the main layout.
function ArrangedLayeredDigraphLayout() {
go.LayeredDigraphLayout.call(this);
this.arrangementSpacing = 50; // some space between the sub graphs
}
go.Diagram.inherit(ArrangedLayeredDigraphLayout, go.LayeredDigraphLayout);
ArrangedLayeredDigraphLayout.prototype.doLayout = function(coll) {
var net = this.makeNetwork(coll);
var subnets = net.splitIntoSubNetworks();
var initorig = this.arrangementOrigin.copy();
var orig = this.initialOrigin(initorig).copy();
var diagram = this.diagram;
diagram.startTransaction();
// layout each subnetwork
// you could sort these in a different order, if you like
var lay = this;
subnets.each(function(n) {
lay.network = n;
lay.arrangementOrigin = orig;
go.LayeredDigraphLayout.prototype.doLayout.call(lay, coll);
var bnds = diagram.computePartsBounds(n.findAllParts());
if (lay.direction === 0 || lay.direction === 180) {
orig.x += bnds.width + lay.arrangementSpacing;
} else {
orig.y += bnds.height + lay.arrangementSpacing;
}
})
// now layout any singleton nodes left over from splitIntoSubNetworks()
// you could also sort these in a different order
net.vertexes.each(function(v) {
var node = v.node;
if (node !== null) {
node.move(orig);
var bnds = node.actualBounds;
if (lay.direction === 0 || lay.direction === 180) {
orig.y += bnds.height + lay.arrangementSpacing;
} else {
orig.x += bnds.width + lay.arrangementSpacing;
}
}
});
this.arrangementOrigin = initorig;
diagram.commitTransaction("ArrangedLayeredDigraphLayout");
};
You just need to adapt this code by putting its doLayout into your custom GenogramLayout.
I thought your initial post in this topic was asking about how to position an unlinked node in a row below all of the other nodes and links. Is that not the case? What I gave you was a custom LayeredDigraphLayout that does that for any number of nodes that have no connected links. But you already have a custom LayeredDigraphLayout, so you need to merge the doLayout method into your code.