var y = d3.scale.linear()
.domain([minValue, maxValue])
.range([height, 0]);
When you compute the "y" attribute of a rect, you can use the y-scale
directly. For the height attribute, you'll have to use height - y(d),
but that seems reasonable to me. When you use an inverted range this
way, you can also use the scale with a d3.svg.axis, and it will do the
right thing.
Mike
Are there any helpers within d3 to make this job easier? Such as an
inverted scale or perhaps I can draw svg shapes by specifying their
bottom + height, rather than y-position + height?
var y = d3.scale.linear().domain([0,100]).range([0,300]);console.log( y(0), y(50), y(100) );//-> [0, 150, 300]var y2 = d3.scale.linear().domain([0,100]).range([450,150]);console.log( y2(0), y2(50), y2(100) );//-> [450, 300, 150]