You could try to fix up the link routes once the link points have been loaded, in case the saved routes do not match any new node bounds due to changed content.
The following example depends on Link.adjusting being different than the default None:
<!DOCTYPE html>
<html>
<head>
<title>State Chart</title>
<!-- Copyright 1998-2021 by Northwoods Software Corporation. -->
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="go.js"></script>
<script id="code">
function init() {
var $ = go.GraphObject.make;
myDiagram =
$(go.Diagram, "myDiagramDiv",
{
"InitialLayoutCompleted": function(e) {
setTimeout(function() {
e.diagram.commit(function(diag) {
diag.links.each(function(l) { l.invalidateRoute(); });
});
}, 1);
}
});
myDiagram.nodeTemplate =
$(go.Node, "Auto",
{ locationSpot: go.Spot.Center },
new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify),
$(go.Shape, "RoundedRectangle",
{
parameter1: 20, // the corner has a large radius
fill: "goldenrod",
portId: "", cursor: "pointer",
fromLinkable: true, fromLinkableDuplicates: true,
toLinkable: true, toLinkableDuplicates: true
}),
$(go.TextBlock,
{ margin: 10, editable: true },
new go.Binding("text").makeTwoWay())
);
myDiagram.linkTemplate =
$(go.Link,
{
curve: go.Link.Bezier, adjusting: go.Link.End,
relinkableFrom: true, relinkableTo: true,
reshapable: true
},
new go.Binding("points").makeTwoWay(),
$(go.Shape, { strokeWidth: 1.5 }),
$(go.Shape, { toArrow: "standard", stroke: null })
);
load();
}
function save() {
document.getElementById("mySavedModel").value = myDiagram.model.toJson();
myDiagram.isModified = false;
}
function load() {
myDiagram.model = go.Model.fromJson(document.getElementById("mySavedModel").value);
}
</script>
</head>
<body onload="init()">
<div id="sample">
<div id="myDiagramDiv" style="background-color: whitesmoke; border: solid 1px black; width: 100%; height: 400px"></div>
<button id="SaveButton" onclick="save()">Save</button>
<button onclick="load()">Load</button>
Diagram Model saved in JSON format:
<textarea id="mySavedModel" style="width:100%;height:300px">
{ "class": "GraphLinksModel",
"nodeKeyProperty": "id",
"linkLabelKeysProperty": "labelKeys",
"nodeDataArray": [
{"id":0,"loc":"100 0","text":"Initial"},
{"id":1,"loc":"300 100","text":"First down"}
],
"linkDataArray": [
{"from":0,"to":1,"points":[136.11678575286592,11.05067617248961,180.67065784598805,24.68285308049549,333.3333282470703,8.333328247070312,310.42384936552855,71.33440828022111]},
{"from":0,"to":1,"points":[134.05877709763718,17.029388548818595,174.40966750898863,37.20483375449432,214.7605579203401,57.38027896017004,255.11144833169152,77.55572416584576]},
{"from":1,"to":0,"points":[257.67734129427646,124.35836106274874,207.3333282470703,153.3333282470703,168.1486771719892,49.726814428493135,130.3060807629716,22.113779998280563]}
]}
</textarea>
</div>
</body>
</html>