Moved to https://beta.observablehq.com/@mbostock/d3-histogram.
-
-
Save mbostock/3048450 to your computer and use it in GitHub Desktop.
Histogram
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
redirect: https://beta.observablehq.com/@mbostock/d3-histogram |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@hirokai made a very good point about the width computation. This version obviously works, but it doesn't generalize to cases where the x-domain doesn't start at 0. It caused me to waste a little time when I first tried to apply this example to my situation. Width should be instead x(data[0].dx) - x(0) - 1 (assuming we still want gaps between the bins).
https://gist.github.com/aww/bf245ae8d58afcebd930