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.4 KiB

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Timeline | Loading screen example</title>
  5. <script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.4/moment.min.js"></script>
  6. <script src="../../../dist/vis.js"></script>
  7. <link href="../../../dist/vis-timeline-graph2d.min.css" rel="stylesheet" type="text/css" />
  8. </head>
  9. <body>
  10. <h1>Timeline with loading screen</h1>
  11. <div id="visualization"></div>
  12. </body>
  13. <script>
  14. var now = moment();
  15. var groupCount = 20;
  16. var itemCount = 400;
  17. // create a data set with groups
  18. var groups = new vis.DataSet();
  19. for (var g = 0; g < groupCount; g++) {
  20. groups.add({
  21. id: g,
  22. content: "group " + g
  23. });
  24. }
  25. var types = ['point', 'range', 'box', 'background']
  26. // create a dataset with items
  27. var items = new vis.DataSet();
  28. for (var i = 0; i < itemCount; i++) {
  29. var start = now.clone().add(Math.random() * 180, 'days');
  30. var end = start.clone().add(Math.random() * 30, 'days');
  31. var group = Math.floor(Math.random() * groupCount);
  32. items.add({
  33. id: i,
  34. type: types[Math.floor(Math.random() * types.length)],
  35. group: group,
  36. content: '' + i,
  37. start: start,
  38. end: end
  39. });
  40. }
  41. // create visualization
  42. var container = document.getElementById('visualization');
  43. var options = {
  44. loadingScreenTemplate: function() {
  45. return '<h1>Loading...</h1>'
  46. }
  47. };
  48. var timeline = new vis.Timeline(container, items, groups, options);
  49. </script>
  50. </html>