score:1

Accepted answer

you are setting widths using a css style. this requires units (px, em, or %).

updated code:

<!doctype html>
<html>

<head>
  <script data-require="d3@4.0.0" data-semver="4.0.0" src="https://d3js.org/d3.v4.min.js"></script>
</head>

<body>
  <div id="chart"></div>
  <script>
    data = [100, 200, 400, 350];
    d3.select("#chart")
      .selectall("div")
      .data(data)
      .enter()
      .append("div")
      .style("height", "30px")
      .style("width", function(d) {
        return d / 2 + "px"
      })
      .style("background-color", "grey")
      .transition()
      .duration(2000)
      .style("width", function(d) {
        return d + "px";
      })
      .style("background-color", "blue");
  </script>
</body>

</html>


Related Query

More Query from same tag