I am using the TreeLayout where i persist the location information.
When i allow for auto layout, the graph respects the portIds - everything is good.
But when I don’t do the initial layout - all the nodes are correctly positioned. But the links don’t seem to respect the ports. Even as i drag around the port keeps moving/changing ports.
The logic is - if we have persisted locations, don’t perform initial layout. This is when problem happens and the links dont respect portIds from the links array
if(hasPeristedLocations) diagram.layout.isInitial = false;
here is how the links model is setup
diagram.model =
$G(go.GraphLinksModel, {
"linkFromPortIdProperty": "fromPort",
"linkToPortIdProperty": "toPort",
nodeDataArray: nodeDataArray,
linkDataArray: linkDataArray
});
sample link data
var linkDataArray = [
{ “from”: 1, “to”: 2, “fromPort”: “B”, “toPort”: “T” },
];
my node template
$G(go.Node, “Auto”,
{
selectionAdorned: false
}, new go.Binding(“location”, “”, parseStringToGoPoint).makeTwoWay(stringifyGoPoint),
$G(go.Shape, “Rectangle”,
{ strokeWidth: 1 }),
makeTopPort(),
makeBottomPort()
);
my port templates
return $G(go.Shape, “Circle”, {
fill: “transparent”,
stroke: null,
desiredSize: new go.Size(8, 8),
alignment: go.Spot.Top, alignmentFocus: go.Spot.Top,
portId: “T”,
fromSpot: go.Spot.Top, toSpot: go.Spot.Top,
fromLinkable: false, toLinkable: true,
cursor: “pointer”
});
return $G(go.Shape, “Circle”, {
fill: “transparent”,
stroke: null,
desiredSize: new go.Size(8, 8),
alignment: go.Spot.Bottom, alignmentFocus: go.Spot.Bottom,
portId: “B”,
fromSpot: go.Spot.Bottom, toSpot: go.Spot.Bottom,
fromLinkable: true, toLinkable: false,
cursor: “pointer”
});
link template
$G(go.Link, go.Link.Orthogonal, { corner: 5, toShortLength: 4, selectable: true, curve: go.Link.JumpOver, relinkableFrom: true, relinkableTo: true });