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.

92 lines
2.2 KiB

  1. <html>
  2. <head>
  3. <title>Timeline | Vertical Scroll Option</title>
  4. <script src="../../../dist/vis.js"></script>
  5. <link href="../../../dist/vis.css" rel="stylesheet" type="text/css" />
  6. <script src="../../googleAnalytics.js"></script>
  7. </head>
  8. <body>
  9. <h1>Timeline vertical scroll option</h1>
  10. <h2>With <code>
  11. verticalScroll: true,
  12. zoomKey: 'ctrlKey'</code>
  13. </h2>
  14. <div id="mytimeline1"></div>
  15. <h2>With <code>
  16. horizontalScroll: true,
  17. verticalScroll: true,
  18. zoomKey: 'ctrlKey'</code>
  19. </h2>
  20. <div id="mytimeline2"></div>
  21. <script>
  22. // create groups
  23. var numberOfGroups = 25;
  24. var groups = new vis.DataSet()
  25. for (var i = 0; i < numberOfGroups; i++) {
  26. groups.add({
  27. id: i,
  28. content: 'Truck&nbsp;' + i
  29. })
  30. }
  31. // create items
  32. var numberOfItems = 1000;
  33. var items = new vis.DataSet();
  34. var itemsPerGroup = Math.round(numberOfItems/numberOfGroups);
  35. for (var truck = 0; truck < numberOfGroups; truck++) {
  36. var date = new Date();
  37. for (var order = 0; order < itemsPerGroup; order++) {
  38. date.setHours(date.getHours() + 4 * (Math.random() < 0.2));
  39. var start = new Date(date);
  40. date.setHours(date.getHours() + 2 + Math.floor(Math.random()*4));
  41. var end = new Date(date);
  42. items.add({
  43. id: order + itemsPerGroup * truck,
  44. group: truck,
  45. start: start,
  46. end: end,
  47. content: 'Order ' + order
  48. });
  49. }
  50. }
  51. // specify options
  52. var options = {
  53. stack: true,
  54. verticalScroll: true,
  55. zoomKey: 'ctrlKey',
  56. maxHeight: 200,
  57. start: new Date(),
  58. end: new Date(1000*60*60*24 + (new Date()).valueOf()),
  59. editable: true,
  60. margin: {
  61. item: 10, // minimal margin between items
  62. axis: 5 // minimal margin between items and the axis
  63. },
  64. orientation: 'top'
  65. };
  66. // create a Timeline
  67. options1 = Object.assign({}, options)
  68. var container1 = document.getElementById('mytimeline1');
  69. timeline1 = new vis.Timeline(container1, items, groups, options1);
  70. options2 = Object.assign({horizontalScroll: true}, options)
  71. var container2 = document.getElementById('mytimeline2');
  72. timeline2 = new vis.Timeline(container2, items, groups, options2);
  73. </script>
  74. </body>
  75. </html>