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];
});
but x is always equal to 0. By using console.log(), I can see that x value is getting changed just inside the function() but out of it x got its initial value of 0.
How can I save the x value and use it later in my application?