score:0

Accepted answer

You are missing a .selectAll('svg') after selecting the div.

var svg = d3.select("#chart")
  .selectAll('svg')    // <-- You want to operate on set of SVG elements
    .data(d3.range(2013, 2015))
  .enter().append("svg")

Working demo: http://plnkr.co/edit/2SwqI8gW2UaGIdlHvX2Y?p=preview

Also, as a general rule, it is best to run your Javascript code which changes the DOM after the DOM has loaded. I have moved the script tag which ran your code to the bottom of the body tag so that the div#chart has been put into the DOM for d3.select('#chart') to find.


Related Query

More Query from same tag