Skip to content
Permalink
Browse files

Merge pull request #728 from nextstrain/dynamically_add_tip_labels

Dynamically add tip labels
  • Loading branch information...
kairstenfay committed Jun 4, 2019
2 parents f98bb55 + 57f762c commit c9ed89c7a7912f5e555dcaaee6c793c5c88aceef
Showing with 5 additions and 6 deletions.
  1. +3 −5 src/components/tree/phyloTree/change.js
  2. +2 −1 src/components/tree/phyloTree/labels.js
@@ -204,6 +204,7 @@ export const modifySVGInStages = function modifySVGInStages(elemsToUpdate, svgPr
if (this.params.showGrid) this.addGrid();
this.svg.selectAll(".tip").remove();
this.drawTips();
this.updateTipLabels();
if (this.vaccines) this.drawVaccines();
this.addTemporalSlice();
if (this.layout === "clock" && this.distance === "num_date") this.drawRegression();
@@ -263,7 +264,7 @@ export const change = function change({
const elemsToUpdate = new Set(); /* what needs updating? E.g. ".branch", ".tip" etc */
const nodePropsToModify = {}; /* which properties (keys) on the nodes should be updated (before the SVG) */
const svgPropsToUpdate = new Set(); /* which SVG properties shall be changed. E.g. "fill", "stroke" */
let useModifySVGInStages = false; /* use modifySVGInStages rather than modifySVG. Not used often. */
const useModifySVGInStages = newLayout; /* use modifySVGInStages rather than modifySVG. Not used often. */

/* calculate dt */
const idealTransitionTime = 500;
@@ -285,7 +286,7 @@ export const change = function change({
if (changeVisibility) {
/* check that visibility is not undefined */
/* in the future we also change the branch visibility (after skeleton merge) */
elemsToUpdate.add(".tip");
elemsToUpdate.add(".tip").add(".tipLabel");
svgPropsToUpdate.add("visibility").add("cursor");
nodePropsToModify.visibility = visibility;
}
@@ -306,9 +307,6 @@ export const change = function change({
elemsToUpdate.add(".grid").add(".regression");
svgPropsToUpdate.add("cx").add("cy").add("d").add("opacity").add("visibility");
}
if (newLayout) {
useModifySVGInStages = true;
}

/* change the requested properties on the nodes */
updateNodesWithNewData(this.nodes, nodePropsToModify);
@@ -1,4 +1,5 @@
import { timerFlush } from "d3-timer";
import { NODE_VISIBLE } from "../../../util/globals";

export const updateTipLabels = function updateTipLabels(dt) {
if ("tipLabels" in this.groups) {
@@ -35,7 +36,7 @@ export const updateTipLabels = function updateTipLabels(dt) {
.text((d) => tLFunc(d))
.attr("class", "tipLabel")
.style("font-size", fontSize.toString()+"px")
.style('visibility', 'visible');
.style('visibility', (d) => d.visibility === NODE_VISIBLE ? "visible" : "hidden");
}, dt);
}
};

0 comments on commit c9ed89c

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