From 6417f3f50e9499673902834490930a35dd61de5c Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Tue, 16 Jul 2019 04:55:01 +0000 Subject: [PATCH] Fix bugs in group borders --- LayoutNode.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/LayoutNode.js b/LayoutNode.js index b7e575b..ba15a7e 100644 --- a/LayoutNode.js +++ b/LayoutNode.js @@ -41,15 +41,16 @@ class LayoutNode { } // Am I in any labeled groups that node is not? - // If so, preserve one space above the group - let labeled = new Set(Array.from(this.groups).filter(g => !!g.label)); - if (asymDifference(labeled, node.groups).size) { + // If so, preserve two spaces above the group + if (asymDifference(this.labelGroups(this.groups), node.groups).size) { this.addAffinity(node, (d, v) => (v[0] >= -1 && v[0] <= 1 && v[1] < 0 && v[1] >= -2) ? -INF : 0); } - if (asymDifference(this.groups, node.groups).size) { + // Preserve one space all around the group + if (asymDifference(this.graphGroups(this.groups), + this.graphGroups(node.groups)).size) { this.addAffinity(node, d => d <= 2 ? -INF : 0); } @@ -92,6 +93,14 @@ class LayoutNode { } } + graphGroups(groups) { + return new Set(Array.from(groups).filter(g => g.hasGraphGroup())); + } + + labelGroups(groups) { + return new Set(Array.from(groups).filter(g => !!g.label)); + } + addAffinity(node, distanceToWeight) { if (this == node) { return;