Creating a histogram in d3. I have 30+ bars, with 30+ corresponding inscriptions on the x axis. I would like the X axis labels to be hidden when the page loads (this works), AND APPEAR only if the user cursor is over the corresponding panel (SVG object). To do this, I assign an identifier to each rectangle and each text element. When the user's cursors exceed the rectangle, the text will be displayed ONLY selected (mouseover'd) rect.
I can assign id for corrections, but not for text. Code:
svg.selectAll("rect") .data(dataset) .enter() .append("rect") .attr("id", function(d){ return d.slug;
However, the same code for my text element on the x axis does not assign id ?!
svg.append("g") .call(xAxis) .selectAll("text") .attr("id", function (d){
How can I assign a unique identifier to my text elements on the x axis? Thanks!
source share