I'm working on a data visualization proyect, using javascript and d3. In this proyect I'm showing the data using various charts (the data comes from an external source). I'm new in this language so I´m using pieces of code from differents parts of the internet and a lot of the work comes from editing those pieces in order to make them compatible with each other.
I have succefully deploy the charts (A big accomplishment for me, since I started with javascript and HTML just one week ago). Now i want to be able to open a modal when clicking the bars of the charts or, at least, on the labels, but I'm having some trouble with that.
This is how the bars on the chart are defined:
var vakken = svg.selectAll(".question")
.data(data)
.enter().append("g")
.attr("class", "bar")
.attr("transform", function(d) { return "translate(0," + y(d.Question) + ")"; });
var bars = vakken.selectAll("rect")
.data(function(d) { return d.boxes; })
.enter().append("g").attr("class", "subbar");
bars.append("rect")
.attr("height", 16)
.attr("x", function(d) { return (x(d.x0)); })
.attr("width", function(d) { return (x(d.x1) - x(d.x0)); })
.style("fill", function(d) { return color(d.name); });
Any comment on how to achieve this will be appreciated (And feel free to mock me, i kind of deserve it)