Minimum graph size, center smaller graph

This commit is contained in:
Ian Gulliver
2019-07-08 02:35:40 +00:00
parent d2ec4d45a2
commit bb45fba08f

View File

@@ -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]) {