veg / phylotree.js

Interactive viewer of phylogenetic trees
http://phylotree.hyphy.org
MIT License
168 stars 72 forks source link

Filter all branches with button instead of using brush #407

Open Sombiri opened 2 years ago

Sombiri commented 2 years ago

Hello there,

I just started using phylotree js. However, alongside the tree-selection using 'brush' features. I want to be able to make the same selection using a click-on button to select all branches (i.e on clicking the select all button, I should select all branches with the dotted lines as shown in the pics).

Screenshot 2022-02-25 at 10 34 38

(achieved the selection in the above picture by using the brush feature)

Currently, when I make the selection, it selects the branches with the bold lines using the implementation from html file. Below is the code.

Screenshot 2022-02-25 at 10 55 49

$(".select-unselect-mode").on ("change", function (e) { if ($(this).is(':checked')) { if ($(this).data ("mode") == "select") { console.log('i am working') tree.modify_selection (function (d) { return true;}); } else { console.log('i am working 2') tree.modify_selection (function (d) { return false;}); } } });

I will appreciate any help on how to make the selection with the dotted lines using the button instead of the brush features.

spond commented 2 years ago

Dear @Sombiri,

Sorry for the delay responding.

You want to call something like


//select all
rendered_tree.modifySelection (_.map (rendered_tree.links.filter(rendered_tree.edgeVisible), (e)=>e.target),"tag", true, false, "true");

//unselect all
rendered_tree.modifySelection (_.map (rendered_tree.links.filter(rendered_tree.edgeVisible), (e)=>e.target),"tag", true, false, "false");

Best, Sergei