NorthwoodsSoftware / GoJS

JavaScript diagramming library for interactive flowcharts, org charts, design tools, planning tools, visual languages.
http://gojs.net
Other
7.8k stars 2.86k forks source link

The Circular layout somehow breaks the links #211

Closed postulkam closed 5 months ago

postulkam commented 6 months ago

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?

simonsarris commented 6 months ago

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

simonsarris commented 6 months ago

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);
};
postulkam commented 6 months ago

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.