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