score:7

Accepted answer

You cannot use an arrow function if you want this to be defined by d3, as stated here:

An arrow function does not create its own this context, so this has its original meaning from the enclosing context.

The following will work as you expect:

 .on('mouseover', function(d) {
     console.log(d3.select(this).attr('x'));
 });

Related Query

More Query from same tag