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.

74 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="top">top</option>
  24. </select>
  25. </p>
  26. <p>
  27. <label for="item-orientation">Item orientation</label>
  28. <select id="item-orientation">
  29. <option value="bottom" selected>bottom</option>
  30. <option value="top">top</option>
  31. </select>
  32. </p>
  33. <div id="visualization"></div>
  34. <script type="text/javascript">
  35. // DOM element where the Timeline will be attached
  36. var container = document.getElementById('visualization');
  37. // Create a DataSet (allows two way data-binding)
  38. var items = new vis.DataSet([
  39. {id: 1, content: 'item 1', start: '2014-04-20'},
  40. {id: 2, content: 'item 2', start: '2014-04-14'},
  41. {id: 3, content: 'item 3', start: '2014-04-18'},
  42. {id: 4, content: 'item 4', start: '2014-04-16', end: '2014-04-19'},
  43. {id: 5, content: 'item 5', start: '2014-04-25'},
  44. {id: 6, content: 'item 6', start: '2014-04-27', type: 'point'}
  45. ]);
  46. // Configuration for the Timeline
  47. var options = {
  48. height: 250 // px
  49. };
  50. // Create a Timeline
  51. var timeline = new vis.Timeline(container, items, options);
  52. var axisOrientation = document.getElementById('axis-orientation');
  53. axisOrientation.onchange = function () {
  54. timeline.setOptions({ orientation: {axis: this.value} });
  55. };
  56. var itemOrientation = document.getElementById('item-orientation');
  57. itemOrientation.onchange = function () {
  58. timeline.setOptions({ orientation: {item: this.value} });
  59. };
  60. </script>
  61. </body>
  62. </html>