Skip to content

Instantly share code, notes, and snippets.

Forked from mbostock/.block
Last active May 14, 2018 11:02
  • Star 5 You must be signed in to star a gist
  • Fork 16 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Copy link

hirokai commented Jan 9, 2015

In line 70:

    .attr("width", x(data[0].dx) - 1)

The code above gives negative width for some data I made.

Should x(data[0].dx) - 1 be x(data[0].dx) - x(0) actually?

Copy link

wangxuq commented Aug 20, 2015

when I use these code to build the chart,the d3.scale.liner().domain([0,1]) cannot work, this is to say the line range cannot appear.why?
as bellow:

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).

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