I have a GoJS organizational chart, where nodes have the functionality of expand and collapse. For each node its child can have the following structure:
Now both A and B type nodes can be multiple but following the same design structure respectively.
I have a linkTemplate method in my diagram in which I am assigning the diagram.LinkTemplate to a custom class of GroupedLink which extends my go.Link class which has some overidden methods.
LinkTemplate() {
this.diagram.linkTemplate = new GroupedLink(go.Link.Orthogonal)
.add(
new go.Shape({ stroke: connector.lineColor, strokeWidth: 2 }),
new go.Shape({ fromArrow: ‘Circle’, scale: 0.65, fill: connector.fromCircleColor }),
new go.Shape({ toArrow: ‘Circle’, scale: 0.65, fill: connector.toCircleColor })
)
.bind(‘fromSpot’, ‘fromSpot’)
.bind(‘toSpot’, ‘toSpot’);
}
In groupedLink class, I have a computePoints() method to customize the point for routes.
computePoints() {
const result = super.computePoints();
if (result && this.toNode && this.toNode.containingGroup !== null) {
const loc = this.toNode.containingGroup.position;
const pt2 = this.getPoint(2);
const pt4 = this.getPoint(4);
this.setPoint(2, new go.Point(pt2.x, loc.y - 10));
this.setPoint(3, new go.Point(loc.x - 5, loc.y - 10));
this.setPoint(4, new go.Point(loc.x - 5, pt4.y));
}
return result;
}
Now the if condition will be executed if my current node type is of A and loc will be the position of that node type A.
According to my analysis, these points are working fine when whole diagram is completely expanded but as soon as nodes are getting collapsed, the position is getting changed and thus all the coordinates of point and in collapsed scenario sometimes I dont even need 3 points (in this case, pt at index 2, 3, 4).
Is there a way so that even in collapsed form, my points remain same and it doesn’t change with respect to collapsed/expanded form.