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.

59 lines
1.7 KiB

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Timeline | Event listeners</title>
  5. <style type="text/css">
  6. body, html {
  7. font-family: sans-serif;
  8. }
  9. </style>
  10. <script src="../../dist/vis.js"></script>
  11. <link href="../../dist/vis.css" rel="stylesheet" type="text/css" />
  12. </head>
  13. <body>
  14. <div id="visualization"></div>
  15. <p></p>
  16. <div id="log"></div>
  17. <script type="text/javascript">
  18. var items = new vis.DataSet([
  19. {id: 1, content: 'item 1', start: '2013-04-20'},
  20. {id: 2, content: 'item 2', start: '2013-04-14'},
  21. {id: 3, content: 'item 3', start: '2013-04-18'},
  22. {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
  23. {id: 5, content: 'item 5', start: '2013-04-25'},
  24. {id: 6, content: 'item 6', start: '2013-04-27'}
  25. ]);
  26. var container = document.getElementById('visualization');
  27. var options = {
  28. editable: true
  29. };
  30. var timeline = new vis.Timeline(container, items, options);
  31. timeline.on('rangechange', function (properties) {
  32. logEvent('rangechange', properties);
  33. });
  34. timeline.on('rangechanged', function (properties) {
  35. logEvent('rangechanged', properties);
  36. });
  37. timeline.on('select', function (properties) {
  38. logEvent('select', properties);
  39. });
  40. items.on('*', function (event, properties) {
  41. logEvent(event, properties);
  42. });
  43. function logEvent(event, properties) {
  44. var log = document.getElementById('log');
  45. var msg = document.createElement('div');
  46. msg.innerHTML = 'event=' + JSON.stringify(event) + ', ' +
  47. 'properties=' + JSON.stringify(properties);
  48. log.firstChild ? log.insertBefore(msg, log.firstChild) : log.appendChild(msg);
  49. }
  50. </script>
  51. </body>
  52. </html>