example17_json_data.html 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <html>
  2. <head>
  3. <title>Timeline JSON data</title>
  4. <style>
  5. body {
  6. font-size: 10pt;
  7. font-family: verdana, sans, arial;
  8. }
  9. </style>
  10. <script type="text/javascript" src="../timeline.js"></script>
  11. <link rel="stylesheet" type="text/css" href="../timeline.css">
  12. <script type="text/javascript">
  13. var timeline;
  14. var data;
  15. // Called when the Visualization API is loaded.
  16. function drawVisualization() {
  17. // Create a JSON data table
  18. data = [
  19. {
  20. 'start': new Date(2010,7,23),
  21. 'content': 'Conversation<br><img src="img/comments-icon.png" style="width:32px; height:32px;">'
  22. },
  23. {
  24. 'start': new Date(2010,7,23,23,0,0),
  25. 'content': 'Mail from boss<br><img src="img/mail-icon.png" style="width:32px; height:32px;">'
  26. },
  27. {
  28. 'start': new Date(2010,7,24,16,0,0),
  29. 'content': 'Report'
  30. },
  31. {
  32. 'start': new Date(2010,7,26),
  33. 'end': new Date(2010,8,2),
  34. 'content': 'Traject A'
  35. },
  36. {
  37. 'start': new Date(2010,7,28),
  38. 'content': 'Memo<br><img src="img/notes-edit-icon.png" style="width:48px; height:48px;">'
  39. },
  40. {
  41. 'start': new Date(2010,7,29),
  42. 'content': 'Phone call<br><img src="img/Hardware-Mobile-Phone-icon.png" style="width:32px; height:32px;">'
  43. },
  44. {
  45. 'start': new Date(2010,7,31),
  46. 'end': new Date(2010,8,3),
  47. 'content': 'Traject B'
  48. },
  49. {
  50. 'start': new Date(2010,8,4,12,0,0),
  51. 'content': 'Report<br><img src="img/attachment-icon.png" style="width:32px; height:32px;">'
  52. }
  53. ];
  54. // specify options
  55. var options = {
  56. 'width': '100%',
  57. 'height': '300px',
  58. 'editable': true, // enable dragging and editing events
  59. 'style': 'box'
  60. };
  61. // Instantiate our timeline object.
  62. timeline = new links.Timeline(document.getElementById('mytimeline'));
  63. function onRangeChanged(properties) {
  64. document.getElementById('info').innerHTML += 'rangechanged ' +
  65. properties.start + ' - ' + properties.end + '<br>';
  66. }
  67. // attach an event listener using the links events handler
  68. links.events.addListener(timeline, 'rangechanged', onRangeChanged);
  69. // Draw our timeline with the created data and options
  70. timeline.draw(data, options);
  71. }
  72. </script>
  73. </head>
  74. <body onload="drawVisualization();">
  75. <h1>Timeline JSON data</h1>
  76. <p>
  77. This demo shows how to feed the Timeline with JSON data.
  78. No Google DataTable is used, and therefore the Google JSAPI is
  79. not needed by the Timeline, which can thus be used offline.
  80. </p>
  81. <div id="mytimeline"></div>
  82. <!-- Information about where the used icons come from -->
  83. <p style="color:gray; font-size:10px; font-style:italic;">
  84. Icons by <a href="http://dryicons.com" target="_blank" title="Aesthetica 2 Icons by DryIcons" style="color:gray;" >DryIcons</a>
  85. and <a href="http://www.tpdkdesign.net" target="_blank" title="Refresh Cl Icons by TpdkDesign.net" style="color:gray;" >TpdkDesign.net</a>
  86. </p>
  87. <div id="info"></div>
  88. </body>
  89. </html>