Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. // define drag behavior
  2. drag = d3.behavior.drag()
  3. .origin(function(d) { return {x: d['x'], y: d['y']}; })
  4. .on('dragstart', function(d) {
  5. dragStart = new Date();
  6. }).on('drag', dragged)
  7. .on('dragend', function(d) {
  8. dragEnd = new Date();
  9. // units are seconds
  10. var elapsedTime = (dragEnd - dragStart) / 1000;
  11. console.log("elapsed drag time: " + elapsedTime);
  12. // TODO: generate the log of the drag ---
  13. });
  14.  
  15. // create circles
  16. var circles = svg
  17. .selectAll('circle')
  18. .data(data)
  19. .enter().append('circle')
  20. .attr('class', 'circle')
  21. .attr('cx', function(d) { return d['x']; })
  22. .attr('cy', function(d) { return d['y']; })
  23. .attr('r', radius)
  24. .classed('unsorted', true)
  25. .call(drag)
  26. .on('click', clicked)
  27. .on('mouseover', mouseover)
  28. .on('mouseout', mouseout);
  29.  
  30. // define mouseover behavior
  31. function mouseover(d) {
  32. mouseoverStart = new Date();
  33. tip.show(d);
  34. }
  35.  
  36. // define mouseout behavior
  37. function mouseout(d) {
  38. tip.hide(d);
  39. mouseoverEnd = new Date();
  40. // units are seconds
  41. var elapsedTime = (mouseoverEnd - mouseoverStart) / 1000;
  42. console.log("elapsed mouseover time: " + elapsedTime);
  43. // TODO: generate the log of the mouseover --
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement