I’m trying to make links more curved. However, as far as I see, curviness property is not respected.
I’m using the following code
const $ = go.GraphObject.make
const diagram = $(go.Diagram, diagramRef.current, {
"undoManager.isEnabled": true,
layout: $(go.TreeLayout, { angle: 90, nodeSpacing: 20, layerSpacing: 80 }),
model: new go.GraphLinksModel({
linkKeyProperty: "key",
}),
})
// Define a simple Node template
diagram.nodeTemplate = $(
go.Node,
"Auto",
$(go.Shape, "RoundedRectangle", {
fill: "#f0f4f8",
stroke: "#c5d1dc",
strokeWidth: 2,
portId: "",
fromLinkable: true,
toLinkable: true,
cursor: "pointer",
}),
$(go.TextBlock, { margin: 10, font: "16px sans-serif" }, new go.Binding("text")),
)
// Define a single Link template with bindings for curviness and text
diagram.linkTemplate = $(
go.Link,
{
curve: go.Link.Bezier,
toEndSegmentLength: 50,
},
new go.Binding("curviness", "curviness"),
$(go.Shape, { strokeWidth: 2 }, new go.Binding("stroke", "color")),
$(
go.Shape,
{
toArrow: "Standard",
stroke: null,
scale: 1.2,
},
new go.Binding("fill", "color"),
),
$(
go.TextBlock,
{
segmentOffset: new go.Point(0, -10),
font: "12px sans-serif",
},
new go.Binding("text", "curviness", (value) => `curviness: ${value}`),
),
)
// Create the model data
const nodeDataArray = [
{ key: 1, text: "Center Node" },
{ key: 2, text: "Node 2" },
{ key: 3, text: "Node 3" },
{ key: 4, text: "Node 4" },
{ key: 5, text: "Node 5" },
{ key: 6, text: "Node 6" },
]
const linkDataArray = [
{ key: -1, from: 1, to: 2, curviness: 0, color: "#2563eb" },
{ key: -2, from: 1, to: 3, curviness: 20, color: "#7c3aed" },
{ key: -3, from: 1, to: 4, curviness: 50, color: "#db2777" },
{ key: -4, from: 1, to: 5, curviness: -30, color: "#059669" },
{ key: -5, from: 1, to: 6, curviness: 100, color: "#d97706" },
{ key: -6, from: 1, to: 6, curviness: 500, color: "#d97706" },
]
diagram.model = new go.GraphLinksModel(nodeDataArray, linkDataArray)