Display Shapes with SVG

Tell us what’s happening:

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)
                  // Add your code below this line
                 svg.selectAll("rect")
           .data(dataset)
          .enter()
          .append("rect")
          .attr("x", 0)
          .attr("y", 0)
          .attr("width", 25)
          .attr("height", 100);
                     
                  
                  // Add your code above this line
  </script>
</body>

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36 OPR/54.0.2952.54.

Link to the challenge:
https://learn.freecodecamp.org/data-visualization/data-visualization-with-d3/display-shapes-with-svg

Your document should have 1 rect element. This test case is not passed what is wrong in this code.

Not sure why you had these lines in your code? What did you think this would do?

Add a rect shape to the svg using append(), and give it a width attribute of 25 and height attribute of 100. Also, give the rect x and y attributes each set to 0.
This is given in the question.

The code I highlighted above does not do any of that. You can delete these 3 lines above and your solution will pass with the other code you had below it.

2 Likes

Thanks Sir…it’s worked:slightly_smiling_face:

Thank you to the solution !