@walter here is code example
// Initialize the diagram
const $ = go.GraphObject.make
const diagram = $(go.Diagram, diagramRef.current, {
"undoManager.isEnabled": true,
model: new go.GraphLinksModel({
linkKeyProperty: "key",
}),
"animationManager.isEnabled": false,
})
// Create a selection adornment template for links
const selectionTemplate = $(
go.Adornment,
"Link",
$(go.Shape, { isPanelMain: true, stroke: "#00A9C9", strokeWidth: 3 }),
$(go.Shape, { toArrow: "Standard", stroke: null, fill: "#00A9C9" }),
)
// Define the node template
diagram.nodeTemplate = $(
go.Node,
"Auto",
{
width: 120,
height: 60,
selectionAdorned: true,
},
$(go.Shape, "RoundedRectangle", {
fill: "#EFEFEF",
stroke: "#333333",
strokeWidth: 1.5,
}),
$(
go.TextBlock,
{
margin: 8,
font: "bold 12px sans-serif",
stroke: "#333333",
editable: true,
},
new go.Binding("text"),
),
)
// Define the link template with all the specified settings
const interactive = true
diagram.linkTemplate = $(
go.Link,
{
zOrder: -5,
selectionAdorned: true,
adjusting: go.LinkAdjusting.None,
toEndSegmentLength: 25,
fromEndSegmentLength: 25,
toShortLength: 5,
fromShortLength: 0,
relinkableFrom: true,
relinkableTo: true,
reshapable: true,
resegmentable: true,
shadowOffset: new go.Point(2, 2),
shadowBlur: 10,
selectionAdornmentTemplate: !interactive ? null : selectionTemplate,
isActionable: interactive,
routing: go.Routing.AvoidsNodes,
curve: go.Curve.JumpOver,
corner: 20,
},
$(go.Shape, { strokeWidth: 2, stroke: "#555" }),
$(go.Shape, { toArrow: "Standard", stroke: null, fill: "#555" }),
$(
go.Panel,
"Auto",
{
cursor: "pointer",
alignment: go.Spot.Center,
alignmentFocus: go.Spot.Center,
segmentFraction: 0.5,
segmentOrientation: go.Orientation.Upright,
background: "white",
},
$(go.Shape, "RoundedRectangle", {
fill: "#FFFFFF",
stroke: "#555555",
strokeWidth: 1,
}),
$(
go.TextBlock,
{
font: "10pt sans-serif",
stroke: "#333333",
editable: true,
textAlign: "center",
wrap: go.TextBlock.WrapFit,
},
new go.Binding("text", "text"),
),
),
)
// Create the model data
const nodeDataArray = [
{ key: 1, text: "Node 1", loc: "100 100" },
{ key: 2, text: "Node 2", loc: "300 100" },
]
const linkDataArray = [
{
key: -1,
from: 1,
to: 2,
text: "This is a much longer link text that.",
},
]
// Initialize the model
diagram.model = new go.GraphLinksModel({
nodeDataArray: nodeDataArray,
linkDataArray: linkDataArray,
linkKeyProperty: "key",
})
// Position nodes
diagram.nodes.each((node) => {
const data = node.data
if (data.loc) {
const parts = data.loc.split(" ")
node.location = new go.Point(Number.parseInt(parts[0]), Number.parseInt(parts[1]))
}
})