I have spent too much time modifying your code to get it to run, and I’m giving up.
Start with something simple and elaborate it as needed. Here’s a version of my above code that runs in v2.3. All I had to do was replace the call to GraphObject.bindTwoWay with a call to bind with four arguments, which we have deprecated in v3 because explicitly calling bindTwoWay is clearer than just providing an extra argument.
<!DOCTYPE html>
<html>
<head>
<title>Minimal GoJS Sample</title>
<!-- Copyright 1998-2025 by Northwoods Software Corporation. -->
</head>
<body>
<div id="myDiagramDiv" style="border: solid 1px black; width:100%; height:400px"></div>
<textarea id="mySavedModel" style="width:100%;height:250px"></textarea>
<script type="importmap">{"imports":{"gojs":"https://cdn.jsdelivr.net/npm/[email protected]/release/go-debug-module.js"}}</script>
<script id="code" type="module">
import { Diagram, Node, Spot, Point, Panel, Shape, TextBlock, Adornment, Placeholder, GraphLinksModel } from "gojs";
const myDiagram =
new Diagram("myDiagramDiv", {
"undoManager.isEnabled": true,
"ModelChanged": e => { // just for demonstration purposes,
if (e.isTransactionFinished) { // show the model data in the page's TextArea
document.getElementById("mySavedModel").textContent = e.model.toJson();
}
}
});
myDiagram.nodeTemplate =
new Node({
locationSpot: Spot.Center,
rotatable: true, rotateObjectName: "ROT", rotationSpot: Spot.Center
})
// in 2.3 one can use the now-deprecated four-argument overload of GraphObject.bind to get TwoWay Binding
.bind/*TwoWay*/("location", "loc", Point.parse, Point.stringify)
.add(
// the details of this Panel don't matter, just that it's named by the rotateObjectName
new Panel("Auto", { name: "ROT" })
.bindTwoWay("angle")
.add(
new Shape({ fill: "white" })
.bind("fill", "color"),
new TextBlock({ margin: 8 })
.bind("text")
)
);
// the details of this Adornment don't matter, just as long as it has a Placeholder
myDiagram.nodeTemplate.selectionAdornmentTemplate =
new Adornment("Vertical")
.add(
new Placeholder(),
new TextBlock({ font: "bold 10pt sans-serif" })
.bind("text", "color"),
new Panel("Auto")
.add(
new Shape("RoundedRectangle", { fill: "whitesmoke" }),
new Panel("Vertical", {
itemTemplate:
new Panel()
.add(
new TextBlock()
.bind("text", "")
)
})
.bind("itemArray", "items")
)
)
myDiagram.model = new GraphLinksModel(
[
{ key: 1, text: "Alpha", color: "lightblue", items: ["one", "two", "three"] },
{ key: 2, text: "Beta", color: "orange", items: ["four", "five"] },
{ key: 3, text: "Gamma", color: "lightgreen", items: ["six", "seven", "eight"] },
{ key: 4, text: "Delta", color: "pink", angle: -45, items: ["ten", "eleven", "twelve"] }
],
[
{ from: 1, to: 2 },
{ from: 1, to: 3 },
{ from: 2, to: 2 },
{ from: 3, to: 4 },
{ from: 4, to: 1 }
]);
</script>
</body>
</html>