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.

64 lines
1.6 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. <script src="../../vis.js"></script>
  12. </head>
  13. <body>
  14. <h1>
  15. Test with a lot of data
  16. </h1>
  17. <p>
  18. <label for="count">Number of items</label>
  19. <input id="count" value="100">
  20. <input id="draw" type="button" value="draw">
  21. </p>
  22. <div id="visualization"></div>
  23. <script>
  24. // create a dataset with items
  25. var now = moment().minutes(0).seconds(0).milliseconds(0);
  26. var data = new vis.DataSet({
  27. fieldTypes: {
  28. start: 'Date',
  29. end: 'Date'
  30. }
  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. data.clear();
  40. data.add(newData);
  41. }
  42. createData();
  43. document.getElementById('draw').onclick = createData;
  44. var container = document.getElementById('visualization');
  45. var options = {
  46. start: now.clone().add('days', -3),
  47. end: now.clone().add('days', 11),
  48. zoomMin: 1000 * 60 * 60 * 24, // a day
  49. zoomMax: 1000 * 60 * 60 * 24 * 30 * 3 // three months
  50. //maxHeight: 300,
  51. //height: '300px',
  52. //orientation: 'top'
  53. };
  54. var timeline = new vis.Timeline(container, data, options);
  55. </script>
  56. </body>
  57. </html>