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.

78 lines
2.9 KiB

11 years ago
11 years ago
11 years ago
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title></title>
  5. <script src="../lib/moment.min.js"></script>
  6. <script src="../src/module.js"></script>
  7. <script src="../src/util.js"></script>
  8. <script src="../src/events.js"></script>
  9. <script src="../src/range.js"></script>
  10. <script src="../src/timestep.js"></script>
  11. <script src="../src/dataset.js"></script>
  12. <script type="text/javascript" src="http://www.google.com/jsapi"></script>
  13. </head>
  14. <body>
  15. <script>
  16. var dataset = new vis.DataSet({
  17. fieldId: 'id',
  18. fieldTypes: {
  19. start: 'ISODate'
  20. }
  21. });
  22. // create an anonymous event listener
  23. dataset.subscribe('*', function (event, params, id) {
  24. console.log('anonymous listener ', event, params, id);
  25. });
  26. // create a named event listener
  27. var entityId = '123';
  28. dataset.subscribe('*', function (event, params, id) {
  29. console.log('named listener ', event, params, id);
  30. }, entityId);
  31. // anonymous put
  32. dataset.add([
  33. {id: 1, content: 'item 1', start: new Date()},
  34. {id: 2, content: 'item 2', start: (new Date()).valueOf()},
  35. {id: '3', content: 'item 3', start: (new Date()).toISOString()},
  36. {id: 4, content: 'item 4', start: '/Date(1198908717056)/'},
  37. {id: 5, content: 'item 5', start: undefined},
  38. {content: 'item 6', start: new Date()}
  39. ]);
  40. // named update
  41. dataset.update([
  42. {id: 1, foo: 'bar'}
  43. ], entityId);
  44. google.load("visualization", "1");
  45. google.setOnLoadCallback(function () {
  46. var table = new google.visualization.DataTable();
  47. table.addColumn('datetime', 'start');
  48. table.addColumn('datetime', 'end');
  49. table.addColumn('string', 'content');
  50. table.addRows([
  51. [new Date(2010,7,23), , 'Conversation<br>' +
  52. '<img src="img/comments-icon.png" style="width:32px; height:32px;">'],
  53. [new Date(2010,7,23,23,0,0), , 'Mail from boss<br>' +
  54. '<img src="img/mail-icon.png" style="width:32px; height:32px;">'],
  55. [new Date(2010,7,24,16,0,0), , 'Report'],
  56. [new Date(2010,7,26), new Date(2010,8,2), 'Traject A'],
  57. [new Date(2010,7,28), , 'Memo<br>' +
  58. '<img src="img/notes-edit-icon.png" style="width:48px; height:48px;">'],
  59. [new Date(2010,7,29), , 'Phone call<br>' +
  60. '<img src="img/Hardware-Mobile-Phone-icon.png" style="width:32px; height:32px;">'],
  61. [new Date(2010,7,31), new Date(2010,8,3), 'Traject B'],
  62. [new Date(2010,8,4,12,0,0), , 'Report<br>' +
  63. '<img src="img/attachment-icon.png" style="width:32px; height:32px;">']
  64. ]);
  65. dataset.add(table);
  66. });
  67. </script>
  68. </body>
  69. </html>