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.

57 lines
1.5 KiB

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Timeline | External data</title>
  5. <style type="text/css">
  6. body, html {
  7. font-family: sans-serif;
  8. }
  9. </style>
  10. <!-- Load jquery for ajax support -->
  11. <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
  12. <script src="../../../dist/vis.js"></script>
  13. <link href="../../../dist/vis-timeline-graph2d.min.css" rel="stylesheet" type="text/css" />
  14. </head>
  15. <body>
  16. <p>
  17. This demo shows how to load external data via an ajax call.
  18. </p>
  19. <div id="visualization"></div>
  20. <div id="loading">loading...</div>
  21. <script type="text/javascript">
  22. // load data via an ajax request. When the data is in, load the timeline
  23. $.ajax({
  24. url: '../resources/data/basic.json',
  25. success: function (data) {
  26. // hide the "loading..." message
  27. document.getElementById('loading').style.display = 'none';
  28. // DOM element where the Timeline will be attached
  29. var container = document.getElementById('visualization');
  30. // Create a DataSet (allows two way data-binding)
  31. var items = new vis.DataSet(data);
  32. // Configuration for the Timeline
  33. var options = {};
  34. // Create a Timeline
  35. var timeline = new vis.Timeline(container, items, options);
  36. },
  37. error: function (err) {
  38. console.log('Error', err);
  39. if (err.status === 0) {
  40. alert('Failed to load data/basic.json.\nPlease run this example on a server.');
  41. }
  42. else {
  43. alert('Failed to load data/basic.json.');
  44. }
  45. }
  46. });
  47. </script>
  48. </body>
  49. </html>