Here is what I have:
http://jsfiddle.net/bozdoz/Q6A3L/

Code for 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, eg, 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 made the red, yellow, green background stripes a fixed height.
When you use the slider or, more importantly, when the graph will be regenerated (what will happen to 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 delete all the chart data, except for the red (vertical) bars, the green bar (horizontal) will be slightly higher than 40 M. This is because the position / height of the background bars is not restored, while the position / height of the graph data is regenerated with javascript rickshaw.
How can I put this data into a rickshaw chart so that it is regenerated?