Ports Saving

fromPort & toPort Properties are not generated in the linkdatarray of the Json that needs to be saved, because of which NODE1(R port) connected to NODE2(L port) keep changing as and when I move the node to a different position.

Could someone please help me with this issue ?


Have you set GraphLinksModel.linkFromPortIdProperty and .linkToPortIdProperty to the names of the properties on your link data that you want to remember the names of the ports that the link should connect?

Nope I havent…
var go$ = go.GraphObject.make;
myDiagram.model.nodeDataArray = [];

my Node template is :
<span =“apple-tab-span”="" style=“white-space:pre”> go$(go.Node, “Spot”, nodeStyle(),
new go.Binding(“location”, “loc”, go.Point.parse).makeTwoWay(go.Point.stringify),
new go.Binding(“desiredSize”, “size”, go.Size.parse).makeTwoWay(go.Size.stringify),
go$(go.Panel, “Auto”,
go$(go.Picture, { source: “”, name: “pic”, desiredSize: new go.Size(50, 50) },
new go.Binding(“source”, “key”, fnConvertKeyImage),
new go.Binding(“desiredSize”, “size”, go.Size.parse).makeTwoWay(go.Size.stringify))),
makePort(“L”, go.Spot.Left, true, true),
makePort(“R”, go.Spot.Right, true, true));

myDiagram.linkTemplate =
{routing: go.Link.AvoidsNodes,
curve: go.Link.JumpOver,
corner: 5, toShortLength: 4,
relinkableFrom: true, relinkableTo: true, reshapable: true
new go.Binding(“points”).makeTwoWay(),
{ isPanelMain: true,
strokeWidth: 3,
stroke: “black”
go$(go.Shape, // the arrowhead
{fromArrow: “StretchedDiamond”,
fill: “white”, strokeWidth: 1
go$(go.Shape, // the arrowhead
{toArrow: “StretchedDiamond”,
fill: “white”, strokeWidth: 1
go$(go.Panel, “Auto”,
{ visible: false, name: “Link”, segmentIndex: 2, segmentFraction: 0.5 },
new go.Binding(“visible”, “visible”).makeTwoWay(),
go$(go.Shape, “RoundedRectangle”,
{fill: “#F8F8F8”, stroke: null })));

<textarea id=“textareaID”>
{ “class”: “go.GraphLinksModel”,
“linkFromPortIdProperty”: “fromPort”,
“linkToPortIdProperty”: “toPort”,
“nodeDataArray”: [],

where do I set set GraphLinksModel.linkFromPortIdProperty and .linkToPortIdProperty

Right after you allocate a new go.GraphLinksModel().

Note also how those properties are set in JSON text and read by Model.fromJson.

Sorry, I didnt get you …

I did this : myDiagram.model = go.Model.fromJson(strJsontext);

I created a diagram using a Json(strJsontext) which has fromport and toport values in it … But still the ports keep changing when I move the nodes.

Well, does your link data in your JSON text contain the port ids that you want?

Everything related to connecting links with particular ports is demonstrated by samples such as FlowChart. Perhaps you can compare your app to see what is missing.