Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tree] Don't allow tiny x-axis domains #909

Merged
merged 2 commits into from
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts/get-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ data_files=(
"flu_seasonal_yam_na_3y.json" "flu_seasonal_yam_na_3y_tip-frequencies.json" \
"flu_seasonal_yam_na_6y.json" "flu_seasonal_yam_na_6y_tip-frequencies.json" \
"flu_seasonal_yam_na_12y.json" "flu_seasonal_yam_na_12y_tip-frequencies.json" \
"tb_global_meta.json" "tb_global_tree.json" \
"enterovirus_d68_genome_meta.json" "enterovirus_d68_genome_tree.json" \
"enterovirus_d68_vp1_meta.json" "enterovirus_d68_vp1_tree.json" \
"ncov.json" "ncov_2020-01-25.json" "ncov_2020-01-23.json" \
Expand Down
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