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.

128 lines
4.2 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title></title>
  5. <script>
  6. var baseUrl = '../src/';
  7. var modules = [
  8. '../node_modules/moment/moment.js',
  9. 'util.js',
  10. 'events.js',
  11. 'timestep.js',
  12. 'dataset.js',
  13. 'stack.js',
  14. 'controller.js',
  15. 'range.js',
  16. 'component/component.js',
  17. 'component/panel.js',
  18. 'component/rootpanel.js',
  19. 'component/timeaxis.js',
  20. 'component/itemset.js',
  21. 'component/item/item.js',
  22. 'component/item/itembox.js',
  23. 'component/item/itemrange.js',
  24. 'component/item/itempoint.js',
  25. 'visualization/timeline.js'
  26. ];
  27. function require(name) {
  28. }
  29. var module = {
  30. exports: {}
  31. };
  32. </script>
  33. <script src="../src/module.js"></script>
  34. <script src="../src/util.js"></script>
  35. <script src="../src/events.js"></script>
  36. <script src="../src/timestep.js"></script>
  37. <script src="../src/dataset.js"></script>
  38. <script src="../src/stack.js"></script>
  39. <script src="../src/controller.js"></script>
  40. <script src="../src/range.js"></script>
  41. <script src="../src/component/component.js"></script>
  42. <script src="../src/component/panel.js"></script>
  43. <script src="../src/component/rootpanel.js"></script>
  44. <script src="../src/component/timeaxis.js"></script>
  45. <script src="../src/component/itemset.js"></script>
  46. <script src="../src/component/item/item.js"></script>
  47. <script src="../src/component/item/itembox.js"></script>
  48. <script src="../src/component/item/itemrange.js"></script>
  49. <script src="../src/component/item/itempoint.js"></script>
  50. <script src="../src/visualization/timeline.js"></script>
  51. <link href="../src/component/css/panel.css" rel="stylesheet" type="text/css" />
  52. <link href="../src/component/css/timeaxis.css" rel="stylesheet" type="text/css" />
  53. <link href="../src/component/css/item.css" rel="stylesheet" type="text/css" />
  54. <style type="text/css">
  55. body, html {
  56. font-family: sans-serif;
  57. font-size: 12pt;
  58. }
  59. #visualization .itemset {
  60. /*background: rgba(255, 255, 0, 0.5);*/
  61. }
  62. </style>
  63. </head>
  64. <body>
  65. <div>
  66. <label for="orientation">Orientation</label>
  67. <select id="orientation">
  68. <option value="top">top</option>
  69. <option value="bottom" selected>bottom</option>
  70. </select>
  71. </div>
  72. <script>
  73. var orientation = document.getElementById('orientation');
  74. orientation.onchange = function () {
  75. timeline.setOptions({
  76. orientation: orientation.value
  77. });
  78. };
  79. </script>
  80. <br>
  81. <div id="visualization"></div>
  82. <script>
  83. // create a dataset with items
  84. var now = moment().minutes(0).seconds(0).milliseconds(0);
  85. var data = new vis.DataSet({
  86. fieldTypes: {
  87. start: 'Date',
  88. end: 'Date'
  89. }
  90. });
  91. data.add([
  92. {id: 1, content: 'item 1<br>start', start: now.clone().add('days', 4).toDate()},
  93. {id: 2, content: 'item 2', start: now.clone().add('days', -2).toDate() },
  94. {id: 3, content: 'item 3', start: now.clone().add('days', 2).toDate()},
  95. {id: 4, content: 'item 4',
  96. start: now.clone().add('days', 0).toDate(),
  97. end: now.clone().add('days', 7).toDate()},
  98. {id: 5, content: 'item 5', start: now.clone().add('days', 9).toDate(), type:'point'},
  99. {id: 6, content: 'item 6', start: now.clone().add('days', 11).toDate()}
  100. ]);
  101. var container = document.getElementById('visualization');
  102. var options = {
  103. //start: now.clone().add('days', -7).valueOf(),
  104. //end: now.clone().add('days', 7).valueOf(),
  105. min: moment('2013-01-01').valueOf(),
  106. max: moment('2013-12-31').valueOf(),
  107. zoomMin: 1000 * 60 * 60 * 24, // 1 day
  108. zoomMax: 1000 * 60 * 60 * 24 * 30 * 6 // 6 months
  109. };
  110. var timeline = new vis.Timeline(container, data, options);
  111. </script>
  112. </body>
  113. </html>