You cannot get this DOM element from inside the line generator (with or without Angular). The line generator has no access to the element you're appending using it.

The API is clear about that:

When a line is generated, the x accessor will be invoked for each defined element in the input data array, being passed the element d, the index i, and the array data as three arguments. (emphasis mine)

The same, obviously, goes for the y accessor. So, as you can see, only the data is passed.

Therefore, this in this case will be simply the window, and there is no parentNode here.

Look at this demo (as the stack snippet takes a long time to console.log the window object, I'm using only

var line = d3.line()
  .x(function(d) {
    return d;
  .y(function(d) {
    return d;

<script src=""></script>

Related Query

More Query from same tag