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.

67 lines
1.8 KiB

11 years ago
11 years ago
11 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="../../vis.js"></script>
  14. </head>
  15. <body>
  16. <h1>
  17. Test with a lot of data
  18. </h1>
  19. <p>
  20. <label for="count">Number of items</label>
  21. <input id="count" value="100">
  22. <input id="draw" type="button" value="draw">
  23. </p>
  24. <div id="visualization"></div>
  25. <script>
  26. // create a dataset with items
  27. var now = moment().minutes(0).seconds(0).milliseconds(0);
  28. var items = new vis.DataSet({
  29. convert: {
  30. start: 'Date',
  31. end: 'Date'
  32. }
  33. });
  34. // create data
  35. function createData() {
  36. var count = parseInt(document.getElementById('count').value) || 100;
  37. var newData = [];
  38. for (var i = 0; i < count; i++) {
  39. newData.push({id: i, content: 'item ' + i, start: now.clone().add('days', i)});
  40. }
  41. items.clear();
  42. items.add(newData);
  43. }
  44. createData();
  45. document.getElementById('draw').onclick = createData;
  46. var container = document.getElementById('visualization');
  47. var options = {
  48. start: now.clone().add('days', -3),
  49. end: now.clone().add('days', 11),
  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>