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.

54 lines
1.5 KiB

  1. <!DOCTYPE HTML>
  2. <!--
  3. This example is used mainly for developers to test performance issues by controlling number of groups,
  4. number of items and their types.
  5. -->
  6. <html>
  7. <head>
  8. <title>Timeline | onTimeout example</title>
  9. <script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.4/moment.min.js"></script>
  10. <script src="../../../dist/vis.js"></script>
  11. <link href="../../../dist/vis-timeline-graph2d.min.css" rel="stylesheet" type="text/css" />
  12. </head>
  13. <body>
  14. <div id="visualization"></div>
  15. </body>
  16. <script>
  17. var now = moment();
  18. var itemCount = 300;
  19. var types = ['point', 'range', 'box']
  20. // create a dataset with items
  21. var items = new vis.DataSet();
  22. for (var i = 0; i < itemCount; i++) {
  23. var start = now.clone().add(Math.random() * 180, 'days');
  24. var end = start.clone().add(Math.random() * 30, 'days');
  25. items.add({
  26. id: i,
  27. type: types[Math.floor(Math.random() * types.length)],
  28. content: '' + i,
  29. start: start,
  30. end: end
  31. });
  32. }
  33. // create visualization
  34. var container = document.getElementById('visualization');
  35. var options = {
  36. stack: true,
  37. onTimeout: {
  38. timeoutMs: 1000,
  39. callback: function(callback) {
  40. var didUserCancel;
  41. var didUserCancel = confirm("Too many items loaded! Would you like to continue rendering (this might take a while)?");
  42. callback(didUserCancel)
  43. },
  44. }
  45. };
  46. var timeline = new vis.Timeline(container, items, options);
  47. </script>
  48. </html>