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. </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. <script type="text/javascript">
  31. // Create a DataSet (allows two way data-binding)
  32. var items = new vis.DataSet([
  33. {id: 1, content: 'Item 1', start: '2016-01-01', end: '2016-01-02',
  34. title: 'Normal text'},
  35. {id: 2, content: 'Item 2', start: '2016-01-02', title: '<b>Bold</b>'},
  36. {id: 3, content: 'Item 3', start: '2016-01-03', type: 'point',
  37. title: '<span style="color: red">Red</span> text'},
  38. {id: 4, content: '<h1>HTML</h1> Item', start: '2016-01-03', end: '2016-01-04',
  39. title: '<table border="1"><tr><td>Cell 1</td><td>Cell 2</td></tr></table>'}
  40. ]);
  41. // Options
  42. var options = {};
  43. // Timeline object
  44. var timelineTooltips = new vis.Timeline(document.getElementById('tooltips'),
  45. items, options
  46. );
  47. // Follow options
  48. var follow_options = {
  49. tooltip: {
  50. followMouse: true
  51. }
  52. };
  53. var timelineFollow = new vis.Timeline(document.getElementById('tooltips-follow'),
  54. items, follow_options);
  55. // Cap options
  56. var cap_options = {
  57. tooltip: {
  58. followMouse: true,
  59. overflowMethod: 'cap'
  60. }
  61. }
  62. var timelineCap = new vis.Timeline(document.getElementById('tooltips-cap'),
  63. items, cap_options);
  64. </script>
  65. </body>
  66. </html>