mbostock/d3 — Issue #472: d3.nest.distinct()
Author: mbostock
Created: 2012-01-27 02:46:41+00:00
State: open
Labels: req

It'd be nice to have a version of d3.nest for computing the number of distinct keys. Currently, you can do something like this:

```js
var m = d3.nest().key(function(d) { return d.foo; }).entries(objects).length;
```

However, it would be faster to just compute the distinct count than to populate all the entries. That might look like this:

```js
var m = d3.nest().key(function(d) { return d.foo; }).distinct(objects);
```

Alternatively, this could be provided as a `d3.distinct(array[, f])` method. It's kind of nice that you can get the same functionality out of a nest operator, though. However, it's a bit weird since the nest operator allows multiple keys; do you want the number of distinct values for all keys? Or just the first key? Probably across all keys.