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.

77 lines
2.9 KiB

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