org-chart icon indicating copy to clipboard operation
org-chart copied to clipboard

fit() function doesn't distinguish between expanded and unexpanded nodes

Open Exscotticus opened this issue 7 months ago • 0 comments

Describe the bug In cases where no nodes list is supplied and the root node is used, the fit function doesn't take the root node's location into account along with its descendants. It doesn't distinguish between expanded and unexpanded nodes.

The bug is in the line that defines the descendants.

Currently...

let descendants = nodes ? nodes : root.descendants();

...and what I think it should be...

const descendants = nodes ? nodes : [root].concat(root.descendants().filter(d => d.data._expanded === true));

Exscotticus avatar Aug 02 '24 16:08 Exscotticus