I just wanted to get the mouse position using D3 by using the following code:
var x = 0;
svg.on(\'mousemove\', function () {
x = d3.mouse(this)[0];
You have to use an array. That will store x and y like:
var coordinates= d3.mouse(this);
var x = coordinates[0];
var y = coordinates[1];
// D3 v4
var x = d3.event.pageX - document.getElementById().getBoundingClientRect().x + 10
var y = d3.event.pageY - document.getElementById().getBoundingClientRect().y + 10