Links are not coming straight line

i need to have Links as shown above in Straight Line whenever i create diagram, but right now it happens only if the nodes in line have the text in same number lines in above example it’s two lines, if varies from node to node then i can’t have straight line as shown in below image,
May i know the solution for this?

What Diagram.layout are you using, and with what parameters?

What is your node template? Depending on the layout, it may help to set the Node.locationSpot to go.Spot.Center and the Node.locationObjectName to the name of the element that acts as the port (that contains or is the Picture).

var $ = go.GraphObject.make;
myDiagram =
$(go.Diagram, mydiagramid, // create a Diagram for the DIV HTML element
// position the graph in the middle of the diagram
initialContentAlignment: go.Spot.Center,
mouseDrop: function(e) { finishDrop(e, null); },
// allow double-click in background to create a new node
“clickCreatingTool.archetypeNodeData”: { text: “Node”, color: “white” },

      // allow Ctrl-G to call groupSelection()
      "commandHandler.archetypeGroupData": { text: "Group", isGroup: true, color: "blue" },

      // enable undo & redo
      "undoManager.isEnabled": true

function makePort(name, spot, output, input) {

	return $(go.Shape,
		figure: "Circle",
		fill: "transparent",
		stroke: null,
		desiredSize: new go.Size(4, 4),
		alignment: spot, alignmentFocus: spot,
		portId: name,
		fromSpot: spot, toSpot: spot,
		fromLinkable: output, toLinkable: input,
		cursor: "pointer"

$(go.Node, “Vertical”, { selectionAdornmentTemplate: UndesiredEventAdornment },{resizable: true,isShadowed:false}, nodeStyle(),new go.Binding(“text”, “key”),
new go.Binding(“location”, “loc”, go.Point.parse).makeTwoWay(go.Point.stringify,{routing:go.Link.AvoidsNodes}),
$(go.Panel, go.Panel.Auto,
{ desiredSize: new go.Size(24, 24) },
new go.Binding(“source”, “source”)),
makePort(“T”, go.Spot.Top , true, true),
makePort(“L”, go.Spot.Left, true, true),
makePort(“R”, go.Spot.Right, true, true),
makePort(“B”, go.Spot.Bottom, true, true)),
$(go.TextBlock, // the text label
{ font: “10pt Helvetica, Arial, sans-serif”,
stroke: “black”,
textAlign: “center”,
margin: 5,
maxSize: new go.Size(100, NaN),
wrap: go.TextBlock.WrapFit,
editable: false },
new go.Binding(“text”, “comments”).makeTwoWay())

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:false ,
new go.Binding(“fromPortId”, “fromport”),
new go.Binding(“toPortId”, “toport”),
$(go.Shape, // the link path shape
{ isPanelMain: true,
strokeWidth: 2 }),
$(go.Shape, // the arrowhead
{ toArrow: “standard”,
stroke: null, fill: “black”}),
$(go.TextBlock, “Yes”,{
font: “10pt helvetica, arial, sans-serif”,
stroke: “#919191”,
margin: 2, editable: true,
segmentOffset: new go.Point(0, -10)
new go.Binding(“text”, “text”).makeTwoWay(),
new go.Binding(“visible”, “visible”).makeTwoWay()),
new go.Binding(“withinLoop”, “withinLoop”),
new go.Binding(“afterLoop”, “afterLoop”),
$(go.TextBlock,“true” ,
{name: “trueBlock”,
new go.Binding(“trueBlock”, “trueBlock”))

these are the templates i am using.

It is hard to read your code when it is not properly formatted and indented.

You still have not said how the nodes are getting their locations. There seems to be no Diagram.layout, but only a Binding on Node.location. What is deciding the location values?

You also have not tried my suggestions.

i am not able to indent the code when i paste it in the forum, and i tried with, binding location manually. Without diagram.layout also if the connected nodes has same line of text(Label) it connects properly to nodes center.

Copy your code as simple text, and insert surrounded by triple backquotes.

Are all of the location y values the same in the model data?