Hi there, I’m using genogram code from the example here: Genogram
I want parents connected to their children in such a way that links form an intersection (see images below).
It behaves as expected when I move the parent nodes - all the parent-child links get recalculated. When I move any of the children, all the parent-child links should get recalculated too, but it doesn’t work as expected. How can I achieve this? Is it possible to do this just by using links or do I need to use a separate node for the intersection? Thanks for help.
Here is the code I’m using:
myDiagram.linkTemplate = // for parent-child relationships
$(
TwinLink(),
{
routing: go.Link.Orthogonal,
corner: 5,
layerName: "Background",
selectable: false,
},
$(go.Shape, { stroke: "#424242", strokeWidth: 2 })
);
function TwinLink() {
class TwinLink extends go.Link {
public computePoints(): boolean {
const result = go.Link.prototype.computePoints.call(this);
const pts = this.points;
const parents = this.fromNode;
let children = 0;
let sumX = 0;
const it = parents?.findNodesOutOf();
while (it?.next()) {
const child = it.value;
children++;
sumX += child.location.x;
if (children > 1) {
const midX = sumX / children;
const oldp = pts.elt(pts.length - 3);
pts.setElt(pts.length - 3, new go.Point(midX, oldp.y));
pts.setElt(pts.length - 2, pts.elt(pts.length - 1));
}
}
return result;
}
}
return TwinLink;
}
First render:
When I move a child, the links get disconnected:
Expected: