Hi,
private createJunction(e, link) {
e.handled = true;
e.diagram.startTransaction("Link Label");
var label = { category: "LinkLabel", location: e.documentPoint }; // Create data for label node -- the junction Node
e.diagram.model.addNodeData(label);
var labelnode = e.diagram.findNodeForData(label); // Finds the created node from the NodeData
this.attachJunction(link, labelnode, e.documentPoint);
e.diagram.commitTransaction("Link Label");
}
and below is my nodetemplate
public getLinkLabelTemplate(): any {
return this._goMake(Node,
{
layerName: "Foreground", // always have link label nodes in front of Links
background: "transparent",
width: 12, height: 12,
locationSpot: Spot.Center,
movable: true, // can't move junctions
deletable: false, // but becomes deletable when there's no connected link
// only deletable when it's unconnected
linkConnected: function (node, link, port) {
node.deletable = false;
},
linkDisconnected: function (node, link, port) {
node.deletable = (node.linksConnected.count === 0);
},
segmentOrientation: Link.OrientAlong,
portSpreading: Node.SpreadingNone
},
new Binding("location", "location", Point.parse).makeTwoWay(Point.stringify),
new Binding("segmentIndex").makeTwoWay(), // remember where this label belongs on the link
new Binding("segmentFraction").makeTwoWay(),
this._goMake(Shape, "Circle",
{ // a junction node appears as just a small black circle
position: new Point(3, 3), // center the circle in the Node
width: 6, height: 6,
fill: "black", strokeWidth: 0,
portId: "",
fromLinkable: true, toLinkable: true, cursor: "pointer",
fromSpot: Spot.Center, toSpot: Spot.Center
})
)
}
while loading the diagram and rendering template getting same location.
Thank You