Help with this please

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

<style>
.bar {
  width: 25px;
  height: 100px;
  display: inline-block;
  background-color: blue;
}
</style>
<body>
<script>
  const dataset = [12, 31, 22, 17, 25, 18, 29, 14, 9];

  d3.select("body").selectAll("div")
    .data(dataset)
    .enter()
    .append("div")
    // Add your code below this line
    .attr("div","bar");


    // Add your code above this line
</script>
</body>
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36

Challenge: Add Classes with D3

Link to the challenge:

Example on the left:

selection.attr("class", "container");

Neither “class” nor “container” refer to a html-tag.

attr takes an attribute and a value.

.attr('id', 'someIdValue')

.attr('style', "background: red; height: 10px;")

1 Like

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