vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
2.2 KiB

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Timeline | Tooltips</title>
  5. <style type="text/css">
  6. body, html {
  7. font-family: sans-serif;
  8. max-width: 800px;
  9. }
  10. </style>
  11. <script src="../../../dist/vis.js"></script>
  12. <link href="../../../dist/vis-timeline-graph2d.min.css" rel="stylesheet" type="text/css" />
  13. </head>
  14. <body>
  15. <h1>Tooltips</h1>
  16. <p>
  17. Setting the tooltip in various ways.
  18. </p>
  19. <div id="tooltips"></div>
  20. <p>
  21. The example below has the tooltip follow the mouse.
  22. </p>
  23. <div id="tooltips-follow"></div>
  24. <p>
  25. The example below has the tooltip overflow set to 'cap'. Compare this to the one above,
  26. to see how they differ. For the best results, move the cursor to the top right,
  27. where the tool-tip is going to overflow out of the timeline.
  28. </p>
  29. <div id="tooltips-cap"></div>
  30. <p>
  31. Disable item tooltips.
  32. </p>
  33. <div id="tooltips-hide"></div>
  34. <script type="text/javascript">
  35. // Create a DataSet (allows two way data-binding)
  36. var items = new vis.DataSet([
  37. {id: 1, content: 'Item 1', start: '2016-01-01', end: '2016-01-02',
  38. title: 'Normal text'},
  39. {id: 2, content: 'Item 2', start: '2016-01-02', title: '<b>Bold</b>'},
  40. {id: 3, content: 'Item 3', start: '2016-01-03', type: 'point',
  41. title: '<span style="color: red">Red</span> text'},
  42. {id: 4, content: '<h1>HTML</h1> Item', start: '2016-01-03', end: '2016-01-04',
  43. title: '<table border="1"><tr><td>Cell 1</td><td>Cell 2</td></tr></table>'}
  44. ]);
  45. // Options
  46. var options = {};
  47. // Timeline object
  48. var timelineTooltips = new vis.Timeline(document.getElementById('tooltips'),
  49. items, options
  50. );
  51. // Follow options
  52. var follow_options = {
  53. tooltip: {
  54. followMouse: true
  55. }
  56. };
  57. var timelineFollow = new vis.Timeline(document.getElementById('tooltips-follow'),
  58. items, follow_options);
  59. // Cap options
  60. var cap_options = {
  61. tooltip: {
  62. followMouse: true,
  63. overflowMethod: 'cap'
  64. }
  65. }
  66. var timelineCap = new vis.Timeline(document.getElementById('tooltips-cap'),
  67. items, cap_options);
  68. // Hide options
  69. var hide_options = {
  70. showTooltips: false
  71. }
  72. var timelineHide = new vis.Timeline(document.getElementById('tooltips-hide'),
  73. items, hide_options);
  74. </script>
  75. </body>
  76. </html>