I’m trying to get the link points after a user has drawn a new link. I use this to get the altered points:
myDiagram.addModelChangedListener(function (e) {
// only at end of transaction or undo or redo
if (!e.isTransactionFinished) return;
// only when have added a new link
if (!e.object.changes.any(function(c) {
return (c.change === go.ChangedEvent.Insert && c.propertyName === "linkDataArray");
})) return;
// log link's new route
e.object.changes.each(function(c) {
if (c.model !== null && c.change === go.ChangedEvent.Property && c.propertyName === "points") {
console.log(c.object.points);
}
});
});
But I’m not getting the points for the link:
This is my linkTemplate:
myDiagram.linkTemplate = make(go.Link, { // the whole link panel
routing: go.Link.AvoidsNodes,
curve: go.Link.JumpOver,
corner: 5, toShortLength: 4,
relinkableFrom: true,
relinkableTo: true,
reshapable: true,
resegmentable: true,
// on double click, add label
doubleClick: function(e, link) {
link.findObject("LABEL").visible = true
e.diagram.commandHandler.editTextBlock()
},
// mouse-overs subtly highlight links:
mouseEnter: function(e, link) { link.findObject("HIGHLIGHT").stroke = "rgba(30,144,255,0.2)"; },
mouseLeave: function(e, link) { link.findObject("HIGHLIGHT").stroke = "transparent"; }
},
new go.Binding("points").makeTwoWay(),
make(go.Shape, // the highlight shape, normally transparent
{ isPanelMain: true, strokeWidth: 8, stroke: "transparent", name: "HIGHLIGHT" }),
make(go.Shape, // the link path shape
{ isPanelMain: true, stroke: "#31303a", strokeWidth: 2 }),
make(go.Shape, // the arrowhead
{ toArrow: "standard", stroke: null, fill: "#31303a"}),
make(go.Panel, "Auto", // the link label, normally not visible
{ visible: false, name: "LABEL", segmentIndex: 2, segmentFraction: 0.5, _isLinkLabel: true},
new go.Binding("visible", "visible").makeTwoWay(),
make(go.Shape, "RoundedRectangle", // the label shape
{ fill: "#F8F8F8", stroke: null }),
make(go.TextBlock, "", // the label
{
textAlign: "center",
font: "10pt helvetica, arial, sans-serif",
stroke: "#333333",
editable: true,
textEdited: function(textBlock, previousText, currentText) {
if(currentText == "") {
textBlock.panel.visible = false
} else {
textBlock.panel.visible = true
}
}
},
new go.Binding("text").makeTwoWay())
)
)
The points are correctly edited and added to the model when I call diagram.model.toJson()