Commit 92fc9800 authored by Ludo Cottret's avatar Ludo Cottret

Use phylocanvas instead of tnt.tree

To have unrooted trees
parent 8c9849e4
......@@ -124,83 +124,16 @@ Ext
var newick = xhr.responseText;
console.log("newick");
console.log(newick);
var width = 760;
var scale = true;
var menu_pane = d3.select(treeDiv)
.append("hr")
.append("div")
.append("span")
.text("Tree layout: ");
var sel = menu_pane
.append("select")
.on("change", function(d) {
var layout = tnt.tree.layout[this.value]().width(width).scale(scale);
tree.layout(layout);
tree.update();
});
sel
.append("option")
.attr("value", "vertical")
.attr("selected", 1)
.text("vertical");
sel
.append("option")
.attr("value", "radial")
.text("radial");
var data = tnt.tree.parse_newick(newick);
// Show different node shapes for collapsed/non-collapsed nodes
var node_size = 5;
var node_fill = "lightgrey";
var node_stroke = "black";
var expanded_node = tnt.tree.node_display.circle()
.size(node_size)
.fill(node_fill)
.stroke(node_stroke);
var collapsed_node = tnt.tree.node_display.triangle()
.size(node_size)
.fill(node_fill)
.stroke(node_stroke);
var node_display = tnt.tree.node_display()
.size(24)
.display(function(node) {
if (node.is_collapsed()) {
collapsed_node.display().call(this, node);
} else {
expanded_node.display().call(this, node);
}
});
var tree = tnt.tree()
.node_display(node_display)
.data(data)
.duration(500)
.layout(tnt.tree.layout.vertical()
.scale(scale)
.width(width)
);
tree.on("click", function(node) {
node.toggle();
tree.update();
});
// The tree renders at this point
tree(treeDiv);
(function (Phylocanvas) {
var tree = Phylocanvas.createTree(treeDiv);
tree.load(newick);
var h = document.getElementsByClassName("phylocanvas-history")[0];
h.remove();
})(window.Phylocanvas);
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment