Skip to content

Instantly share code, notes, and snippets.

@mbostock
Forked from mbostock/.block
Last active May 14, 2018 11:02
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 16 You must be signed in to fork a gist
  • Save mbostock/3048450 to your computer and use it in GitHub Desktop.
Save mbostock/3048450 to your computer and use it in GitHub Desktop.
Histogram
redirect: https://beta.observablehq.com/@mbostock/d3-histogram
@aww
Copy link

aww commented Oct 10, 2015

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment