Sounds like you want to use JavaScript's built-in .map() function for
arrays. For example:
var x = d3.scale.ordinal()
.domain(array.map(function(d) { return d.lang; }))
.rangeBands([0, 200]);
Note that map is a fairly recent addition to the standard, so you may
need to add a workaround for older browsers e.g. see:
<https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/map>
for an example of this.
Hope that helps,
--
Jason Davies, http://www.jasondavies.com/
You may want to use D3's built-in min and max functions, which allow
you to specify an accessor. This is much like using JavaScript's
array.map method, but it's a bit more direct if you just want to
compute the extent of a set of values. For example, to use the domain
[0, max], where *max* is the maximum post count, you might say:
var y = d3.scale.linear()
.domain([0, d3.max(objects, function(d) { return d.post_count; })])
.range([0, 854400]);
In the case of `lang`, which is an ordinal variable, it makes the most
sense to use map. Jason's example has that covered!
Mike
These methods are completely different. It's named `map` because it
returns a map (an associated array from keys to values). It's not a
mapping operation on an array.
The `nest` operator is designed to group tabular data (an array of
objects, each with different attributes—equivalently, rows & colums)
into a hierarchical structure. For example, you might have a set of
samples for time-series data, where each sample is a post count for a
particular time, labeled with an associated language. If you nest
these samples by language, then you get an array of arrays of samples.
For example, this two-dimensional array can then be used with the
d3.layout.stack operator, mapping each language to a layer in a
streamgraph.
Mike