Skip to content
Permalink
Browse files

add comments to `addLeafCount()`

and remove it from initial phylotree setup as it's only every used in unrooted layouts and each call to `unrootedLayout` will call it.
  • Loading branch information...
jameshadfield committed Jul 30, 2019
1 parent 4608e88 commit 3a594b3bf36be2d3b42f383ba3bda9776ad577fe
Showing with 8 additions and 7 deletions.
  1. +7 −5 src/components/tree/phyloTree/helpers.js
  2. +1 −2 src/components/tree/phyloTree/phyloTree.js
@@ -1,10 +1,12 @@
/* eslint-disable no-param-reassign */

/*
* adds the total number of descendant leaves to each node in the tree
* the functions works recursively.
* @params:
* node -- root node of the tree.
/**
* computes a measure of the total number of leaves for each node in
* the tree, weighting leaves differently if they are inView.
* Note: function is recursive
* @param {obj} node -- root node of the tree
* @returns {undefined}
* @sideEffects sets `node.leafCount` {number} for all nodes
*/
export const addLeafCount = (node) => {
if (node.terminal && node.inView) {
@@ -1,6 +1,6 @@
import { scaleLinear } from "d3-scale";
import { createDefaultParams } from "./defaultParams";
import { addLeafCount, createChildrenAndParentsReturnNumTips, setYValues } from "./helpers";
import { createChildrenAndParentsReturnNumTips, setYValues } from "./helpers";
import { change, modifySVG, modifySVGInStages } from "./change";

/* PROTOTYPES */
@@ -41,7 +41,6 @@ const PhyloTree = function PhyloTree(reduxNodes, debugId) {
this.xScale = scaleLinear();
this.yScale = scaleLinear();
this.zoomNode = this.nodes[0];
addLeafCount(this.nodes[0]);
this.strainToNode = {};
this.nodes.forEach((phylonode) => {this.strainToNode[phylonode.n.strain] = phylonode;});
/* debounced functions (AFAIK you can't define these as normal prototypes as they need "this") */

0 comments on commit 3a594b3

Please sign in to comment.
You can’t perform that action at this time.