legumeinfo / web-components

A collection of Web Components for interacting with and visualizing biological data.
https://legumeinfo.github.io/web-components/
Apache License 2.0
5 stars 3 forks source link

Implement phylotree #144

Open alancleary opened 1 year ago

alancleary commented 1 year ago

This is basically a second attempt at #10. @rispop is going to implement a phylotree component in an iterative manner. See the list below for steps and details:

rispop commented 1 year ago

Forked the web-components repo --> https://github.com/rispop/web-components

rispop commented 1 year ago

Just added the lis-phylotree.ts file --> https://github.com/rispop/web-components/blob/main/src/lis-phylotree.ts. Would this be the correct format and have the correct dependencies?

alancleary commented 1 year ago

Just added the lis-phylotree.ts file --> https://github.com/rispop/web-components/blob/main/src/lis-phylotree.ts. Would this be the correct format and have the correct dependencies?

Good progress @rispop. I've emailed you about the format and whatnot.

rispop commented 1 year ago

Created a test in /dev directory and have almost completed the component. One error regarding data still remains while compiling. Also fixed src/controllers/lis-cancel-promise-controller.ts as you said in email.

alancleary commented 1 year ago

Created a test in /dev directory and have almost completed the component. One error regarding data still remains while compiling. Also fixed src/controllers/lis-cancel-promise-controller.ts as you said in email.

Sounds good. Let me know when you're ready for me try out your code.

rispop commented 1 year ago

Finished component and test. The component prompts the user to enter a newick tree and then displays it.

alancleary commented 1 year ago

Great! I've added more items to the task list.

rispop commented 1 year ago

Declared and exported Phylotree type

rispop commented 1 year ago

Added the private _data state to LisPhylotree class

rispop commented 1 year ago

Replaced input with tree and new type, implemented setter with conditions if tree is a string or a Phylotree.

rispop commented 1 year ago

Also changed the drawing tree code to use _data, but for some reason, the tree doesn't display properly afterward.

rispop commented 1 year ago

Fixed the tree display error by modifying the setter for the tree. Also fixed a couple of compile errors.

rispop commented 1 year ago

Added 2nd <lis-phylotree> component which uses the Phylotree object.

rispop commented 1 year ago

Added optional color attribute

rispop commented 1 year ago

Updated tree drawing code to color the nodes based on their attributes and updated Phylotree object to include some nodes with colors. Also made the default color of the nodes gray. If any color attribute is an empty string or null, the color will be gray.

alancleary commented 1 year ago

Updated tree drawing code to color the nodes based on their attributes and updated Phylotree object to include some nodes with colors. Also made the default color of the nodes gray. If any color attribute is an empty string or null, the color will be gray.

Mind making the default color white? That's what the Funnotate implementation does and we want to replicate that.

rispop commented 1 year ago

Yup, done.

rispop commented 1 year ago

Adjusted width in drawing code to use screen.availWidth rather than a set value.

rispop commented 1 year ago

Nevermind it looks like window.innerWidth is better to use as it makes the tree viewable in a windowed browser tab as well.

svengato commented 1 year ago

The Funnotate implementation is at https://github.com/legumeinfo/Funnotate/blob/main/static/js/phylogram.js

rispop commented 1 year ago

The layout property has been added and is used in the tree drawing code.

alancleary commented 1 year ago

The layout property has been added and is used in the tree drawing code.

Works great! Very cool that the tree automatically redraws if you change this property on an existing element.

rispop commented 1 year ago

Added scale property and used in .scale method

rispop commented 1 year ago

Clears the previous tree whenever it is redrawn using this.innerHTML = "";

rispop commented 1 year ago

Built query query GeneFamilies($page: Int, $pageSize: Int) { geneFamilies(page: $page, pageSize: $pageSize) { results { phylotree { newick } } } }

And variables { "pageSize": 1, "page": 1 }

Sorry the formating doesn't look right.

rispop commented 1 year ago

Updated /dev/lis-phylotree.html with query and displaying it in the Tree object.

rispop commented 1 year ago

Completed GraphQL query and made pull-request.