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.

76 lines
2.0 KiB

11 years ago
11 years ago
11 years ago
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Timeline | Manipulation example</title>
  5. <style>
  6. body, html {
  7. font-family: arial, sans-serif;
  8. font-size: 11pt;
  9. }
  10. </style>
  11. <script src="../../../dist/vis.js"></script>
  12. <link href="../../../dist/vis-timeline-graph2d.min.css" rel="stylesheet" type="text/css" />
  13. <script src="../../googleAnalytics.js"></script>
  14. </head>
  15. <body>
  16. <p>An editable timeline allows to drag items around, create new items, and remove items. Changes are logged in the browser console.</p>
  17. <div id="visualization"></div>
  18. <script>
  19. // create a dataset with items
  20. // we specify the type of the fields `start` and `end` here to be strings
  21. // containing an ISO date. The fields will be outputted as ISO dates
  22. // automatically getting data from the DataSet via items.get().
  23. var items = new vis.DataSet({
  24. type: { start: 'ISODate', end: 'ISODate' }
  25. });
  26. // add items to the DataSet
  27. items.add([
  28. {id: 1, content: 'item 1<br>start', start: '2014-01-23'},
  29. {id: 2, content: 'item 2', start: '2014-01-18'},
  30. {id: 3, content: 'item 3', start: '2014-01-21'},
  31. {id: 4, content: 'item 4', start: '2014-01-19', end: '2014-01-24'},
  32. {id: 5, content: 'item 5', start: '2014-01-28', type:'point'},
  33. {id: 6, content: 'item 6', start: '2014-01-26'}
  34. ]);
  35. // log changes to the console
  36. items.on('*', function (event, properties) {
  37. console.log(event, properties.items);
  38. });
  39. var container = document.getElementById('visualization');
  40. var options = {
  41. start: '2014-01-10',
  42. end: '2014-02-10',
  43. height: '300px',
  44. // allow selecting multiple items using ctrl+click, shift+click, or hold.
  45. multiselect: true,
  46. // allow manipulation of items
  47. editable: true,
  48. /* alternatively, enable/disable individual actions:
  49. editable: {
  50. add: true,
  51. updateTime: true,
  52. updateGroup: true,
  53. remove: true
  54. },
  55. */
  56. showCurrentTime: true
  57. };
  58. var timeline = new vis.Timeline(container, items, options);
  59. </script>
  60. </body>
  61. </html>