Skip to content

Commit

Permalink
updated tip labeling to allow toggle to show all tips
Browse files Browse the repository at this point in the history
  • Loading branch information
ntaft committed Mar 27, 2020
1 parent 3633e73 commit 644a132
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/components/tree/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const Tree = connect((state) => ({
panelsToDisplay: state.controls.panelsToDisplay,
selectedBranchLabel: state.controls.selectedBranchLabel,
narrativeMode: state.narrative.display,
animationPlayPauseButton: state.controls.animationPlayPauseButton
animationPlayPauseButton: state.controls.animationPlayPauseButton,
alwaysDisplayTipLabels: state.controls.alwaysDisplayTipLabels
}))(UnconnectedTree);

export default Tree;
7 changes: 3 additions & 4 deletions src/components/tree/phyloTree/labels.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { timerFlush } from "d3-timer";
import { NODE_VISIBLE } from "../../../util/globals";

export const updateTipLabels = function updateTipLabels(dt) {
export const updateTipLabels = function updateTipLabels(alwaysDisplayTipLabels, dt) {
if ("tipLabels" in this.groups) {
this.groups.tipLabels.selectAll("*").remove();
} else {
Expand All @@ -14,9 +14,8 @@ export const updateTipLabels = function updateTipLabels(dt) {
const inViewTerminalNodes = this.nodes
.filter((d) => d.terminal)
.filter((d) => d.inView);
// console.log(`there are ${inViewTerminalNodes.length} nodes in view`)
if (inViewTerminalNodes.length < this.params.tipLabelBreakL1 || true) {

// console.log(`there are ${inViewTerminalNodes.length} nodes in view`)
if (inViewTerminalNodes.length < this.params.tipLabelBreakL1 || alwaysDisplayTipLabels) {
let fontSize = this.params.tipLabelFontSizeL1;
if (inViewTerminalNodes.length < this.params.tipLabelBreakL2) {
fontSize = this.params.tipLabelFontSizeL2;
Expand Down
5 changes: 5 additions & 0 deletions src/components/tree/reactD3Interface/change.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ export const changePhyloTreeViaPropsComparison = (mainTree, phylotree, oldProps,
args.newLayout = newProps.layout;
}

/* if force-display tip label control is toggled, re-render tree labels */
if (oldProps.alwaysDisplayTipLabels !== newProps.alwaysDisplayTipLabels) {
phylotree.updateTipLabels(newProps.alwaysDisplayTipLabels);
}

/* zoom to a clade / reset zoom to entire tree */
if (oldTreeRedux.idxOfInViewRootNode !== newTreeRedux.idxOfInViewRootNode) {
const rootNode = phylotree.nodes[newTreeRedux.idxOfInViewRootNode];
Expand Down

0 comments on commit 644a132

Please sign in to comment.