-
Notifications
You must be signed in to change notification settings - Fork 31
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
Node default #486
Conversation
There was a problem hiding this 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)) |
There was a problem hiding this comment.
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:
visible(node) && !tree.isleaf(tree.postorderselect(node)) | |
visible(node) && !tree.isleaf(tree.postorderselect(node)) && tree.children(...).length === 1``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test added
empress/support_files/js/empress.js
Outdated
* each node's position. | ||
* @param{String} showTreeNodes 0 - draw only internal nodes circles, | ||
* 1 - draw all node circles, | ||
* 2 - hide all node circles |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
thanks @ElDeveloper! The PR should be good to merge in now. |
There was a problem hiding this 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!
This PR address #479. I added new node circle option "Show internal node circles" and made it the default option.