Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node default #486

Merged
merged 4 commits into from
Feb 18, 2021
Merged

Node default #486

merged 4 commits into from
Feb 18, 2021

Conversation

kwcantrell
Copy link
Collaborator

@kwcantrell kwcantrell commented Feb 16, 2021

This PR address #479. I added new node circle option "Show internal node circles" and made it the default option.

@kwcantrell kwcantrell linked an issue Feb 16, 2021 that may be closed by this pull request
Copy link
Member

@ElDeveloper ElDeveloper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kwcantrell, thanks so much. This looks good but I think we can reduce the number of circles drawn. Instead of drawing all internal node circles, just show node circles for internal nodes that have only 1 descendant. This will help avoid issues where a branch looks "long" but is really a series of nodes one after the other. It will also reduce overhead by default drawing even fewer nodes.

See the example I posted here you'll see there's a few branches with a lot of internal nodes that have only one descendant.

if (this.drawNodeCircles === 0) {
comp = function (node) {
return (
visible(node) && !tree.isleaf(tree.postorderselect(node))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pseudo-code but I think this would help further reduce the number of circles drawn on screen:

Suggested change
visible(node) && !tree.isleaf(tree.postorderselect(node))
visible(node) && !tree.isleaf(tree.postorderselect(node)) && tree.children(...).length === 1```

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a forth option (show internal nodes with one descendant) and made it the default. Here is an example.
Screenshot from 2021-02-17 15-54-45

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent, that looks exactly like what we need! Just for completeness how does that clade in the tree look when you show all node circles?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the clade. The node highlighted in the above clade is located on the bottom branch.

Screenshot from 2021-02-17 17-54-22

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, this looks great! Whenever you get a chance feel free to push the code and I'll be happy to re-review the code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad. I had commited it but forgot to push it.

Copy link
Member

@ElDeveloper ElDeveloper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The result is perfect! I tried it out in a tree and it looks great. Just a couple of comments regarding the tests and comments.

@@ -105,6 +107,43 @@ require([
deepEqual(empressUnrootCoords, unrootCoords);
});

test("Test getNodeCoords only internal node circles", function () {
// have empress draw only internal node circles
this.empress.drawNodeCircles = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for the case where this value is 3 i.e. the default?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test added

* each node's position.
* @param{String} showTreeNodes 0 - draw only internal nodes circles,
* 1 - draw all node circles,
* 2 - hide all node circles
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the missing value here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added missing value

return scope.getNodeInfo(node, "visible");
};
var comp;
if (this.drawNodeCircles === 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment before each if describing what case this is?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comment to each if case

@kwcantrell
Copy link
Collaborator Author

thanks @ElDeveloper! The PR should be good to merge in now.

Copy link
Member

@ElDeveloper ElDeveloper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks so much @kwcantrell!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show node circles by default
2 participants