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

Example Code under node.sort(compare) #48

Closed
tomwanzek opened this issue Jun 28, 2016 · 4 comments
Closed

Example Code under node.sort(compare) #48

tomwanzek opened this issue Jun 28, 2016 · 4 comments

Comments

@tomwanzek
Copy link

The first example under the node.sort(compare) contains the code snippet:

.sort(function(a, b) { return b.value - a.value; });

This should probably read:

.sort(function(a, b) { return b.data.value - a.data.value; });

as the sort function passes in nodes.

@mbostock
Copy link
Member

The code is correct as-is; it is sorting by the aggregate values computed and set by node.sum on the previous line, not the data.value.

@tomwanzek
Copy link
Author

Apologies, skipped over the implication of the sum(...) call in the prior line too quickly 😞 .

On a related aside then, maybe it would be valuable, pardon the pun, to add the value property as an optional node property to passage starting with:

The returned node and each descendant has the following properties:

e.g.:

  • node.value - aggregated numeric value, if any, as calculated by node.sum(value)

Just an idea from someone who seems to have read too fast. Your call.

@mbostock
Copy link
Member

That’s a nice idea. I’ll make that change unless you beat me to it! Thanks.
On Mon, Jun 27, 2016 at 7:33 PM Tom Wanzek notifications@github.com wrote:

Apologies, skipped over the implication of the sum(...) call in the prior
line too quickly 😞 .

On a related aside then, maybe it would be valuable, pardon the pun, to
add the value property as an optional node property to passage starting
with:

The returned node and each descendant has the following properties:

e.g.:

Just an idea from someone who seems to have read too fast. Your call.


You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub
#48 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AAOEjQyrINFpTOZjwI-7QVGElqIXSY__ks5qQIfkgaJpZM4I_qa9
.

mbostock added a commit that referenced this issue Jun 28, 2016
@tomwanzek
Copy link
Author

Clearly you beat me to it... 😄

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

No branches or pull requests

2 participants