Skip to content

Commit

Permalink
[tree] Don't allow tiny x-axis domains
Browse files Browse the repository at this point in the history
Don't allow tiny x-axis domains -- e.g. if zoomed into a polytomy where the divergence values are all tiny, then we don't want to display the tree topology.
The threshold for tiny is set here arbitrarily at 1E-8, however this will become problematic if we get eukaryotic genomes in nextstrain.
  • Loading branch information
jameshadfield committed Feb 26, 2020
1 parent eb53a25 commit 0446278
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/tree/phyloTree/layouts.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,20 @@ export const mapToScreen = function mapToScreen() {
maxY += delta;
}

/* Don't allow tiny x-axis domains -- e.g. if zoomed into a polytomy where the
divergence values are all tiny, then we don't want to display the tree topology */
const minimumXAxisSpan = 1E-8;
let spanX = maxX-minX;
if (spanX < minimumXAxisSpan) {
maxX = minimumXAxisSpan - minX;
spanX = minimumXAxisSpan;
}

/* set the domain of the x & y scales */
if (this.layout === "radial" || this.layout === "unrooted") {
// handle "radial and unrooted differently since they need to be square
// since branch length move in x and y direction
// TODO: should be tied to svg dimensions
const spanX = maxX-minX;
const spanY = maxY-minY;
const maxSpan = max([spanY, spanX]);
const ySlack = (spanX>spanY) ? (spanX-spanY)*0.5 : 0.0;
Expand Down

0 comments on commit 0446278

Please sign in to comment.