I want to add a textblock in the center of line using LineDrawing tool but after few different ways i tried it is still adding the text at top left corner of the node.
selectionMargin = 5 / 2;
$(
go.Node,
{
reshapable: true, // allow LineReshapingTool to work
locationObjectName: "LINE",
locationSpot: new go.Spot(0, 0, selectionMargin, selectionMargin), // account for strokeWidth
zOrder: 1,
},
new go.Binding("location", "loc", go.Point.parse).makeTwoWay(
go.Point.stringify
),
new go.Binding("resizable", "resizable"),
{
rotatable: false,
rotateObjectName: "LINE",
},
new go.Binding("position", "pos", go.Point.parse).makeTwoWay(
go.Point.stringify
),
$(
go.Shape,
{
name: "LINE",
margin: 7.5,
fill: null,
stroke: "blue",
strokeWidth: 0.5,
position: new go.Point(
selectionMargin - 1 / 2,
selectionMargin - 1 / 2
),
},
new go.Binding("geometry", "pts", _makeGeo).makeTwoWay(_saveGeo),
new go.Binding("stroke", "isSelected", (s) =>
s ? "#00D1FF" : "#333333"
).ofObject(),
new go.Binding("desiredSize", "size", go.Size.parse).makeTwoWay(
go.Size.stringify
)
),
$(go.TextBlock, {
text: "PIZZA",
alignment: go.Spot.Center,
alignmentFocus: go.Spot.Center,
}),
$(
go.Shape, //this shape is for increasing touch area of line tool
{
// this shows the actual line, thinner than the transparent shape for selection
name: "LINE",
stroke: "#333333",
opacity: 0,
strokeWidth: 15,
position: new go.Point(
selectionMargin - 1 / 2,
selectionMargin - 1 / 2
),
}
)
)