Add labels to D3 solution

What is your hint or solution suggestion?
/Instead of changing rectangle y coordinate and height by 3 times of d we can change it by 2 times then the result is available clearly on screen./
svg.selectAll(“rect”)
.data(dataset)
.enter()
.append(“rect”)
.attr(“x”, (d, i) => i * 30)
.attr(“y”, (d, i) => h - 2 * d)//change y by 2 times
.attr(“width”, 25)
.attr(“height”, (d, i) => 2 * d)//change height by 2 times
.attr(“fill”, “navy”);

svg.selectAll("text")
   .data(dataset)
   .enter()
   // Add your code below this line
   .append("text")
  .attr("x",(d,i)=> i * 30)
   .attr("y",(d,i)=>h-2*d)
   .text((d,i)=>d)

Challenge: Add Labels to D3 Elements

Link to the challenge:

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