Having trouble updating height with d3.style

Tell us what’s happening:

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")
    .attr("class", "bar")
    // Add your code below this line
    
    .style("height", (d) => d + "px");


    // Add your code above this line
</script>
</body>

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36.

Challenge: Update the Height of an Element Dynamically

Link to the challenge:
https://www.freecodecamp.org/learn/data-visualization/data-visualization-with-d3/update-the-height-of-an-element-dynamically

Welcome to the forum.

Your code is passing for me. This might be a zoom bug with Chrome. Make sure you have set the browser zoom to 100% (Ctrl + 0) and run the test again.

BTW, this issue should be fixed but it still needs to be pushed to production.

2 Likes

@lasjorg Great to be here, and thanks for your help!

Thanks! Had the same issue today. That did the trick!!