score:9

Accepted answer

First you have to change the y domain to accept negative values:

y.domain([d3.min(data,function(d){return d.count}), d3.max(data, function(d) { return d.count; })]);

Then you have to play with the y and height attributes of bars to make sure that the boxes are located at the correct place:

.attr("y", function(d) { return y(Math.max(0, d.count)); })
.attr("height", function(d) { return Math.abs(y(d.count) - y(0)); })

Here is a working example (used in another answer): http://jsfiddle.net/chrisJamesC/tNdJj/4/


Related Query

More Query from same tag