Here's what I have:
http://jsfiddle.net/bozdoz/Q6A3L/
Code for the background bars:
maxData = 80000000;
maxHeight = 250;
var yScale = d3.scale.linear().
domain([0, maxData]). // your data minimum and maximum
range([0, maxHeight]); // the pixels to map to, e.g., the height of the diagram.
var riskpoints = [62000000,48000000,30000000];
var rectDemo = d3.select("#chart").
append("svg:svg").
attr("width", 400).
attr("height", maxHeight).
attr('class','risk');
rectDemo.append("svg:rect").
attr("x",0).
attr("y", maxHeight - yScale(riskpoints[0])).
attr("height", yScale(riskpoints[0]) - yScale(riskpoints[1])).
attr("width", '100%').
attr("fill", "rgba(0,100,0,.3)");
rectDemo.append("svg:rect").
attr("x",0).
attr("y", maxHeight - yScale(riskpoints[1])).
attr("height", yScale(riskpoints[1]) - yScale(riskpoints[2])).
attr("width", '100%').
attr("fill", "rgba(100,100,0,.3)");
rectDemo.append("svg:rect").
attr("x",0).
attr("y", maxHeight - yScale(riskpoints[2])).
attr("height", yScale(riskpoints[2])).
attr("width", '100%').
attr("fill", "rgba(100,0,0,.3)");
This is exactly what I want, except that I have made the red, yellow, green background bars a fixed height.
When you use the slider, or, more importantly, when the graph is regenerated (which it will with the actual data), I want the background bars to adjust to the correct height.
For example, in the image, the green bar is somewhere between 300M and 200M. If you remove all the graph data except for the red (vertical) bars, the green bar (horizontal) is just above 40M. This is because the position/height of the background bars are not regenerated, whereas the position/height of the graph data are regenerated, via the rickshaw javascript.
How could I put this data into the rickshaw graph so that it is regenerated?