Skip to content
This repository has been archived by the owner on Nov 11, 2018. It is now read-only.

Add nest.count or nest.visit? #4

Closed
mbostock opened this issue May 14, 2016 · 1 comment
Closed

Add nest.count or nest.visit? #4

mbostock opened this issue May 14, 2016 · 1 comment
Assignees

Comments

@mbostock
Copy link
Member

Copied from d3/d3-array#10:

Related d3/d3#1091, it might be nice if there were an easy way to count the number of elements matched at each level of the hierarchy. Yes, things like the cluster layout do that for you already, but it’d be nice to do that with a simple nest operator, too.

This feels slightly related to the nest.rollup method, too. Like, instead of replacing the set of nested values with the return value of the rollup function, I just want to decorate the object (say by assigning a count value). But another big difference is that rollup only operates on arrays of siblings, and nest.count should be a recursive operation on the entire tree.

So… it’s almost like you want tree visit methods on the returned nest object. Which makes me wonder if there should be a nest.tree method instead of nest.map, and then have some useful methods on the returned tree instance.

@mbostock
Copy link
Member Author

The current solution is to pass the result of nest.entries to d3.hierarchy.

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

No branches or pull requests

1 participant