Link Labels location

Hi,
I have a link template who looks like this :

diagram.linkTemplate = $(go.Link,
            $(go.Shape,
                  {
                     stroke: "black", strokeWidth: 2
                  }
            ),
            $(go.Shape,
                    {
                        toArrow: "Standard",
                        stroke: "black", strokeWidth: 2
                    }
            ),
            $(go.Panel, "Vertical",
                    {
                        segmentIndex: 0,
                        alignmentFocus: go.Spot.BottomLeft
                    },
                    $(go.TextBlock,
                            {
                                font : "14pt arial bold",
                                stroke: "red"
                            } ,
                            new go.Binding("text", "portA")
                    )
            ),
            $(go.Panel, "Vertical",
                    {
                        segmentIndex: -1,
                        alignmentFocus: go.Spot.TopRight
                    },
            $(go.TextBlock,
                    {
                        font : "14pt arial bold",
                        stroke: "red"
                    } ,
                    new go.Binding("text", "portZ")
            )
    )

The results as shown :

The “aaaa” and “bbbb” labels are located as desired.
But the “cccc” and “dddd” are shifed to the right and left.
How can i control their location ? They show be located like “aaa” and “bbb”.
I tried with segementOffset/Orientaion/Fraction but it even got worse.
Please advice.
Regards,
Tany

Try segmentOffset: new go.Point(NaN, NaN) instead of setting alignmentFocus.

Example: https://gojs.net/latest/samples/entityRelationship.html

Yes, but this will put “aaaa” and “bbbb” above the link line. The “bbbb” should retain under the line

Any thoughts ?

Sorry, I’ve been busy.

If you always want the label to be on the “right” side of the link, as seen traveling in the direction of the link, then you could set the Point.y value of the GraphObject.segmentOffset to be a positive number.

I just tried this, modifying the samples/entityRelationship.html sample:

          $(go.TextBlock,  // the "to" label
            {
              textAlign: "center",
              font: "bold 14px sans-serif",
              stroke: "#1967B3",
              segmentIndex: -1,
              segmentOffset: new go.Point(NaN, 12),
              segmentOrientation: go.Link.OrientUpright
            },
            new go.Binding("text", "toText"))

Unfortunately you’ll need to hard-code the offset, so it won’t be adaptive of the label size, unlike NaN.

Looks good,
Thanks