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.css" rel="stylesheet" type="text/css" />
  20. <script src="../../googleAnalytics.js"></script>
  21. </head>
  22. <body>
  23. <div id="main">
  24. <h1>Timeline click to use</h1>
  25. <p>
  26. 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.
  27. </p>
  28. </div>
  29. <script>
  30. // create a dataset with items
  31. // we specify the type of the fields `start` and `end` here to be strings
  32. // containing an ISO date. The fields will be outputted as ISO dates
  33. // automatically getting data from the DataSet via items.get().
  34. var items = new vis.DataSet({
  35. type: { start: 'ISODate', end: 'ISODate' }
  36. });
  37. // add items to the DataSet
  38. items.add([
  39. {id: 1, content: 'item 1<br>start', start: '2014-01-23'},
  40. {id: 2, content: 'item 2', start: '2014-01-18'},
  41. {id: 3, content: 'item 3', start: '2014-01-21'},
  42. {id: 4, content: 'item 4', start: '2014-01-19', end: '2014-01-24'},
  43. {id: 5, content: 'item 5', start: '2014-01-28', type:'point'},
  44. {id: 6, content: 'item 6', start: '2014-01-26'}
  45. ]);
  46. function createTimeline(main) {
  47. var main = document.getElementById('main');
  48. var container = document.createElement('div');
  49. container.className = 'container';
  50. main.appendChild(container);
  51. var options = {
  52. editable: true,
  53. clickToUse: true
  54. };
  55. return new vis.Timeline(container, items, options);
  56. }
  57. var timelines = [];
  58. for (var i = 0; i < 10; i++) {
  59. timelines.push(createTimeline());
  60. }
  61. </script>
  62. </body>
  63. </html>