reversed Y-axis D3

Maybe this will help.

http://jsfiddle.net/S575k/4/

A few notes:

  1. I reversed your y domain range from .range([0, h-margin]); to .range([h-margin, 0]); This will fix the issue of the y-axis marks going in the wrong direction because the browser consider’s the origin (0,0) point to the the upper-left corner, and not the bottom-left corner like in math.

  2. Because of this reversal I had to tweak your .attr('height') and .attr('y').

  3. A nice way to find the height of bar in a bar chart is to realize that the yscale(0) will give you the pixel-position of the bottom of the barchart. You can then do yscale(value) - yscale(0) to get the pixel-height of your bars.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)