Don't redraw link on rotate

Hi, we’re using the linking functionality from Dynamic Ports and we’re running into an “issue”. The users are wondering if it is possible for links inside of a group/multi-selection to stay static and just rotate along with the group they are inside, instead of redrawing and reorienting after each rotate. I tried just changing the angle of the link itself but it added an offset to it and would have to end up redrawing the link in the end. I was overwriting the computePoints() function and what I have to far is

computePoints = function() {
   this.angle = this.angle + 5;
   return true;

Do you have any ideas on how to make that work nicely?


What is your group template? And do you have and screenshots or sketches of what is happening vs what you’d like to happen?

Group template:

this.diagram.groupTemplate = $(go.Group, {
        angle: 0,
        contextMenu: nodeContextMenu,
        ungroupable: true,
        handlesDragDropForMembers: true,
        selectionAdorned: false,
        locationObjectName: "SHAPE",
        resizable: true,
        resizeObjectName: "SHAPE",
        resizeAdornmentTemplate: resizeAdornmentTemplate,
        dragComputation: this.stayInGroup,
        rotatable: true,
        locationSpot: go.Spot.Center,
        rotateAdornmentTemplate: rotateAdornmentTemplate
      new go.Binding("location", "pos", go.Point.parse).makeTwoWay(go.Point.stringify),
      new go.Binding('angle').makeTwoWay(),
          name: "SHAPE",
          fill: "transparent",
          stroke: "gray",
          strokeDashArray: [5, 5],
          strokeWidth: 2,
          desiredSize: new go.Size(100, 100),  // default size
          minSize: new go.Size(1, 1)  // don't allow zero width or height
        new go.Binding("desiredSize", "size", go.Size.parse).makeTwoWay(go.Size.stringify)

And here’s an image showing current behavior:

We’d like to see the line as drawn in the first image stay the same as the group is rotated. Currently it gets redrawn every time the rotation ticks.

This isn’t normally how groups work, do you have other customizations for moving and rotating those nodes?

What happens if you change the value of the Link’s adjusting to go.Link.Scale or go.Link.Stretch?

We’ve messed with those props a bit, but we weren’t able to get anything useful out of them. We’re also using for some custom rotating behavior.

I see. I’m not yet sure what to propose, but what do you expect to happen if, after a rotation, you drag and move one of the nodes? Will the link recompute then?

Are your links orthogonally routed? Orthogonal routing means that the points of the route, which are always in document coordinates, have adjacent points share either the same X or the same Y value. That is different from what I think you want, which would require the points not to be orthogonal.

Right, dragging a single node or rotating a single node should redraw the line, but when rotating the whole system we would like to maintain the existing pathing.

We can look into the orthogonal routing, but the structure/path of the line itself is fine, we just dont want it to change when you rotate the two nodes and line all as one. I think because the coordinates on the line are based on the document, we would need to have some serious math to adjust the line after each rotation tick, since the line will likely not fall right on the center point of the selected group.

Decades ago when we were designing/implementing the routing behavior for links and considering what should happen when “groups” are rotated in the manner you describe, we wondered what other apps do in this situation. Visio maintained orthogonality relative to the whole diagram, just as we do.

Yes, if you want that kind of functionality, you’ll need to turn off Orthogonal Link.routing and just rotate/translate the Link.points. That shouldn’t be too hard, but if then one of those nodes changes size or location – the route might not look “ortho” any more.

Yeah that all makes sense. We’ll have to run this by our stakeholders and see if it’s really a big enough issue for them to change some of the core linking behavior. Thanks for the input.