histogram.domain()

histogram.domain([domain])

If domain is specified, sets the domain accessor to the specified function or array and returns this histogram generator. If domain is not specified, returns the current domain accessor, which defaults to extent. The histogram domain is defined as an array [min, max], where min is the minimum observable value and max is the maximum observable value; both values are inclusive. Any value outside of this domain will be ignored when the histogram is generated.

For example, if you are using the the histogram in conjunction with a linear scale x, you might say:

var histogram = d3.histogram()
    .domain(x.domain())
    .thresholds(x.ticks(20));

You can then compute the bins from an array of numbers like so:

var bins = histogram(numbers);

Note that the domain accessor is invoked on the materialized array of values, not on the input data array.

doc_D3_Js
2016-11-24 10:27:51
Comments
Leave a Comment

Please login to continue.