Visualization tooltip wrong text

Tell us what’s happening:
So I have added the title elements as best I could so far. But when I run it; all of my bars have the value on the tooltip. Yet when I submit it; the challenge says everything is fine.
Your code so far


<style>
.bar:hover {
  fill: brown;
}
</style>
<body>
<script>
  const dataset = [12, 31, 22, 17, 25, 18, 29, 14, 9];

  const w = 500;
  const h = 100;

  const svg = d3.select("body")
                .append("svg")
                .attr("width", w)
                .attr("height", h);

  svg.selectAll("rect")
     .data(dataset)
     .enter()
     .append("rect")
     .attr("x", (d, i) => i * 30)
     .attr("y", (d, i) => h - 3 * d)
     .attr("width", 25)
     .attr("height", (d, i) => d * 3)
     .attr("fill", "navy")
     .attr("class", "bar")
     // Add your code below this line
    svg.selectAll("title")
      .data(dataset)
      .enter()
      .append("title")
      .text((d) => d);


     // Add your code above this line

  svg.selectAll("text")
     .data(dataset)
     .enter()
     .append("text")
     .text((d) => d)
     .attr("x", (d, i) => i * 30)
     .attr("y", (d, i) => h - (d * 3 + 3))

</script>
</body>
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0.

Challenge: Add a Tooltip to a D3 Element

Link to the challenge:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.