Skip to content

Commit

Permalink
[phylotree] fix edge cases surrounding display of branch labels
Browse files Browse the repository at this point in the history
Fixes a couple of edge cases introduced by the scatterplot functionality which would result in a tree rendering with branch labels when it shouldn't have them (and vice versa).
  • Loading branch information
jameshadfield committed Mar 30, 2021
1 parent 0751e81 commit a80e186
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/tree/phyloTree/change.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const modifySVG = function modifySVG(elemsToUpdate, svgPropsToUpdate, tra
});

/* special cases not listed in classesToPotentiallyUpdate */
if (elemsToUpdate.has('.branchLabel')) {
if (elemsToUpdate.has('.branchLabel') && !extras.newBranchLabellingKey) {
this.updateBranchLabels(transitionTime);
}
if (extras.hideTipLabels) {
Expand Down
3 changes: 2 additions & 1 deletion src/components/tree/reactD3Interface/change.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ export const changePhyloTreeViaPropsComparison = (mainTree, phylotree, oldProps,
args.newBranchLabellingKey = "none";
} else if (
(oldProps.canRenderBranchLabels===false && newProps.canRenderBranchLabels===true) ||
(oldProps.selectedBranchLabel !== newProps.selectedBranchLabel)
(oldProps.selectedBranchLabel !== newProps.selectedBranchLabel) ||
(oldProps.scatterVariables.showBranches===false && newProps.scatterVariables.showBranches===true)
) {
args.newBranchLabellingKey = newProps.selectedBranchLabel;
}
Expand Down
7 changes: 6 additions & 1 deletion src/components/tree/reactD3Interface/initialRender.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ export const renderTree = (that, main, phylotree, props) => {
console.warn("can't run renderTree (not loaded)");
return;
}
// calculate if branch labels should be rendered
let renderBranchLabels = props.canRenderBranchLabels;
if (Object.prototype.hasOwnProperty.call(props.scatterVariables, "showBranches") && props.scatterVariables.showBranches===false) {
renderBranchLabels=false;
}
/* simply the call to phylotree.render */
phylotree.render(
select(ref),
Expand All @@ -20,7 +25,7 @@ export const renderTree = (that, main, phylotree, props) => {
{ /* parameters (modifies PhyloTree's defaults) */
grid: true,
confidence: props.temporalConfidence.display,
branchLabelKey: props.canRenderBranchLabels && props.selectedBranchLabel,
branchLabelKey: renderBranchLabels && props.selectedBranchLabel,
orientation: main ? [1, 1] : [-1, 1],
tipLabels: true,
showTipLabels: true
Expand Down

0 comments on commit a80e186

Please sign in to comment.