Hi Walter, thank you, for this Twins Example, I will need it.
But, about my question, I decided continue using label nodes to keep the GenogramLayout
class. Now I can reproduce what I wanted by mannualy defining the Spots everytime a new child (new link) is created. Using this function:
private rearrangeChildrenLinks(marriageNodeKey: any) {
var marriageNode: go.Node = this._diagram.findNodeForKey(marriageNodeKey);
var childrenLinks = marriageNode.findLinksConnected();
var childrenTotal = childrenLinks.count;
if (childrenTotal <= 1) {
return;
}
var spaceBetween = 0.8 / childrenTotal;
while (childrenLinks.next()) {
var childLink = childrenLinks.value;
var m = this._diagram.model;
var data = childLink.data;
var distanceBetween = spaceBetween * (childrenLinks.key + 1);
m.setDataProperty(data, 'fromSpot', new go.Spot(distanceBetween, 1));
}
}
This is the current result:
The problem now is, how to get the links to be a vertical line without the curves pointed above?
Here is my Diagram config:
var $ = this._$;
this._diagram = $(go.Diagram, this._canvasID, {
'initialAutoScale': go.Diagram.Uniform,
'initialContentAlignment': go.Spot.Center,
'allowDrop': true,
'LinkDrawn': this.createNewLink.bind(this),
'layout': $(GenogramLayout, {
'direction': 90,
'columnSpacing': 10,
'setsPortSpots': false,
'layerSpacing': 60
})
});
Here is my Label Node template:
public createMarriageNodeTemplate() {
var $ = this._$;
var nodeTemplate = $("Node", { height: 0, width: 0, fromEndSegmentLength: 1 },
$(go.Panel, 'Auto', {'isPanelMain': true},
$(go.Shape, {
"fill": "red"
}))
)
;
return nodeTemplate;
}
And here is the Link Template used to link child with the marriage node:
public createParentalLinkTemplate(): any {
var $ = this._$;
var parentalLink = $(go.Link,
{
'layerName': 'Background',
'selectable': true,
'fromSpot': go.Spot.Bottom,
'toSpot': go.Spot.Top
},
new go.Binding("fromSpot", "fromSpot"),
$(go.Shape, {
'strokeWidth': 2
},
new go.Binding("strokeDashArray", "isDashed", function(isDashed) {return (isDashed) ? [6,2] : null})
)
);
return parentalLink;
}
I need it to looks like it:
Are these information enough ? Thank you.