From 76546d5a35a7fe781f9a52c17545d47e49e62a90 Mon Sep 17 00:00:00 2001 From: Kairsten Fay Date: Fri, 31 May 2019 16:53:28 -0700 Subject: [PATCH 1/3] Refactor declaration of useModifySVGInStages `useModifySVGInStages` is false unless `newLayout` is set to true. Thus, set `useModifySVGInStages = newLayout`. --- src/components/tree/phyloTree/change.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/tree/phyloTree/change.js b/src/components/tree/phyloTree/change.js index 59e169f4b..c0aa608a3 100644 --- a/src/components/tree/phyloTree/change.js +++ b/src/components/tree/phyloTree/change.js @@ -263,7 +263,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; @@ -306,9 +306,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); From f944011d7fa5ac11a178570eb1d06eaa98f8826b Mon Sep 17 00:00:00 2001 From: Kairsten Fay Date: Fri, 31 May 2019 16:59:31 -0700 Subject: [PATCH 2/3] Update tip labels on layout change Previously, `updateTipLabels()` was not being called when modifying the SVG after a layout change. --- src/components/tree/phyloTree/change.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/tree/phyloTree/change.js b/src/components/tree/phyloTree/change.js index c0aa608a3..1cfb862ef 100644 --- a/src/components/tree/phyloTree/change.js +++ b/src/components/tree/phyloTree/change.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(); From 57f762cae19e7f2f20ca31a564fa3eb99ffbb989 Mon Sep 17 00:00:00 2001 From: Kairsten Fay Date: Mon, 3 Jun 2019 17:13:49 -0700 Subject: [PATCH 3/3] Update tip label visibility on date range change Previously, tip labels would not update in visibility unless the SVG or layout was modified, or the page was reloaded. Now tip labels reflect date range changes. --- src/components/tree/phyloTree/change.js | 2 +- src/components/tree/phyloTree/labels.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/tree/phyloTree/change.js b/src/components/tree/phyloTree/change.js index 1cfb862ef..18bb216d1 100644 --- a/src/components/tree/phyloTree/change.js +++ b/src/components/tree/phyloTree/change.js @@ -286,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; } diff --git a/src/components/tree/phyloTree/labels.js b/src/components/tree/phyloTree/labels.js index 32ff196a0..91b92a745 100644 --- a/src/components/tree/phyloTree/labels.js +++ b/src/components/tree/phyloTree/labels.js @@ -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); } };