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

Keep sources of the root of the zoomed-subtree in sync. Closes #1139 #1156

Merged
merged 1 commit into from
Jun 9, 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
4 changes: 2 additions & 2 deletions src/components/tree/phyloTree/phyloTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as confidence from "./confidence";
import * as labels from "./labels";

/* phylogenetic tree drawing function - the actual tree is rendered by the render prototype */
const PhyloTree = function PhyloTree(reduxNodes, id) {
const PhyloTree = function PhyloTree(reduxNodes, id, idxOfInViewRootNode) {
this.grid = false;
this.attributes = ['r', 'cx', 'cy', 'id', 'class', 'd'];
this.params = createDefaultParams();
Expand Down Expand Up @@ -40,7 +40,7 @@ const PhyloTree = function PhyloTree(reduxNodes, id) {
setYValues(this.nodes);
this.xScale = scaleLinear();
this.yScale = scaleLinear();
this.zoomNode = this.nodes[0];
this.zoomNode = this.nodes[idxOfInViewRootNode];
this.strainToNode = {};
this.nodes.forEach((phylonode) => {this.strainToNode[phylonode.n.name] = phylonode;});
/* debounced functions (AFAIK you can't define these as normal prototypes as they need "this") */
Expand Down
4 changes: 2 additions & 2 deletions src/components/tree/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Tree extends React.Component {
setUpAndRenderTreeToo(props, newState) {
/* this.setState(newState) will be run sometime after this returns */
/* modifies newState in place */
newState.treeToo = new PhyloTree(props.treeToo.nodes, "RIGHT");
newState.treeToo = new PhyloTree(props.treeToo.nodes, "RIGHT", props.treeToo.idxOfInViewRootNode);
if (attemptUntangle) {
untangleTreeToo(newState.tree, newState.treeToo);
}
Expand All @@ -53,7 +53,7 @@ class Tree extends React.Component {
componentDidMount() {
if (this.props.tree.loaded) {
const newState = {};
newState.tree = new PhyloTree(this.props.tree.nodes, "LEFT");
newState.tree = new PhyloTree(this.props.tree.nodes, "LEFT", this.props.tree.idxOfInViewRootNode);
renderTree(this, true, newState.tree, this.props);
if (this.props.showTreeToo) {
this.setUpAndRenderTreeToo(this.props, newState); /* modifies newState in place */
Expand Down