Google News
logo
D3.js - Interview Questions
How to get mouse position in d3.js?
var svg = d3.select('body').append('svg')
    .attr('width', width)
    .attr('height', height)
    .on('mousemove', function() {
      console.log( d3.event.clientX, d3.event.clientY ) // log the mouse x,y position
    });
Advertisement