Data Visualization with D3 - Style D3 Labels (Not passing correct answer)

Tell us what’s happening:
Hi there, I am unable to pass this section as the site is failing the code incorrectly.
The implementation of adding 25px to the font-size is correct but its not passing the section. Please assist.
Thanks

Your code so far

<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");

    svg.selectAll("text")
       .data(dataset)
       .enter()
       .append("text")
       .text((d) => d)
       .attr("x", (d, i) => i * 30)
       .attr("y", (d, i) => h - (3 * d) - 3)
       .style("font-size", "25px")
        .style("fill","red");
  </script>
</body>

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Safari/605.1.15

Challenge: Data Visualization with D3 - Style D3 Labels

Link to the challenge:

Welcome to our community!

Instead of the .style() method use .attr().

Just to clarify the last answer, the challenge wants you to use style for font size and attr for filling red color

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