GoJS icon indicating copy to clipboard operation
GoJS copied to clipboard

The Circular layout somehow breaks the links

Open postulkam opened this issue 1 year ago • 3 comments

Hi, the Circular layout encounters issues with rerouting links when used after another layout.

When computesBoundsIncludingLinks in a group is set to false and the user changes the layout type in groups, it attempts to change the link routing, but then it reverts them back to the previous layout route, while also laying out the nodes in the group correctly by Circular layout at the same time. When computesBoundsIncludingLinks in a group is set to true and the user changes the layout type in groups, the Circular layout uses ports from the previous layout, causing the links to come out from the node in the direction of the previous layout, which is unexpected.

GoJS version: 3.0.1 Example with better explanation: https://jsfiddle.net/Mi_Po/8dvgsym2/126/

I noticed that the Circular layout lacks the setsPorts feature that other layout have. Could that be the problem?

postulkam avatar May 10 '24 07:05 postulkam

Thanks for reporting this. We'll investigate and get back to you.

simonsarris avatar May 10 '24 13:05 simonsarris

This has been fixed and will be out with the next release, though it may be some days before we release again, as we just released 3.0.2 yesterday.

Meanwhile, if you need a workaround immediately, you can add this to your code:

go.Group.prototype.ensureBounds = function () {
  const g = this;
  if (g.isSubGraphExpanded) {
    this.memberParts.each((p) => {
      p.ensureBounds();
    });
  }
  go.Node.prototype.ensureBounds.call(this);
};

simonsarris avatar May 10 '24 19:05 simonsarris

Thank you for your quick response! Unfortunately, I can't figure out how and where to use these functions in my templates.

Meanwhile, I found another workaround - binding for the layout type and setting computesBoundsIncludingLinks to true only for the Cycle layout.

postulkam avatar May 13 '24 13:05 postulkam