Skip to content

Commit e0bd6e9

Browse files
committed
cap the default number of bins at 200 (see #417)
1 parent c862122 commit e0bd6e9

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ The **thresholds** option may be specified as a named method or a variety of oth
10311031
* a time interval (for temporal binning)
10321032
* a function that returns an array, count, or time interval
10331033

1034-
If the **thresholds** option is not specified, it defaults to *scott*. If a function, it is passed three arguments: the array of input values, the domain minimum, and the domain maximum. If a number, [d3.ticks](https://github.com/d3/d3-array/blob/master/README.md#ticks) or [d3.utcTicks](https://github.com/d3/d3-time/blob/master/README.md#ticks) is used to choose suitable nice thresholds.
1034+
If the **thresholds** option is not specified, it defaults to *scott*, capped at 200. If a function, it is passed three arguments: the array of input values, the domain minimum, and the domain maximum. If a number, [d3.ticks](https://github.com/d3/d3-array/blob/master/README.md#ticks) or [d3.utcTicks](https://github.com/d3/d3-time/blob/master/README.md#ticks) is used to choose suitable nice thresholds.
10351035

10361036
The bin transform supports grouping in addition to binning: you can subdivide bins by up to two additional ordinal or categorical dimensions (not including faceting). If any of **z**, **fill**, or **stroke** is a channel, the first of these channels will be used to subdivide bins. Similarly, Plot.binX will group on **y** if **y** is not an output channel, and Plot.binY will group on **x** if **x** is not an output channel. For example, for a stacked histogram:
10371037

src/transforms/bin.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,10 @@ function maybeBin(options) {
171171
return bin;
172172
}
173173

174-
function maybeThresholds(thresholds = thresholdScott) {
174+
function maybeThresholds(thresholds) {
175+
if (thresholds === undefined) {
176+
return (...args) => Math.min(200, thresholdScott(...args));
177+
}
175178
if (typeof thresholds === "string") {
176179
switch (thresholds.toLowerCase()) {
177180
case "freedman-diaconis": return thresholdFreedmanDiaconis;

0 commit comments

Comments
 (0)