I am trying to create a Bar chart using D3.js. The condition is that Bar should have fixed width and padding between the bars and it should be plot at center of grid lines.
Tooltip should appear on click with a vertical line
I am able to create the grid lines with plotted bar, somehow rx,ry is rounding from both sides. How can i acheive the same sort of result.
var rectCluster = svg.selectAll(".bar")
.data(data);
rectCluster
.enter().append("rect")
.attr("class", function(d) {
return "bar";
})
.attr(attrs)
.attr({ry : (20), rx : 20 })
.attr("x", function(d) { return x(d.text); })
.attr("y", function(d) {
return height;
})
.style("fill", function(d) {
return color(d.text);
})
.attr("width", x.rangeBand())
.attr("height", 0)
.transition()
.duration(animationDelay)
.delay(function(d, i) {
return i * animationDelay;
})
.attr("y", function(d) { return y(d.score); })
.attr("height", function(d) { return height - y(d.score) });
var attrs = {
width: function(d, i){
return o.rangeBand();
},
height: function(d, i){
return yScale(d);
},
fill: "#384252",
x: function(d, i){
return xScale(i);
},
y: function(d, i){
return height - yScale(d) - margin.bottom;
}
};