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.

120 lines
4.4 KiB

  1. <html>
  2. <head>
  3. <title>Timeline demo</title>
  4. <style type="text/css">
  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,7,23), , 'Conversation<br>' +
  24. '<img src="img/comments-icon.png" style="width:32px; height:32px;">'],
  25. [new Date(2010,7,23,23,0,0), , 'Mail from boss<br>' +
  26. '<img src="img/mail-icon.png" style="width:32px; height:32px;">'],
  27. [new Date(2010,7,24,16,0,0), , 'Report'],
  28. [new Date(2010,7,26), new Date(2010,8,2), 'Traject A'],
  29. [new Date(2010,7,28), , 'Memo<br>' +
  30. '<img src="img/notes-edit-icon.png" style="width:48px; height:48px;">'],
  31. [new Date(2010,7,29), , 'Phone call<br>' +
  32. '<img src="img/Hardware-Mobile-Phone-icon.png" style="width:32px; height:32px;">'],
  33. [new Date(2010,7,31), new Date(2010,8,3), 'Traject B'],
  34. [new Date(2010,8,1,12,0,0), , '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'), options1);
  44. google.visualization.events.addListener(vis1, 'rangechange', onrangechange1);
  45. // Draw our timeline with the created data and options
  46. vis1.draw(data1);
  47. }
  48. function createTimeline2() {
  49. // Create and populate a data table.
  50. var data2 = new google.visualization.DataTable();
  51. data2.addColumn('datetime', 'start');
  52. data2.addColumn('datetime', 'end');
  53. data2.addColumn('string', 'content');
  54. data2.addRows([
  55. [new Date(2010,7,23), new Date(2010,7,30), 'Traject C'],
  56. [new Date(2010,7,27), new Date(2010,7,31), 'Traject D']
  57. ]);
  58. // specify options
  59. var options2 = {
  60. width: "100%",
  61. height: "300px"
  62. };
  63. // Instantiate our timeline object.
  64. vis2 = new links.Timeline(document.getElementById('timeline2'), options2);
  65. google.visualization.events.addListener(vis2, 'rangechange', onrangechange2);
  66. // Draw our timeline with the created data and options
  67. vis2.draw(data2);
  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>