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