Skip to content

Commit 126b895

Browse files
committed
🚧 fix and clarify calculation
1 parent 37d69ba commit 126b895

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

‎src/components/tree/phyloTree/helpers.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,18 @@ export const setDisplayOrder = ({nodes, focus}) => {
9999
let incrementer = (_node) => 1;
100100

101101
if (focus) {
102-
const numVisible = nodes[0].n.tipCount;
102+
const nVisible = nodes[0].n.tipCount;
103+
const nTotal = nodes[0].n.fullTipCount;
103104

104105
let yProportionFocused = 0.8;
105106
// Adjust for a small number of visible tips (n<4)
106-
yProportionFocused = Math.min(yProportionFocused, numVisible / 5);
107+
yProportionFocused = Math.min(yProportionFocused, nVisible / 5);
107108
// Adjust for a large number of visible tips (>80% of all tips)
108-
yProportionFocused = Math.max(yProportionFocused, numVisible / nodes.length);
109+
yProportionFocused = Math.max(yProportionFocused, nVisible / nTotal);
110+
111+
const yPerFocused = (yProportionFocused * nTotal) / nVisible;
112+
const yPerUnfocused = ((1 - yProportionFocused) * nTotal) / (nTotal - nVisible);
109113

110-
const yPerFocused = (yProportionFocused * nodes.length) / numVisible;
111-
const yPerUnfocused = ((1 - yProportionFocused) * nodes.length) / (nodes.length - numVisible);
112114
incrementer = (() => {
113115
let previousWasVisible = false;
114116
return (node) => {

0 commit comments

Comments
 (0)