Extremity link labels colliding with node at angle

Hi again,

If I display link labels at the source extremity of links, they tend to collide with their source node at certain angles. See for example the screenshot taken with the “link labels near ends” sample in the documentation below:

Would there be a way to always have some sufficient margin at the left of the label so that it would be all right at all angles? I tried adding some margin to the TextBlock but it did not seem to do anything. I also tried segmentOffset but no success.

Thanks,
Marc.

You have the right idea, except that setting the margin on the TextBlock should have no effect, given how it is positioned within the Link Panel.

Instead, you can make the TextBlock measure as a larger object by wrapping it in a Panel. You can then either set the TextBlock.margin or the Panel.padding. Here’s that example from http://gojs.net/latest/intro/linkLabels.html:

diagram.linkTemplate = $(go.Link, $(go.Shape), $(go.Shape, { toArrow: "Standard" }), $(go.Panel, { segmentIndex: 0, segmentOffset: new go.Point(NaN, NaN), segmentOrientation: go.Link.OrientUpright, padding: new go.Margin(0, 15) }, $(go.TextBlock, "from") ), $(go.TextBlock, "to", { segmentIndex: -1, segmentOffset: new go.Point(NaN, NaN), segmentOrientation: go.Link.OrientUpright }) );

Perfect. Thanks!