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.

66 lines
1.8 KiB

10 years ago
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Timeline | a lot of data</title>
  5. <style>
  6. body, html {
  7. font-family: arial, sans-serif;
  8. font-size: 11pt;
  9. }
  10. </style>
  11. <!-- note: moment.js must be loaded before vis.js, else vis.js uses its embedded version of moment.js -->
  12. <script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.3.1/moment.min.js"></script>
  13. <script src="../../dist/vis.js"></script>
  14. <link href="../../dist/vis.css" rel="stylesheet" type="text/css" />
  15. </head>
  16. <body>
  17. <h1>
  18. Test with a lot of data
  19. </h1>
  20. <p>
  21. <label for="count">Number of items</label>
  22. <input id="count" value="10000">
  23. <input id="draw" type="button" value="draw">
  24. </p>
  25. <div id="visualization"></div>
  26. <script>
  27. // create a dataset with items
  28. var now = moment().minutes(0).seconds(0).milliseconds(0);
  29. var items = new vis.DataSet({
  30. type: {start: 'ISODate', end: 'ISODate' }
  31. });
  32. // create data
  33. function createData() {
  34. var count = parseInt(document.getElementById('count').value) || 100;
  35. var newData = [];
  36. var start = now;
  37. for (var i = 0; i < count; i++) {
  38. newData.push({id: i, content: 'item ' + i, start: start + 24*3600*1000 * i}); // much much faster than now.clone add days
  39. }
  40. items.clear();
  41. items.add(newData);
  42. }
  43. createData();
  44. document.getElementById('draw').onclick = createData;
  45. var container = document.getElementById('visualization');
  46. var options = {
  47. editable: true,
  48. start: now.clone().add(-3, 'days'),
  49. end: now.clone().add(11, 'days'),
  50. zoomMin: 1000 * 60 * 60 * 24, // a day
  51. zoomMax: 1000 * 60 * 60 * 24 * 30 * 3 // three months
  52. //maxHeight: 300,
  53. //height: '300px',
  54. //orientation: 'top'
  55. };
  56. var timeline = new vis.Timeline(container, items, options);
  57. </script>
  58. </body>
  59. </html>