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.

85 lines
2.3 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
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title></title>
  5. <script src="../node_modules/moment/moment.js"></script>
  6. <script src="../dist/vis.js"></script>
  7. <link href="../dist/vis.css" rel="stylesheet" type="text/css" />
  8. <style type="text/css">
  9. body, html {
  10. font-family: sans-serif;
  11. font-size: 11pt;
  12. }
  13. #visualization .itemset {
  14. /*background: rgba(255, 255, 0, 0.5);*/
  15. }
  16. </style>
  17. </head>
  18. <body>
  19. <div>
  20. <label for="orientation">Orientation</label>
  21. <select id="orientation">
  22. <option value="top">top</option>
  23. <option value="bottom" selected>bottom</option>
  24. </select>
  25. </div>
  26. <script>
  27. var orientation = document.getElementById('orientation');
  28. orientation.onchange = function () {
  29. timeline.setOptions({
  30. orientation: orientation.value
  31. });
  32. };
  33. </script>
  34. <br>
  35. <div id="visualization"></div>
  36. <script>
  37. // create a dataset with items
  38. var now = moment().minutes(0).seconds(0).milliseconds(0);
  39. var items = new vis.DataSet({
  40. convert: {
  41. start: 'Date',
  42. end: 'Date'
  43. },
  44. fieldId: '_id'
  45. });
  46. items.add([
  47. {_id: 0, content: 'item 0', start: now.clone().add('days', 3).toDate()},
  48. {_id: 1, content: 'item 1<br>start', start: now.clone().add('days', 4).toDate()},
  49. {_id: 2, content: 'item 2', start: now.clone().add('days', -2).toDate() },
  50. {_id: 3, content: 'item 3', start: now.clone().add('days', 2).toDate()},
  51. {_id: 4, content: 'item 4',
  52. start: now.clone().add('days', 0).toDate(),
  53. end: now.clone().add('days', 7).toDate()},
  54. {_id: 5, content: 'item 5', start: now.clone().add('days', 9).toDate(), type:'point'},
  55. {_id: 6, content: 'item 6', start: now.clone().add('days', 11).toDate()}
  56. ]);
  57. var container = document.getElementById('visualization');
  58. var options = {
  59. editable: true,
  60. //orientation: 'top',
  61. start: now.clone().add('days', -7),
  62. end: now.clone().add('days', 7),
  63. //maxHeight: 200,
  64. //height: 200,
  65. showCurrentTime: true,
  66. showCustomTime: true,
  67. //start: moment('2013-01-01'),
  68. //end: moment('2013-12-31'),
  69. //min: moment('2013-01-01'),
  70. //max: moment('2013-12-31'),
  71. zoomMin: 1000 * 60 * 60 * 24, // 1 day
  72. zoomMax: 1000 * 60 * 60 * 24 * 30 * 6 // 6 months
  73. };
  74. var timeline = new vis.Timeline(container, items, options);
  75. </script>
  76. </body>
  77. </html>