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.

70 lines
2.7 KiB

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