Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm guessing he's using a d3.js <code>transition</code>, see <a href="https://github.com/mbostock/d3/wiki/Transitions" rel="nofollow">https://github.com/mbostock/d3/wiki/Transitions</a>, to basically animate the line (and values) from the current line position to where the mouse cursor currently is. You can tell he isn't trying to just follow the mouse curse because if you move the cursor quickly you can see the line lag behind a bit, this is the animation time of the transition.</p> <p>I put together a quick example of how this is done in d3.js at <a href="http://jsfiddle.net/2N2rt/4/" rel="nofollow">http://jsfiddle.net/2N2rt/4/</a>. I didn't play around with it much so I'm sure you can get it even smoother, but this seemed pretty good.</p> <pre><code>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); </code></pre> <p>Also keep in mind that <code>svg</code> elements tend to animate a lot more smoothly than <code>DOM</code> elements. Here's a pure <code>svg</code> example ( <a href="http://jsfiddle.net/2N2rt/10/" rel="nofollow">http://jsfiddle.net/2N2rt/10/</a> ).</p> <pre><code>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(); </code></pre> <p>Again, this is just a quick example but hopefully it gives you some ideas. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload