veg / phylotree.js

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

Assign Attributes Function in Phylotree.js #411

Open santule opened 2 years ago

santule commented 2 years ago

Hello,

I tried using the assignAttributes function but it does not work as there is problem with the node name match in the phylotree.js code.

function assignAttributes(attributes) { //return nodes; // add annotations to each matching node ___namespace.each(this.nodes, function(d) { if (___namespace.indexOf(___namespace.keys(attributes), d.name) >= 0) { d["annotations"] = attributes[d.name]; } }); }

Based on my limited knowledge, if the d.name in the above code is changed to d.data.name as the node structure has name inside the data element it would work. Similarly for the d["annotations"], should now be d.data["annotations"]. I tested this by writing the same code in my script but using the d.data.name instead.

Regards, Sanjana

spond commented 2 years ago

Dear @santule,

Yes, you are correct. During the development of v.1.0 of phylotree.js not all of the features from the v.0.x version were properly migrated. This seems to be the case here. I am going to implement a fix and push an updated version (there were a few other fixes) in the next day or two.

Thanks!

Best., Sergei

spond commented 2 years ago

Resolved via https://github.com/veg/phylotree.js/commit/b5d193f2331aa262c69c7a48a821d044d35ffef1