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.

89 lines
2.0 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. </head>
  7. <body>
  8. <h1>Timeline vertical scroll option</h1>
  9. <h2>With <code>
  10. verticalScroll: true,
  11. zoomKey: 'ctrlKey'</code>
  12. </h2>
  13. <div id="mytimeline1"></div>
  14. <h2>With <code>
  15. horizontalScroll: true,
  16. verticalScroll: true,
  17. zoomKey: 'ctrlKey'</code>
  18. </h2>
  19. <div id="mytimeline2"></div>
  20. <script>
  21. // create groups
  22. var numberOfGroups = 25;
  23. var groups = new vis.DataSet()
  24. for (var i = 0; i < numberOfGroups; i++) {
  25. groups.add({
  26. id: i,
  27. content: 'Truck&nbsp;' + i
  28. })
  29. }
  30. // create items
  31. var numberOfItems = 1000;
  32. var items = new vis.DataSet();
  33. var itemsPerGroup = Math.round(numberOfItems/numberOfGroups);
  34. for (var truck = 0; truck < numberOfGroups; truck++) {
  35. var date = new Date();
  36. for (var order = 0; order < itemsPerGroup; order++) {
  37. date.setHours(date.getHours() + 4 * (Math.random() < 0.2));
  38. var start = new Date(date);
  39. date.setHours(date.getHours() + 2 + Math.floor(Math.random()*4));
  40. var end = new Date(date);
  41. var orderIndex = order + itemsPerGroup * truck
  42. items.add({
  43. id: orderIndex,
  44. group: truck,
  45. start: start,
  46. end: end,
  47. content: 'Order ' + orderIndex
  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. };
  60. // create a Timeline
  61. options1 = Object.assign({}, options)
  62. var container1 = document.getElementById('mytimeline1');
  63. timeline1 = new vis.Timeline(container1, items, groups, options1);
  64. options2 = Object.assign({horizontalScroll: true}, options)
  65. var container2 = document.getElementById('mytimeline2');
  66. timeline2 = new vis.Timeline(container2, items, groups, options2);
  67. </script>
  68. </body>
  69. </html>