Because our persisted data model for links is different from what GoJS wants, we have to manually update the points when there are midpoints. We do this on InitialLayoutCompleted. When there aren’t any midpoints and the user adds one, here is the incremental JSON where points is an array:
{
"class" : "go.GraphLinksModel",
"incremental" : 1,
"linkKeyProperty" : "key",
"modifiedLinkData" : [{
"parent" : "ext-comp-1228",
"key" : "216:WPDS",
"midpoints" : {
"Na" : false,
"o" : [],
"H" : 0,
"ec" : null,
"Kj" : null,
"fa" : null
},
"category" : "namedlink",
"labelVisible" : false,
"text" : "",
"from" : "126:WPDS",
"to" : "216:WPDS",
"linkColor" : "#999",
"tranVisible" : true,
"strokeDashArray" : null,
"points" : [135.2847602000331, 115.81426167116703, 210, 242, 377.0966295976506, 176.01825395374823]
}
]
}
Now if there is an existing midpoint and the user adds another, points now comes back as an object.
{
"class" : "go.GraphLinksModel",
"incremental" : 1,
"linkKeyProperty" : "key",
"modifiedLinkData" : [{
"parent" : "ext-comp-1275",
"key" : "216:WPDS",
"midpoints" : {
"Na" : false,
"o" : [{
"class" : "go.Point",
"x" : 210,
"y" : 242
}
],
"H" : 1,
"ec" : null,
"Kj" : null,
"fa" : null
},
"category" : "namedlink",
"labelVisible" : false,
"text" : "",
"from" : "126:WPDS",
"to" : "216:WPDS",
"linkColor" : "#999",
"tranVisible" : true,
"strokeDashArray" : null,
"points" : {
"Na" : true,
"o" : [{
"class" : "go.Point",
"x" : 132.54668888700468,
"y" : 117.2503320708705
}, {
"class" : "go.Point",
"x" : 210,
"y" : 242
}, {
"class" : "go.Point",
"x" : 315,
"y" : 245
}, {
"class" : "go.Point",
"x" : 382.57772043949024,
"y" : 184.93091516489758
}
],
"H" : 0,
"ec" : null,
"Kj" : null,
"fa" : null
}
}
]
}
I don’t know if this is a bug or the way it’s designed to work but thought I would point it out. Personally I would prefer the incremental JSON to always be in the same format. I found a way to do this by changing link.point = List to link.points = List.toArray() when I manually set them.