Just out of the curiosity…it seems that Node created via Model.addNodeData() sets the locationSpot to center. IMO it’s a bit confusing as Part.locationSpot states that the initial value should be Spot.TopLeft.
I’m quite new with GoJS, so maybe I’m missing something essential.
The value of Node.locationSpot, as with any other GraphObject property, is determined by the template’s initialization. (Unless there is a Binding for that property.)
Maybe the new Node is being positioned by Diagram.layout, causing the bound location information to be discarded? If so, try setting Layout.isInitial and/or Layout.isOngoing to false.
No, this property is not bound. Furthermore I don’t think the locationSpot is discarded as the following code makes it position as expected.
drawingDiagram.model.addNodeData({ key: tagNodeKey,
category: "comment",
text: "Example text.",
group: groupNodeKey,
loc: go.Point.stringify(tagLoc)
});
drawingDiagram.model.addLinkData({"from": node.data.key, "to": tagNodeKey});
drawingDiagram.model.setDataProperty(node.data, "group", groupNodeKey);
drawingDiagram.commitTransaction("addTag");
// Some reason created node's initial location spot is at the center.
// We want it to be at top-left.
drawingDiagram.startTransaction("modTag");
var newTag = drawingDiagram.findNodeForKey(tagNodeKey);
newTag.locationSpot = go.Spot.TopLeft;
drawingDiagram.commitTransaction("modTag");
I also debugged the locationSpot property value and it indeed wasn’t TopLeft.