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.

75 lines
2.0 KiB

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Timeline | Orientation</title>
  5. <style type="text/css">
  6. body, html {
  7. font-family: sans-serif;
  8. }
  9. </style>
  10. <script src="../../../dist/vis.js"></script>
  11. <link href="../../../dist/vis.css" rel="stylesheet" type="text/css" />
  12. <script src="../../googleAnalytics.js"></script>
  13. </head>
  14. <body>
  15. <p>
  16. There are a number of orientation options for the time axis and the items.
  17. </p>
  18. <p>
  19. <label for="axis-orientation">Axis orientation</label>
  20. <select id="axis-orientation">
  21. <option value="both">both</option>
  22. <option value="bottom" selected>bottom</option>
  23. <option value="none">none</option>
  24. <option value="top">top</option>
  25. </select>
  26. </p>
  27. <p>
  28. <label for="item-orientation">Item orientation</label>
  29. <select id="item-orientation">
  30. <option value="bottom" selected>bottom</option>
  31. <option value="top">top</option>
  32. </select>
  33. </p>
  34. <div id="visualization"></div>
  35. <script type="text/javascript">
  36. // DOM element where the Timeline will be attached
  37. var container = document.getElementById('visualization');
  38. // Create a DataSet (allows two way data-binding)
  39. var items = new vis.DataSet([
  40. {id: 1, content: 'item 1', start: '2014-04-20'},
  41. {id: 2, content: 'item 2', start: '2014-04-14'},
  42. {id: 3, content: 'item 3', start: '2014-04-18'},
  43. {id: 4, content: 'item 4', start: '2014-04-16', end: '2014-04-19'},
  44. {id: 5, content: 'item 5', start: '2014-04-25'},
  45. {id: 6, content: 'item 6', start: '2014-04-27', type: 'point'}
  46. ]);
  47. // Configuration for the Timeline
  48. var options = {
  49. height: 250 // px
  50. };
  51. // Create a Timeline
  52. var timeline = new vis.Timeline(container, items, options);
  53. var axisOrientation = document.getElementById('axis-orientation');
  54. axisOrientation.onchange = function () {
  55. timeline.setOptions({ orientation: {axis: this.value} });
  56. };
  57. var itemOrientation = document.getElementById('item-orientation');
  58. itemOrientation.onchange = function () {
  59. timeline.setOptions({ orientation: {item: this.value} });
  60. };
  61. </script>
  62. </body>
  63. </html>