Why not always have the label TextBlock be visible, and just modify the text that it shows according to the port that it is connected with. In fact you could just have a Binding determine the label. Here’s a minimal Link template. Caution, I haven’t tried this. I’m assuming your link data object has not only “from” but “fromPort” as well as “to” and “toPort” properties.
myDiagram.linkTemplate =
$(go.Link,
$(go.Shape),
$(go.TextBlock,
new go.Binding(“text”, “fromPort”, function§ {
switch § {
case “R”: return “right side”;
case “B”: return “bottom side”;
case “L”: return “left side”;
default: return “”;
}
}))
);
I finally had a chance to try it, and I confirmed that it works.
It also updates automatically if Link.relinkableFrom and/or Link.relinkableTo are set to true and the user actually reconnects the link to a port on a different side of the same or a different node. The magic of data binding!