| <!DOCTYPE HTML> | |
| <html> | |
| <head> | |
|   <title></title> | |
|   <script src="../node_modules/moment/moment.js"></script> | |
|   <script src="../node_modules/moment/locale/nl.js"></script> | |
|   <script> | |
|     moment.locale('nl'); | |
|   </script> | |
|   <script src="../dist/vis.js"></script> | |
|   <link href="../dist/vis.css" rel="stylesheet" type="text/css" /> | |
| 
 | |
|   <style type="text/css"> | |
|     body, html { | |
|       font-family: sans-serif; | |
|       font-size: 11pt; | |
|     } | |
| 
 | |
|     #visualization .itemset { | |
|       /*background: rgba(255, 255, 0, 0.5);*/ | |
|     } | |
| 
 | |
|     .vis-timeline .vis-item.vis-range .vis-drag-left, | |
|     .vis-timeline .vis-item.vis-range .vis-drag-right { | |
|       /*width: 40px;*/ | |
|       background: rgba(255,0,0,0.5); | |
|     } | |
| 
 | |
|     #visualization .vis-grid.vis-vertical.vis-odd { | |
|       background: #f5f5f5; | |
|     } | |
| 
 | |
|     #visualization .vis-grid.vis-vertical.vis-saturday, | |
|     #visualization .vis-grid.vis-vertical.vis-sunday { | |
|       background: gray; | |
|     } | |
| 
 | |
|     #visualization .vis-text.vis-saturday, | |
|     #visualization .vis-text.vis-sunday { | |
|       color: white; | |
|     } | |
|   </style> | |
| 
 | |
|   <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> | |
| 
 | |
| <p> | |
|   <label for="orientation">Orientation</label> | |
|   <select id="orientation"> | |
|     <option value="both" selected>both</option> | |
|     <option value="bottom">bottom</option> | |
|     <option value="none">none</option> | |
|     <option value="top">top</option> | |
|   </select> | |
| </p> | |
| <p> | |
|   <label for="align">Content alignment</label> | |
|   <select id="align"> | |
|     <option value="auto" selected>auto</option> | |
|     <option value="center">center</option> | |
|     <option value="left">left</option> | |
|     <option value="right">right</option> | |
|   </select> | |
| </p> | |
| <script> | |
|   var o = document.getElementById('orientation'); | |
|   o.onchange = function () { | |
|     timeline.setOptions({ | |
|       orientation: o.value | |
|     }); | |
|   }; | |
| 
 | |
|   var a = document.getElementById('align'); | |
|   a.onchange = function () { | |
|     timeline.setOptions({ | |
|       align: a.value | |
|     }); | |
|   }; | |
| 
 | |
| </script> | |
| 
 | |
| <p> | |
|   <label for="currenttime"><input id="currenttime" type="checkbox" checked="true"> Show current time</label> | |
| </p> | |
| <script> | |
|   var currenttime = document.getElementById('currenttime'); | |
|   currenttime.onchange = function () { | |
|     timeline.setOptions({ | |
|       showCurrentTime: currenttime.checked | |
|     }); | |
|   }; | |
| </script> | |
| 
 | |
| <br> | |
| 
 | |
| <div id="visualization"></div> | |
| <div style="height: 1000px;"></div><!-- for testing vertical scroll on touch devices--> | |
| 
 | |
| <script> | |
|   console.time('create dataset'); | |
| 
 | |
|   // create a dataset with items | |
|   var now = moment().minutes(0).seconds(0).milliseconds(0); | |
|   var items = new vis.DataSet({ | |
|     type: { | |
|       start: 'ISODate', | |
|       end: 'ISODate' | |
|     }, | |
|     fieldId: '_id' | |
|   }); | |
| 
 | |
|   var someHtml = document.createElement('div'); | |
|   someHtml.innerHTML = 'Click <a href="javascript: alert(\'you clicked an anchor\');">here <span style="color: green;">or here</span></a><br><button onclick="alert(\'click\')">Click me</button>'; | |
| 
 | |
| 
 | |
|   items.add([ | |
|     {_id: 0, content: someHtml, start: now.clone().add(3, 'days').toDate(), title: 'hello title!'}, | |
|     {_id: '1', content: 'item 1<br>start', start: now.clone().add(4, 'days').toDate()}, | |
|     {_id: 2, content: '<a href="javascript: alert(\'you clicked an anchor\');">Click here! (anchor)</a><br><br>' + | |
|     '<div onclick="alert(\'you clicked a div\');   ">Click here! (div)</div>', start: now.clone().add(-2, 'days').toDate() }, | |
|     {_id: 3, content: 'item 3', start: now.clone().add(2, 'days').toDate(), style: 'color: red;'}, | |
|     { | |
|       _id: 4, content: 'item 4 foo bar foo bar foo bar foo bar foo bar', | |
|       start: now.clone().add(0, 'days').toDate(), | |
|       end: now.clone().add(7, 'days').toDate(), | |
|       title: 'hello title!' | |
|     }, | |
|     { | |
|       _id: 4.1, content: 'item 4.1 test overflow foo bar foo bar foo bar', | |
|       start: now.clone().add(0, 'days').toDate(), | |
|       end: now.clone().add(1, 'days').toDate(), | |
|       title: 'hello title!' | |
|     }, | |
|     { | |
|       _id: 4.2, content: 'item 4.2 test overflow foo bar foo bar foo bar', | |
|       start: now.clone().add(1, 'days').toDate(), | |
|       end: now.clone().add(1, 'days').add(1, 'minutes').toDate(), | |
|       title: 'hello title!' | |
|     }, | |
|     {_id: 5, content: 'item 5', start: now.clone().add(9, 'days').toDate(), type:'point', title: 'hello title!', className: 'special'}, | |
|     {_id: 6, content: 'item 6 very long test bla bla bla', start: now.clone().add(11, 'days').toDate()} | |
|   ]); | |
| 
 | |
|   var container = document.getElementById('visualization'); | |
|   var options = { | |
|     configure: true, | |
|     multiselect: true, | |
|     editable: true, | |
|     //orientation: 'top', | |
|     orientation: 'both', | |
| //    start: now.clone().add(-7, 'days'), | |
| //    end: now.clone().add(7, 'days'), | |
|     //maxHeight: 200, | |
|     //height: 200, | |
|     showCurrentTime: true, | |
|     format: { | |
|       minorLabels: { | |
|         'weekday':    'dddd D', | |
|         'month': 'MMMM' | |
|       }, | |
|       majorLabels: { | |
|         'minute':     'dddd D MMMM', | |
|         'hour':       'dddd D MMMM' | |
|       } | |
|     }, | |
|     snap: null, | |
| //    timeAxis: { | |
| //      scale: 'hour', | |
| //      step: 2 | |
| //    } | |
|     //clickToUse: true, | |
|     //min: moment('2013-01-01'), | |
|     //max: moment('2013-12-31'), | |
|     //zoomMin: 1000 * 60 * 60 * 24,            // 1 day | |
| //    zoomMax: 1000 * 60 * 60 * 24 * 30 * 6     // 6 months | |
|   }; | |
| 
 | |
|   console.timeEnd('create dataset'); | |
| 
 | |
|   console.time('create timeline'); | |
|   var timeline = new vis.Timeline(container, items, options); | |
|   console.timeEnd('create timeline'); | |
| 
 | |
|   timeline.addCustomTime(moment().add(1, 'day')); | |
| 
 | |
|   timeline.on('select', function (selection) { | |
|     console.log('select', selection); | |
|   }); | |
| 
 | |
|   timeline.on('click', function (props) { | |
|     console.log('click', props); | |
|   }); | |
| 
 | |
|   timeline.on('contextmenu', function (props) { | |
|     console.log('contextmenu', props); | |
|   }); | |
| 
 | |
|   //  timeline.on('touch', function (event) { | |
|   //    console.log('touch', event, Object.keys(event)); | |
|   //  }); | |
|   // | |
|   //  timeline.on('release', function (event) { | |
|   //    console.log('release', event, Object.keys(event)); | |
|   //  }); | |
|  | |
|   /* | |
|    timeline.on('rangechange', function (range) { | |
|    console.log('rangechange', range); | |
|    }); | |
|    timeline.on('rangechanged', function (range) { | |
|    console.log('rangechanged', range); | |
|    }); | |
|    */ | |
| 
 | |
|   items.on('add',    console.log.bind(console)); | |
|   items.on('update', console.log.bind(console)); | |
|   items.on('remove', console.log.bind(console)); | |
| 
 | |
| </script> | |
| </body> | |
| </html> |