Guest User

Untitled

a guest
Jul 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. function showTooltip(x, y, contents) {
  2. $('<div id="tooltip">' + contents + '</div>').css( {
  3. position: 'absolute',
  4. top: y + 5,
  5. left: x + 5,
  6. border: '1px solid #fdd',
  7. padding: '2px',
  8. 'background-color': '#fee',
  9. opacity: 0.80
  10. }).appendTo("body");//.fadeIn(200);
  11. }
  12.  
  13. var previousPoint = null;
  14.  
  15. $('#placeholder').bind('mouseout', function() {
  16. plot.unhighlight();
  17. $("#tooltip").remove();
  18. $(this).data('previous-post', -1);
  19. });
  20.  
  21. $('#placeholder').bind('plothover', function(event, pos, item) {
  22. if (item) {
  23. if ($(this).data('previous-post') != item.seriesIndex) {
  24. plot.unhighlight();
  25. plot.highlight(item.series, item.datapoint);
  26. $(this).data('previous-post', item.seriesIndex);
  27. }
  28. $("#tooltip").remove();
  29. y = 'on ' + (new Date(item.datapoint[0])).toDateString() + ': ' + item.datapoint[1];
  30. showTooltip(pos.pageX, pos.pageY, item.series.label + " " + y);
  31. } else {
  32. plot.unhighlight();
  33. $("#tooltip").remove();
  34. previousPost = $(this).data('previous-post', -1);
  35. }
  36. });
Add Comment
Please, Sign In to add comment