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.

73 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
  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. });
  43. data.add([
  44. {id: 1, content: 'item 1<br>start', start: now.clone().add('days', 4).toDate()},
  45. {id: 2, content: 'item 2', start: now.clone().add('days', -2).toDate() },
  46. {id: 3, content: 'item 3', start: now.clone().add('days', 2).toDate()},
  47. {id: 4, content: 'item 4',
  48. start: now.clone().add('days', 0).toDate(),
  49. end: now.clone().add('days', 7).toDate()},
  50. {id: 5, content: 'item 5', start: now.clone().add('days', 9).toDate(), type:'point'},
  51. {id: 6, content: 'item 6', start: now.clone().add('days', 11).toDate()}
  52. ]);
  53. var container = document.getElementById('visualization');
  54. var options = {
  55. //start: now.clone().add('days', -7).valueOf(),
  56. //end: now.clone().add('days', 7).valueOf(),
  57. min: moment('2013-01-01').valueOf(),
  58. max: moment('2013-12-31').valueOf(),
  59. zoomMin: 1000 * 60 * 60 * 24, // 1 day
  60. zoomMax: 1000 * 60 * 60 * 24 * 30 * 6 // 6 months
  61. };
  62. var timeline = new vis.Timeline(container, data, options);
  63. </script>
  64. </body>
  65. </html>