Skip to content

cap the default number of bins at 200 #421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 2, 2021
Merged

cap the default number of bins at 200 #421

merged 6 commits into from
Aug 2, 2021

Conversation

Fil
Copy link
Contributor

@Fil Fil commented May 29, 2021

(see #417)

(200 is working for almost any chart size; 100 would be a fine choice too)

@Fil Fil requested review from mbostock and mkfreeman May 29, 2021 15:54
@Fil Fil requested a review from mbostock May 29, 2021 16:45
if (thresholds === undefined) {
return (...args) => Math.min(200, thresholdScott(...args));
}
if (thresholds === undefined) return thresholdDefault;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can now be a default argument again.

Copy link
Member

@mbostock mbostock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to the facet option #450, if we have a default implementation strategy for an option, there should be a way to specify it explicitly rather than requiring you to pass undefined. So, let’s call the min(200, scott) strategy auto, so that you can specify it explicitly?

I was separately wondering if the max of 200 should apply to any of the other threshold strategies, and if so, should it be a separate option, say thresholdsMax which defaults to 200? Or are we doing this only because Scott’s normal reference rule is prone to too many bins? It’s nice, though not obvious, that using scott instead of auto will disable the cap.

Lastly, I was wondering if the 200 should be dependent on the dimensions of the chart. That might suggest having a separate thresholdsMax option, too, which perhaps could somehow default to a value derived from the chart dimensions. Though these dimensions are not currently made available to transforms so it’d require further plumbing to make a smart default, and in any case, I think 200 is almost certainly fine for now.

@Fil
Copy link
Contributor Author

Fil commented Aug 2, 2021

Rebased and made "auto" explicit. (I don't think we should make this value of 200 configurable or magical; we just want to avoid the dramatic explosion of Scott’s rule when the distribution is highly concentrated around an extremum.)

@mbostock mbostock merged commit 75f2ab2 into main Aug 2, 2021
@mbostock mbostock deleted the fil/bins-cap branch August 2, 2021 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants