I am having a problem where links that have been reshaped do not reload using the stored points, but go back to the default routing points. Overall my implementation looks a lot like the Dynamic Ports sample, but using React, and the gojs-react npm component.
I am using model.toJson and model.fromJson, and storing in a database between reloads. I can see in the database that links in the links have points that update as I reshape the link. Here is a sample of the first link in the database:
"linkDataArray": [
{
"id": "cf7ae4e7-1b9d-4a36-9985-8e6604a1f57c",
"to": "ea4900e0-0817-4d4f-9fa7-d28ec88ff904",
"from": "0bd4201f-be65-49dc-a1ee-96257a100879",
"text": "FIRST",
"points": [
-114.14285278320312,
22.5,
-96.14285278320312,
22.5,
-55.33333396911621,
22.5,
-55.33333396911621,
97.5,
-51.857147216796875,
97.5,
-45.857147216796875,
97.5
],
"toPort": "_01",
"fromPort": "01",
"segmentIndex": {
"class": "NaN"
},
"segmentFraction": 0.21681827187411645
},
My link template does have the required binding, here it is in full:
diagram.linkTemplate =
goObject( CustomLink,
{
routing: go.Link.AvoidsNodes,
corner: 8,
curve: go.Link.JumpGap,
reshapable: true,
resegmentable: false,
relinkableFrom: true,
relinkableTo: true
},
new go.Binding( "points" ).makeTwoWay(),
goObject( go.Shape, { stroke: "#2F4F4F", strokeWidth: 2 } ),
goObject( go.Shape, { toArrow: "Feather" } ),
goObject( go.Panel, "Auto",
{ visible: false, _isLinkLabel: true, segmentIndex: NaN, segmentFraction: 0.5 }, // Default not visible
new go.Binding( "visible", "text", text => !!text ),
goObject( go.Shape, { stroke: "#2F4F4F", fill: '#ffffff', strokeWidth: 0.5 } ),
goObject( go.Panel, "Horizontal", { margin: new go.Margin( 3, 3, 0, 3 ) }, // Panel needed for inner margins.
goObject( go.TextBlock, "", // the label text
{
textAlign: "center",
font: "9pt helvetica, arial, sans-serif",
stroke: "#2F4F4F",
editable: true
},
new go.Binding( "text" ).makeTwoWay()
),
),
new go.Binding( "segmentFraction" ).makeTwoWay()
)
)
The linkDataArray is then fed into the React component:
<ReactDiagram
ref={diagramRef}
initDiagram={initDiagram}
divClassName='diagram-component'
nodeDataArray={nodes}
linkDataArray={links}
linkKeyProperty="id"
onModelChange={onModelChange}
skipsDiagramUpdate={skipsDiagramUpdate}
/>
…but when the diagram is drawn all link reshapes are ignored and they are routed with the default path.
(This is with “gojs”: “^2.1.30”, “gojs-react”: “^1.0.10” )