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.

72 lines
1.9 KiB

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Timeline | Click to use</title>
  5. <style>
  6. body, html {
  7. font-family: arial, sans-serif;
  8. font-size: 11pt;
  9. }
  10. #main {
  11. width: 728px;
  12. margin: 0 auto;
  13. }
  14. .container {
  15. margin: 10px;
  16. }
  17. </style>
  18. <script src="../../../dist/vis.js"></script>
  19. <link href="../../../dist/vis-timeline-graph2d.min.css" rel="stylesheet" type="text/css" />
  20. </head>
  21. <body>
  22. <div id="main">
  23. <h1>Timeline click to use</h1>
  24. <p>
  25. This example demonstrates how to use the <code>clickToUse</code> option: before you can scroll and drag in the timeline, you first have to click in the timeline to activate.
  26. </p>
  27. </div>
  28. <script>
  29. // create a dataset with items
  30. // we specify the type of the fields `start` and `end` here to be strings
  31. // containing an ISO date. The fields will be outputted as ISO dates
  32. // automatically getting data from the DataSet via items.get().
  33. var items = new vis.DataSet({
  34. type: { start: 'ISODate', end: 'ISODate' }
  35. });
  36. // add items to the DataSet
  37. items.add([
  38. {id: 1, content: 'item 1<br>start', start: '2014-01-23'},
  39. {id: 2, content: 'item 2', start: '2014-01-18'},
  40. {id: 3, content: 'item 3', start: '2014-01-21'},
  41. {id: 4, content: 'item 4', start: '2014-01-19', end: '2014-01-24'},
  42. {id: 5, content: 'item 5', start: '2014-01-28', type:'point'},
  43. {id: 6, content: 'item 6', start: '2014-01-26'}
  44. ]);
  45. function createTimeline(main) {
  46. var main = document.getElementById('main');
  47. var container = document.createElement('div');
  48. container.className = 'container';
  49. main.appendChild(container);
  50. var options = {
  51. editable: true,
  52. clickToUse: true
  53. };
  54. return new vis.Timeline(container, items, options);
  55. }
  56. var timelines = [];
  57. for (var i = 0; i < 10; i++) {
  58. timelines.push(createTimeline());
  59. }
  60. </script>
  61. </body>
  62. </html>