score:2

Accepted answer

The problem is your html file is invalid. Too many bugs in syntax.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">

    <style type="text/css">   
      .chart div {
        font: 10px sans-serif;
        background-color: steelblue;
        text-align: right;
        padding: 3px;
        margin: 1px;
        color: white;
      }
    </style>
  </head>
  <body>
    <div class="chart"></div>
    <script src="./d3.js" charset="utf-8"></script>
    <script>
       window.onload = function runD3code() {
        console.log("not getting called");
         var data = [4, 8, 15, 16, 23, 42];
           d3.select(".chart")
            .selectAll("div")
            .data(data)
          .enter().append("div")
            .style("width", function(d) { return d * 10 + "px"; })
            .text(function(d) { return d; });
        };
     </script>

  </body>
</html>

Related Query

More Query from same tag