example10_link_two_timelines.html 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <html>
  2. <head>
  3. <title>Timeline demo</title>
  4. <style>
  5. body {font: 10pt arial;}
  6. </style>
  7. <script type="text/javascript" src="http://www.google.com/jsapi"></script>
  8. <script type="text/javascript" src="../timeline.js"></script>
  9. <link rel="stylesheet" type="text/css" href="../timeline.css">
  10. <script type="text/javascript">
  11. google.load("visualization", "1");
  12. // Set callback to run when API is loaded
  13. google.setOnLoadCallback(drawVisualization);
  14. var vis1;
  15. var vis2;
  16. function createTimeline1() {
  17. // Create and populate a data table.
  18. var data1 = new google.visualization.DataTable();
  19. data1.addColumn('datetime', 'start');
  20. data1.addColumn('datetime', 'end');
  21. data1.addColumn('string', 'content');
  22. data1.addRows([
  23. [new Date(2010,07,23), , 'Conversation<br>' +
  24. '<img src="img/comments-icon.png" style="width:32px; height:32px;">'],
  25. [new Date(2010,07,23,23,00,00), , 'Mail from boss<br>' +
  26. '<img src="img/mail-icon.png" style="width:32px; height:32px;">'],
  27. [new Date(2010,07,24,16,00,00), , 'Report'],
  28. [new Date(2010,07,26), new Date(2010,08,02), 'Traject A'],
  29. [new Date(2010,07,28), , 'Memo<br>' +
  30. '<img src="img/notes-edit-icon.png" style="width:48px; height:48px;">'],
  31. [new Date(2010,07,29), , 'Phone call<br>' +
  32. '<img src="img/Hardware-Mobile-Phone-icon.png" style="width:32px; height:32px;">'],
  33. [new Date(2010,07,31), new Date(2010,08,03), 'Traject B'],
  34. [new Date(2010,08,01,12,00,00), , 'Report<br>' +
  35. '<img src="img/attachment-icon.png" style="width:32px; height:32px;">']
  36. ]);
  37. // specify options
  38. options1 = {width: "100%",
  39. height: "300px",
  40. layout: "box"
  41. };
  42. // Instantiate our timeline object.
  43. vis1 = new links.Timeline(document.getElementById('timeline1'));
  44. google.visualization.events.addListener(vis1, 'rangechange', onrangechange1);
  45. // Draw our timeline with the created data and options
  46. vis1.draw(data1, options1);
  47. }
  48. function createTimeline2() {
  49. // Create and populate a data table.
  50. var data2 = new google.visualization.DataTable();
  51. data2.addColumn('datetime', 'startdate');
  52. data2.addColumn('datetime', 'enddate');
  53. data2.addColumn('string', 'content');
  54. data2.addRows([
  55. [new Date(2010,07,23), new Date(2010,7,30), 'Traject C'],
  56. [new Date(2010,07,27), new Date(2010,07,31), 'Traject D']
  57. ]);
  58. // specify options
  59. options2 = {
  60. width: "100%",
  61. height: "300px",
  62. };
  63. // Instantiate our timeline object.
  64. vis2 = new links.Timeline(document.getElementById('timeline2'));
  65. google.visualization.events.addListener(vis2, 'rangechange', onrangechange2);
  66. // Draw our timeline with the created data and options
  67. vis2.draw(data2, options2);
  68. onrangechange1(); // to set the range equal initially
  69. }
  70. // Called when the Visualization API is loaded.
  71. function drawVisualization() {
  72. createTimeline1();
  73. createTimeline2();
  74. }
  75. function onrangechange1() {
  76. var range = vis1.getVisibleChartRange();
  77. vis2.setVisibleChartRange(range.start, range.end);
  78. }
  79. function onrangechange2() {
  80. var range = vis2.getVisibleChartRange();
  81. vis1.setVisibleChartRange(range.start, range.end);
  82. }
  83. </script>
  84. </head>
  85. <body>
  86. <p>When moving one timeline, the other moves along.</p>
  87. <div id="timeline1"></div>
  88. <br>
  89. <div id="timeline2"></div>
  90. <!-- Information about where the used icons come from -->
  91. <p style="color:gray; font-size:10px; font-style:italic;">
  92. Icons by <a href="http://dryicons.com" target="_blank" title="Aesthetica 2 Icons by DryIcons" style="color:gray;" >DryIcons</a>
  93. and <a href="http://www.tpdkdesign.net" target="_blank" title="Refresh Cl Icons by TpdkDesign.net" style="color:gray;" >TpdkDesign.net</a>
  94. </p>
  95. </body>
  96. </html>