vis.js is a dynamic, browser-based visualization library

82 lines
2.2 KiB

12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 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. //orientation: 'top',
  60. start: now.clone().add('days', -7),
  61. end: now.clone().add('days', 7),
  62. //maxHeight: 200,
  63. height: 200,
  64. //start: moment('2013-01-01'),
  65. //end: moment('2013-12-31'),
  66. //min: moment('2013-01-01'),
  67. //max: moment('2013-12-31'),
  68. zoomMin: 1000 * 60 * 60 * 24, // 1 day
  69. zoomMax: 1000 * 60 * 60 * 24 * 30 * 6 // 6 months
  70. };
  71. var timeline = new vis.Timeline(container, items, options);
  72. </script>
  73. </body>
  74. </html>