Skip to content

Commit

Permalink
Merge branch 'pr-1043'
Browse files Browse the repository at this point in the history
* pr-1043:
  Improve tree label font sizes
  #915: using triple equals
  #915: determine whether tip label should be shown based on count of fully visible nodes, not all in-view nodes
  • Loading branch information
jameshadfield committed Apr 8, 2020
2 parents 22fd0b2 + 44c22a1 commit fc69b8f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/components/tree/phyloTree/labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,28 @@ export const updateTipLabels = function updateTipLabels(dt) {
const tLFunc = this.callbacks.tipLabel;
const xPad = this.params.tipLabelPadX;
const yPad = this.params.tipLabelPadY;
const inViewTerminalNodes = this.nodes

const inViewTips = 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) {

const inViewVisibleTips = inViewTips.filter((d) => d.visibility === NODE_VISIBLE);

/* We show tip labels by checking the number of "inView & visible" tips */
if (inViewVisibleTips.length < this.params.tipLabelBreakL1) {

/* We calculate font size based on the total number of in view tips (both visible & non-visible) */
let fontSize = this.params.tipLabelFontSizeL1;
if (inViewTerminalNodes.length < this.params.tipLabelBreakL2) {
fontSize = this.params.tipLabelFontSizeL2;
}
if (inViewTerminalNodes.length < this.params.tipLabelBreakL3) {
if (inViewTips.length < this.params.tipLabelBreakL3) {
fontSize = this.params.tipLabelFontSizeL3;
} else if (inViewTips.length < this.params.tipLabelBreakL2) {
fontSize = this.params.tipLabelFontSizeL2;
}

window.setTimeout(() => {
this.groups.tipLabels
.selectAll('.tipLabel')
.data(inViewTerminalNodes)
.data(inViewVisibleTips)
.enter()
.append("text")
.attr("x", (d) => d.xTip + xPad)
Expand Down

0 comments on commit fc69b8f

Please sign in to comment.