From bb45fba08f33c7f3e56ff2a194416f42967129fe Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Mon, 8 Jul 2019 02:35:40 +0000 Subject: [PATCH] Minimum graph size, center smaller graph --- Layout.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Layout.js b/Layout.js index 0619b9e..78b2d45 100644 --- a/Layout.js +++ b/Layout.js @@ -158,6 +158,19 @@ class Layout { } } } + + // Set a minimum size and center the smaller graph + const MIN_SIZE = 6; + for (let i of [0, 1]) { + let expand = MIN_SIZE - (max[i] - min[i] + 1); + if (expand <= 0) { + continue; + } + let expandHalf = Math.floor(expand / 2); + min[i] -= expandHalf; + max[i] += (expand - expandHalf); + } + // Offset is negative minimum, e.g min -1 means +1 to all values for (let node of this.nodes_) { for (let i of [0, 1]) {