score:1

Accepted answer

If you are re-using that same directive for each chart, then in your template your div id isn't unique. This:

var chart = d3.select("#chart").append("div") 

will append to the first div with id chart.

Instead, in your link function find the div from the element variable.

element.children() 

returns the DOM elements in your template.

With your template to find the first child of the outer div should be (untested):

d3.select(element.children(0).children()[0]));

Related Query