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.

65 lines
1.7 KiB

  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. for (var i = 0; i < count; i++) {
  37. newData.push({id: i, content: 'item ' + i, start: now.clone().add('days', i)});
  38. }
  39. items.clear();
  40. items.add(newData);
  41. }
  42. createData();
  43. document.getElementById('draw').onclick = createData;
  44. var container = document.getElementById('visualization');
  45. var options = {
  46. editable: true,
  47. start: now.clone().add('days', -3),
  48. end: now.clone().add('days', 11),
  49. zoomMin: 1000 * 60 * 60 * 24, // a day
  50. zoomMax: 1000 * 60 * 60 * 24 * 30 * 3 // three months
  51. //maxHeight: 300,
  52. //height: '300px',
  53. //orientation: 'top'
  54. };
  55. var timeline = new vis.Timeline(container, items, options);
  56. </script>
  57. </body>
  58. </html>