D3 create and append a rect

Tell us what’s happening:
Describe your issue in detail here.
I have to ceate and append a rectangle for each item of the dataset. My code doesn’t seem to work, I don’t understand why. Anyone could help me please ? Thanks.

  **Your code so far**

  const dataset = [12, 31, 22, 17, 25, 18, 29, 14, 9];

  const w = 500;
  const h = 100;

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

     // Add your code below this line

     // Add your code above this line
     .attr("x", 0)
     .attr("y", 0)
     .attr("width", 25)
     .attr("height", 100);
  **Your browser information:**

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0

Challenge: Create a Bar for Each Data Point in the Set

Link to the challenge:

What do you mean by not working? To clarify, the code will create multiple rect but they are displayed on top of each other. The next challenge will make them appear at different locations.

Alright, thank you for your help :slightly_smiling_face:

1 Like

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