function deploy (div) { // toggle for branch lengths var sel = d3.select(div) .append("select") .on ("change", function () { tree_vis.layout().scale(this.value === "use_branch_lengths"); tree_vis.update(); }) sel .append("option") .attr("value", "use_branch_lengths") .text("Use branch lengths"); sel .append("option") .attr("value", "ignore_branch_lengths") .text("Ignore branch lengths"); var tree_vis = tnt.tree() .data (tnt.tree.parse_newick(newick)) .layout (tnt.tree.layout.vertical() .width(650) ) .label (tnt.tree.label.text() .height(20) ); tree_vis(div); } // The tree to plot var newick = "(((((((((Homo_sapiens:0.0067,Pan_troglodytes:0.006667):0.00225,Pongo_abelii:0.018318):0.00717,Nomascus_leucogenys:0.025488):0.00717,(Macaca_mulatta:0.007853,Papio_hamadryas:0.007637):0.029618):0.021965,Callithrix_jacchus:0.066131):0.05759,Tarsius_syrichta:0.137823):0.011062,(Microcebus_murinus:0.092749,Otolemur_garnettii:0.129725):0.035463):0.015494,Tupaia_belangeri:0.186203):0.004937,(((((Mus_musculus:0.084509,Rattus_norvegicus:0.091589):0.197773,Dipodomys_ordii:0.211609):0.022992,Cavia_porcellus:0.225629):0.01015,Ictidomys_tridecemlineatus:0.148468):0.025746,(Oryctolagus_cuniculus:0.114227,Ochotona_princeps:0.201069):0.101463):0.015313);";