Using LayeredDigraphLayout, I observe that nodes are spaced too far away, especially when there are few of them.
For example in [AAAA] ---- [BBBB] ---- [CCCC], the space between the nodes appear to be as long as the node labels, and it seems to be dependent on the size of the nodes.
I digged into the code and found out that with alignOption: go.LayeredDigraphAlign.All
, there is a partially undocumented function nodeMinLayerSpace
which does the relevant computation.
The code
return t.node === null && t.data === null ? 0 : this.S === 90 || this.S === 270 ? i ? t.focus.y + 10 : t.bounds.height - t.focus.y + add : i ? t.focus.x + 10 : t.bounds.width - t.focus.x + 10;
does some computation and then adds a constant 10 to the result.
I modified it a bit to only add 2 instead of 10. This makes the links shorter.
This is my current code:
class MyLayout extends go.LayeredDigraphLayout {
nodeMinLayerSpace(t, i) {
if (t.node === null && t.data === null) {
return 0;
}
if (self.S === 90 || self.S === 270) {
// we are only interested in S = 0, call the base method
return super.nodeMinLayerSpace(t, i);
}
let add = 2; // instead of 10
let computed = (t.bounds.width - t.focus.x) + add;
return computed;
}
}
However I am not sure I understand what is the principle behind the code.
- What exactly is the resulting value used for?
- What does
(t.bounds.width - t.focus.x)
compute? - Where does 10 come from?
- If I put 2 instead will it break somewhere for some topologies?
thanks,
A.