Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 6925

Node Overlapping - Genogram Layout

$
0
0

@julio.sampaio wrote:

Hello!

Is there a way to avoid node overlapping when using the GenogramLayout class, defined here ?

Here is a gif showing what is happening to the nodes.

I've found this sample, using the following function:

      function shiftNodesToEmptySpaces() {
        myDiagram.selection.each(function(node) {
          if (!(node instanceof go.Node)) return;
          // look for Parts overlapping the node
          while (true) {
            var exist = myDiagram.findObjectsIn(node.actualBounds,
                                                // only consider Parts
                                                function(obj) { return obj.part; },
                                                // ignore Links and the dropped node itself
                                                function(part) { return part instanceof go.Node && part !== node; },
                                                // check for any overlap, not complete containment
                                                true).first();
            if (exist === null) break;
            // try shifting down beyond the existing node to see if there's empty space
            node.position = new go.Point(node.actualBounds.x, exist.actualBounds.bottom+10);
          }
        });
      }

Can I use this function within the GenogramLayout class? If yes, where should I use it?

Thank you!

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 6925

Trending Articles