First I would like to find out if anyone knows of a D3 example showing grouped bar charts with error bars? The closest things I have found are:
http://tenxer.github.io/xcharts/examples/ (Example Custom Vis Type: Error Bars) http://bl.ocks.org/chrisbrich/5044999 (error bars for points)
I have a working example of a grouped bar chart and I would like to add an error bar to each bar in the graph showing the MOE. What steps would I need to take to accomplish this? How would I calculate the position of the line? This is what I think needs to be done, please help me fill in the steps I need to take.
Create a SVG line
Calculate the ymin and ymax of the line by taking d3.max of d.value + the MOE and d3.max of d.value - MOE
Append
This doesn't work but is it on the right track?
var line = d3.svg.line()
.x(function(d) {return x(d.state); })
.y0(function(d) {return y(d.value - d.moe); })
.y1(function(d) {return y(d.value + d.moe); })
.interpolate("linear");
var errorBarSVG = d3.select("body").append("svg")
var errorBar = errorBarSVG.append("path")
.attr("d", line(data))
.attr("stroke", "red")
.attr("stroke-width", 1.5);