Auto Alignment of Links



Hello,

Is there any way i can get straight line for the link without adjusting it manually.As seen in the image there appears to be a small deviation can i align the these nodes automatically.

my link template is as follows,

myDiagram.linkTemplate =
$(go.Link, // the whole link panel
{ routing: go.Link.AvoidsNodes,
curve: go.Link.JumpOver,
corner: 5, toShortLength: 4,
relinkableFrom: true, relinkableTo: true, reshapable:true },
$(go.Shape, // the link path shape
{ isPanelMain: true,
stroke: “gray”, strokeWidth: 2 }),
$(go.Shape, // the arrowhead
{ toArrow: “standard”,
stroke: null, fill: “black”}),
$(go.Panel, “Auto”,
{ visible: false, name: “LABEL”, segmentIndex: 2, segmentFraction: 0.5},
new go.Binding(“visible”, “visible”).makeTwoWay(),
$(go.Shape, “RoundedRectangle”, // the link shape
{ fill: “#F8F8F8”, stroke: null }),
$(go.TextBlock, “Yes” ,// the label
{ textAlign: “center”,
font: “10pt helvetica, arial, sans-serif”,
stroke: “#919191”,
margin: 2, editable: true },
new go.Binding(“text”, “text”).makeTwoWay())
)
);

This has nothing to do with your link routing but everything to do with your node definition and location.

Are users positioning the nodes? If so, I suggest that you turn on grid snapping and make sure that the locationSpot is precisely in line with the ports, which looks like it should be go.Spot.Center.

I have Grid snapping on ,
myDiagram.grid.visible = true;
myDiagram.toolManager.draggingTool.isGridSnapEnabled = true;
myDiagram.toolManager.resizingTool.isGridSnapEnabled = true;
myDiagram.addDiagramListener(“ObjectSingleClicked”, onTextEdited);
// myDiagram.maxSelectionCount = 2;
myDiagram.allowDrop = true;
myDiagram.toolManager.linkingTool.temporaryLink.routing=go.Link.Orthogonal;
myDiagram.toolManager.relinkingTool.temporaryLink.routing=go.Link.Orthogonal;
myDiagram.undoManager.isEnabled = true;
is there any way where i can select two nodes and say align horizontally or vertically?

http://gojs.net/latest/extensions/DrawCommandHandler.js