I'm trying to have a bar graph in my program update in a .change function, but I'm not quite sure on how to go with making that happen. I already have a line object changing, which was accomplished by changing the attribute. But the problem that I'm having is that I don't know how to go about updating the rectangles in a bar graph to reflect the changes. Here's the relevant code with my attempt:
//updates when slider changes
$("#myRange").change(function () {
slider = $("#myRange").val();
updateXs();
updateLineData();
displayVals();
d3.select(".myLine").transition()
.attr("d", lineFunc(lineData));
d3.select(".myBars")
.attr("y", function (d) {
return d.value - d.y;
});
});
And here's the full code: http://jsfiddle.net/tqj5maza/15/