-
1.
I think this is a simple question but I'm not getting it. I have the following code for the x-axis of my Stacked bar chart, and I'm trying to access the x-value when the corresponding stacked bar is clicked. I've tried selecting xAxis, x, and .domain, but I'm getting null values.
data = [
{State: "Greg", Achieved:10,Breached:10},
{State: "Ari", Achieved:10,Breached:10},
{State: "Loser", Achieved:10,Breached:10}
];
// From JSON object state represents X axis (I want to get this).
var state = vis.selectAll(".state")
.data(data)
.enter().append("g")
.attr("class", "g")
.attr("transform", function(d) { return "translate(" + x(d.State) + ",0)"; });
state.selectAll("rect")
.data(function(d) { return d.ages; })
.enter().append("rect")
.attr("y", function(d) { return y(d.y1); })
.attr("height", function(d) { return y(d.y0) - y(d.y1); })
.style("fill", function(d) { return color(d.name); })
.attr("width", x.rangeBand())
.on("click", function(d, i){ console.log(x.rangeBand());return scope.onClick({item: d});});