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.

84 lines
2.0 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. <script src="../../googleAnalytics.js"></script>
  14. </head>
  15. <body>
  16. <h1>Tooltips</h1>
  17. <p>
  18. Setting the tooltip in various ways.
  19. </p>
  20. <div id="tooltips"></div>
  21. <p>
  22. The example below has the tooltip follow the mouse.
  23. </p>
  24. <div id="tooltips-follow"></div>
  25. <p>
  26. The example below has the tooltip overflow set to 'cap'. Compare this to the one above,
  27. to see how they differ. For the best results, move the cursor to the top right,
  28. where the tool-tip is going to overflow out of the timeline.
  29. </p>
  30. <div id="tooltips-cap"></div>
  31. <script type="text/javascript">
  32. // Create a DataSet (allows two way data-binding)
  33. var items = new vis.DataSet([
  34. {id: 1, content: 'Item 1', start: '2016-01-01', end: '2016-01-02',
  35. title: 'Normal text'},
  36. {id: 2, content: 'Item 2', start: '2016-01-02', title: '<b>Bold</b>'},
  37. {id: 3, content: 'Item 3', start: '2016-01-03', type: 'point',
  38. title: '<span style="color: red">Red</span> text'},
  39. {id: 4, content: '<h1>HTML</h1> Item', start: '2016-01-03', end: '2016-01-04',
  40. title: '<table border="1"><tr><td>Cell 1</td><td>Cell 2</td></tr></table>'}
  41. ]);
  42. // Options
  43. var options = {};
  44. // Timeline object
  45. var timelineTooltips = new vis.Timeline(document.getElementById('tooltips'),
  46. items, options
  47. );
  48. // Follow options
  49. var follow_options = {
  50. tooltip: {
  51. followMouse: true
  52. }
  53. };
  54. var timelineFollow = new vis.Timeline(document.getElementById('tooltips-follow'),
  55. items, follow_options);
  56. // Cap options
  57. var cap_options = {
  58. tooltip: {
  59. followMouse: true,
  60. overflowMethod: 'cap'
  61. }
  62. }
  63. var timelineCap = new vis.Timeline(document.getElementById('tooltips-cap'),
  64. items, cap_options);
  65. </script>
  66. </body>
  67. </html>