Skip to content

Commit

Permalink
vaccine positions correct for all layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshadfield committed Feb 13, 2018
1 parent 46d48e5 commit 91fb4d3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/components/tree/phyloTree/generalUpdates.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const updateGeometry = function updateGeometry(dt) {
this.svg.selectAll(".vaccineCross")
.transition().duration(dt)
.attr("d", (dd) => dd.vaccineCross);
if (this.layout === "rect") { /* we only have dotted lines on rect layout so far */
if (this.distance === "num_date") {
this.svg.selectAll(".vaccineDottedLine")
.transition().duration(dt)
.style("opacity", 1)
Expand Down
20 changes: 16 additions & 4 deletions src/components/tree/phyloTree/layouts.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const rectangularLayout = function rectangularLayout() {
if (this.vaccines) {
this.vaccines.forEach((d) => {
d.xCross = d.crossDepth;
d.yCross = d.y;
});
}
};
Expand All @@ -65,8 +66,11 @@ export const timeVsRootToTip = function timeVsRootToTip() {
d.px = d.n.parent.attr["num_date"];
d.py = d.n.parent.attr["div"];
});
if (this.vaccines) { /* where the tips should be */
this.vaccines.forEach((d) => {d.xCross = d.x;});
if (this.vaccines) { /* overlay vaccine cross on tip */
this.vaccines.forEach((d) => {
d.xCross = d.x;
d.yCross = d.y;
});
}
const nTips = this.numberOfTips;
// REGRESSION WITH FREE INTERCEPT
Expand Down Expand Up @@ -145,7 +149,9 @@ export const unrootedLayout = function unrootedLayout() {
}
if (this.vaccines) {
this.vaccines.forEach((d) => {
d.xCross = d.x;
const bL = d.crossDepth - d.depth;
d.xCross = d.px + bL * Math.cos(d.tau + d.w * 0.5);
d.yCross = d.py + bL * Math.sin(d.tau + d.w * 0.5);
});
}
};
Expand Down Expand Up @@ -175,7 +181,13 @@ export const radialLayout = function radialLayout() {
});
if (this.vaccines) {
this.vaccines.forEach((d) => {
d.xCross = (d.crossDepth - offset) * Math.sin(d.angle);
if (this.distance === "div") {
d.xCross = d.x;
d.yCross = d.y;
} else {
d.xCross = (d.crossDepth - offset) * Math.sin(d.angle);
d.yCross = (d.crossDepth - offset) * Math.cos(d.angle);
}
});
}
};
Expand Down
7 changes: 4 additions & 3 deletions src/components/tree/phyloTree/zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,10 @@ export const mapToScreen = function mapToScreen() {
if (this.vaccines) {
this.vaccines.forEach((d) => {
const n = 5; /* half the number of pixels that the cross will take up */
d.xTipCross = this.xScale(d.xCross); /* x position of the center of the cross */
d.vaccineCross = ` M ${d.xTipCross-n},${d.yTip-n} L ${d.xTipCross+n},${d.yTip+n} M ${d.xTipCross-n},${d.yTip+n} L ${d.xTipCross+n},${d.yTip-n}`;
d.vaccineLine = ` M ${d.xTip},${d.yTip} L ${d.xTipCross},${d.yTip}`;
const xTipCross = this.xScale(d.xCross); /* x position of the center of the cross */
const yTipCross = this.yScale(d.yCross); /* x position of the center of the cross */
d.vaccineCross = ` M ${xTipCross-n},${yTipCross-n} L ${xTipCross+n},${yTipCross+n} M ${xTipCross-n},${yTipCross+n} L ${xTipCross+n},${yTipCross-n}`;
d.vaccineLine = ` M ${d.xTip},${d.yTip} L ${xTipCross},${yTipCross}`;
});
}
if (this.params.confidence && this.layout==="rect") {
Expand Down

0 comments on commit 91fb4d3

Please sign in to comment.