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.

90 lines
2.1 KiB

  1. <html>
  2. <head>
  3. <title>Timeline | Vertical Scroll Option</title>
  4. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
  5. <script src="../../../dist/vis.js"></script>
  6. <link href="../../../dist/vis.css" rel="stylesheet" type="text/css" />
  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. var orderIndex = order + itemsPerGroup * truck
  43. items.add({
  44. id: orderIndex,
  45. group: truck,
  46. start: start,
  47. end: end,
  48. content: 'Order ' + orderIndex
  49. });
  50. }
  51. }
  52. // specify options
  53. var options = {
  54. stack: true,
  55. verticalScroll: true,
  56. zoomKey: 'ctrlKey',
  57. maxHeight: 200,
  58. start: new Date(),
  59. end: new Date(1000*60*60*24 + (new Date()).valueOf()),
  60. };
  61. // create a Timeline
  62. options1 = jQuery.extend(options, {});
  63. var container1 = document.getElementById('mytimeline1');
  64. timeline1 = new vis.Timeline(container1, items, groups, options1);
  65. options2 = jQuery.extend(options, {horizontalScroll: true});
  66. var container2 = document.getElementById('mytimeline2');
  67. timeline2 = new vis.Timeline(container2, items, groups, options2);
  68. </script>
  69. </body>
  70. </html>