@prameela.dara wrote:
Hi,
Below is the twins display code which I am using in genogram application
myDiagram.linkTemplate = // for parent-child relationships $(TwinLink, // custom routing for same birth siblings { routing: go.Link.AvoidsNodes, curviness: 10, layerName: "Background", selectable: false, fromSpot: go.Spot.Bottom, toSpot: go.Spot.Top }, $(go.Shape, { strokeWidth: 2 }) ); //custom routing for same birth siblings function TwinLink() { go.Link.call(this); } go.Diagram.inherit(TwinLink, go.Link); TwinLink.prototype.computePoints = function() { var result = go.Link.prototype.computePoints.call(this); var pts = this.points; if (pts.length >= 4) { var birthId = this.toNode.data["birth"]; if (birthId) { var parents = this.fromNode; var sameBirth = 0; var sumX = 0; var it = parents.findNodesOutOf(); while (it.next()) { var child = it.value; if (child.data["birth"] === birthId) { sameBirth++; sumX += child.location.x; } } if (sameBirth > 0) { /* sameBirth = sameBirth +50; sumX = sumX + 50;*/ var midX = sumX/sameBirth; var oldp = pts.elt(pts.length-4); // pts.setElt(pts.length-3, new go.Point(midX, oldp.y)); pts.setElt(pts.length-3, new go.Point(midX, oldp.y)); pts.setElt(pts.length-1, pts.elt(pts.length-1)); // for below vertical pts.setElt(pts.length-2, new go.Point(midX, oldp.y)); pts.setElt(pts.length-1, pts.elt(pts.length-1)); } } } return result; }; // end TwinLink classPassing Data is :
{key: 0, name: "Aaron",s:"FM",age:"31",div:1,relationText:"1=divorce"}, {key: 1, name: "Alice",s:"F",age:"29"}, {key: 2, name: "abc",s:"M",age:"20",f:0,m:1,relationText:"1=child 1"}, {key: 3, name: "xcv",s:"M",age:"18",f:0,m:1,nla:1,relationText:"1=child 2"}, {key: 4, name: "dfg",s:"M",age:"16",f:0,m:1,la:1,relationText:"1=child 3"}, {key: 5, name: "qqq",s:"F",age:"12",f:0,m:1,birth:1,relationText:"1=child 4"}, {key: 6, name: "fgr",s:"F",age:"12",f:0,m:1,birth:1,relationText:"1=child 5"}Example for one key details as below:
{key: 2, name: "abc",s:"M",age:"20",f:0,m:1,relationText:"1=child 1"},Here relationText represented as “1=child 1”…
(“1” is mother’s or father’s key number) = (“child 1” is text which should be displayed on the link between child and mother or father’s node).
In the above example The text “Child 1” will display at the above of child node which is key:2.
Like that I implemented code.Same way don’t know why twins nodes are not displaying as “child 4” and “child 5”.
Is this possible to display text for twins. If yes can you please explain?Please let me know if anything required.
Posts: 2
Participants: 2
