- <!DOCTYPE HTML>
- <html>
- <head>
- <title>Timeline | a lot of data</title>
-
- <style>
- body, html {
- font-family: arial, sans-serif;
- font-size: 11pt;
- }
- </style>
-
- <!-- note: moment.js must be loaded before vis.js, else vis.js uses its embedded version of moment.js -->
- <script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.4/moment.min.js"></script>
-
- <script src="../../dist/vis.js"></script>
- <link href="../../dist/vis.css" rel="stylesheet" type="text/css" />
- <script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-61231638-1', 'auto');ga('send', 'pageview');</script></head>
- <body>
- <h1>
- Test with a lot of data
- </h1>
- <p>
- <label for="count">Number of items</label>
- <input id="count" value="10000">
- <input id="draw" type="button" value="draw">
- </p>
- <div id="visualization"></div>
-
- <script>
- // create a dataset with items
- var now = moment().minutes(0).seconds(0).milliseconds(0);
- var items = new vis.DataSet({
- type: {start: 'ISODate', end: 'ISODate' }
- });
-
- // create data
- function createData() {
- var count = parseInt(document.getElementById('count').value) || 100;
- var newData = [];
- var start = now;
- for (var i = 0; i < count; i++) {
- newData.push({id: i, content: 'item ' + i, start: start + 24*3600*1000 * i}); // much much faster than now.clone add days
- }
- items.clear();
- items.add(newData);
- }
- createData();
-
- document.getElementById('draw').onclick = createData;
-
- var container = document.getElementById('visualization');
- var options = {
- editable: true,
- start: now.clone().add(-3, 'days'),
- end: now.clone().add(11, 'days'),
- zoomMin: 1000 * 60 * 60 * 24, // a day
- zoomMax: 1000 * 60 * 60 * 24 * 30 * 3 // three months
- };
-
- var timeline = new vis.Timeline(container, items, options);
- </script>
- </body>
- </html>
|