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.

74 lines
2.8 KiB

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