I assume it uses d3.js transition , see https://github.com/mbostock/d3/wiki/Transitions to basically animate the line (and values) from the current line position to where the mouse cursor is. You can say that he is not trying to just follow the mouse whip, because if you quickly move the cursor, you can see the lag behind the line behind, this is the transition animation time.
I put together a quick example of how this is done in d3.js at http://jsfiddle.net/2N2rt/4/ . I have not played with him much, so I am sure you can make it even smoother, but it seemed very good to us.
var line = d3.select('#selection_line'), page = d3.select('#page_content'), x = 0; page.on('mousemove', function() { x = d3.mouse(this)[0]; }); var update = function() { line.transition() .duration(5) .ease('cubic-in-out') .style('left', x + 'px'); }; setInterval(update, 35);
Also keep in mind that svg elements tend to come to life much more smoothly than DOM elements. Here is an example of svg ( http://jsfiddle.net/2N2rt/10/ ).
var graph = d3.select('#graph') .append('svg') .attr('width', '100%') .attr('height', 600); var box = graph.append('rect') .attr('transform', 'translate(0, 100)') .attr('width', '100%') .attr('height', 200) .attr('class', 'page_content'); var line = graph.append('line') .attr('transform', 'translate(0, 50)') .attr({'x1': 0, 'y1' : 0, 'x2': 0, 'y2': 300}) .attr('class', 'selection_line'); var x = 0; graph.on('mousemove', function () { x = d3.mouse(this)[0]; }); var draw = function () { line .transition() .duration(18) .attrTween('transform', d3.tween('translate(' + x + ', 50)', d3.interpolateString)) .each('end', draw); }; draw();
Again, this is just a quick example, but hopefully it gives you some ideas.