Which Diagram Layout to use?

Just set the position or location (what the DraggingTool does) or call move or moveTo. Or depend on the Binding of position or location and set the corresponding data property.

yes, that’s what I am doing in my code example that I shared but the Node isn’t going to my desired position

I bound the position to the position prop but it doesn’t honor the value new go.Point(1000, 1000)

Since your Binding converts a string to a Point, the data property value had better be a string.

Aiight this combo worked… :-)

const importNode = $(
    go.Node,
    "Auto",
    { movable: false, isLayoutPositioned: false },
    new go.Binding("isLayoutPositioned", "isLayoutPositioned").makeTwoWay(),
    new go.Binding("location", "location").makeTwoWay(),
  );

Palette Data

{
    ...
    isLayoutPositioned: true,
}

Then on ExternalObjectsDropped Drop event handler…

...
    const dModel = diagram.model as go.GraphLinksModel;

    // Change Node state in Diagram Model
    dModel.nodeDataArray.forEach((dNode: any) => {
      if (dNode.key === newNode.key) {
        dModel.set(dNode, "location", new go.Point(-200, -200));
        dModel.set(dNode, "isLayoutPositioned", false);
      }
    });

Does it need to be TwoWay? For performance reasons don’t make any Binding TwoWay unless you expect code to be modifying the GraphObject and you want that change to be remembered in the model.

1 Like