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

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="../../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="100">
  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. start: now.clone().add('days', -3),
  50. end: now.clone().add('days', 11),
  51. zoomMin: 1000 * 60 * 60 * 24, // a day
  52. zoomMax: 1000 * 60 * 60 * 24 * 30 * 3 // three months
  53. //maxHeight: 300,
  54. //height: '300px',
  55. //orientation: 'top'
  56. };
  57. var timeline = new vis.Timeline(container, items, options);
  58. </script>
  59. </body>
  60. </html>