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.

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