diff --git a/src/components/tree/phyloTree/layouts.js b/src/components/tree/phyloTree/layouts.js index 17cd4b39c..f4af4a828 100644 --- a/src/components/tree/phyloTree/layouts.js +++ b/src/components/tree/phyloTree/layouts.js @@ -316,9 +316,10 @@ export const calcYValues = (nodes, spacing = "even") => { } const recurse = (node) => { - if (node.children) { - for (let i = node.children.length - 1; i >= 0; i--) { - recurse(node.children[i]); + const children = node.n.children; // (redux) tree node + if (children && children.length) { + for (let i = children.length - 1; i >= 0; i--) { + recurse(children[i].shell); } } else { node.displayOrder = calcY(node); @@ -326,8 +327,8 @@ export const calcYValues = (nodes, spacing = "even") => { return; } /* if here, then all children have yvalues, but we dont. */ - node.displayOrder = node.children.reduce((acc, d) => acc + d.displayOrder, 0) / node.children.length; - node.displayOrderRange = [node.n.children[0].displayOrder, node.n.children[node.n.children.length - 1].displayOrder]; + node.displayOrder = children.reduce((acc, d) => acc + d.displayOrder, 0) / children.length; + node.displayOrderRange = [children[0].displayOrder, children[children.length - 1].displayOrder]; }; recurse(nodes[0]); };