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.

247 lines
5.4 KiB

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Timeline | Basic demo</title>
  5. <!-- load handlebars for templating, and create a template -->
  6. <script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0-alpha.4/handlebars.min.js"></script>
  7. <script id="item-template" type="text/x-handlebars-template">
  8. <table class="score">
  9. <tr>
  10. <td colspan="3" class="description">{{description}}</td>
  11. </tr>
  12. <tr>
  13. <td>{{player1}}</td>
  14. <th>{{score1}} - {{score2}}</th>
  15. <td>{{player2}}</td>
  16. </tr>
  17. <tr>
  18. <td><img src="http://flagpedia.net/data/flags/mini/{{abbr1}}.png" width="31" height="20" alt="{{abbr1}}"></td>
  19. <th></th>
  20. <td><img src="http://flagpedia.net/data/flags/mini/{{abbr2}}.png" width="31" height="20" alt="{{abbr2}}"></td>
  21. </tr>
  22. </table>
  23. </script>
  24. <script src="../../dist/vis.js"></script>
  25. <link href="../../dist/vis.css" rel="stylesheet" type="text/css" />
  26. <style type="text/css">
  27. body, html {
  28. font-family: sans-serif;
  29. font-size: 10pt;
  30. }
  31. .vis.timeline .item {
  32. border-color: #acacac;
  33. background-color: #efefef;
  34. box-shadow: 5px 5px 10px rgba(128,128,128, 0.3);
  35. }
  36. table .description {
  37. font-style: italic;
  38. }
  39. #visualization {
  40. position: relative;
  41. }
  42. .logo {
  43. position: absolute;
  44. right: 10px;
  45. top: 10px;
  46. }
  47. .logo img {
  48. width: 120px;
  49. }
  50. </style>
  51. </head>
  52. <body>
  53. <h1>WK 2014</h1>
  54. <p>
  55. This example demonstrates using templates to format item contents.
  56. </p>
  57. <div id="visualization">
  58. <div class="logo"><img src="http://upload.wikimedia.org/wikipedia/en/e/e8/WC-2014-Brasil.svg"></div>
  59. </div>
  60. <script type="text/javascript">
  61. // create a handlebars template
  62. var source = document.getElementById('item-template').innerHTML;
  63. var template = Handlebars.compile(document.getElementById('item-template').innerHTML);
  64. // DOM element where the Timeline will be attached
  65. var container = document.getElementById('visualization');
  66. // Create a DataSet (allows two way data-binding)
  67. var items = new vis.DataSet([
  68. {
  69. player1: 'Brazil',
  70. abbr1: 'br',
  71. score1: '1 (3)',
  72. player2: 'Chile',
  73. abbr2: 'cl',
  74. score2: '1 (2)',
  75. description: 'round of 16',
  76. start: '2014-06-28 13:00'
  77. },
  78. {
  79. player1: 'Colombia',
  80. abbr1: 'co',
  81. score1: 2,
  82. player2: 'Uruguay',
  83. abbr2: 'uy',
  84. score2: 0,
  85. description: 'round of 16',
  86. start: '2014-06-28 17:00'
  87. },
  88. {
  89. player1: 'Netherlands',
  90. abbr1: 'nl',
  91. score1: 2,
  92. player2: 'Mexico',
  93. abbr2: 'mx',
  94. score2: 1,
  95. description: 'round of 16',
  96. start: '2014-06-29 13:00'
  97. },
  98. {
  99. player1: 'Costa Rica',
  100. abbr1: 'cr',
  101. score1: '1 (5)',
  102. player2: 'Greece',
  103. abbr2: 'gr',
  104. score2: '1 (3)',
  105. description: 'round of 16',
  106. start: '2014-06-29 17:00'
  107. },
  108. {
  109. player1: 'France',
  110. abbr1: 'fr',
  111. score1: 2,
  112. player2: 'Nigeria',
  113. abbr2: 'ng',
  114. score2: 0,
  115. description: 'round of 16',
  116. start: '2014-06-30 13:00'
  117. },
  118. {
  119. player1: 'Germany',
  120. abbr1: 'de',
  121. score1: 2,
  122. player2: 'Algeria',
  123. abbr2: 'dz',
  124. score2: 1,
  125. description: 'round of 16',
  126. start: '2014-06-30 17:00'
  127. },
  128. {
  129. player1: 'Argentina',
  130. abbr1: 'ar',
  131. score1: 1,
  132. player2: 'Switzerland',
  133. abbr2: 'ch',
  134. score2: 0,
  135. description: 'round of 16',
  136. start: '2014-07-01 13:00'
  137. },
  138. {
  139. player1: 'Belgium',
  140. abbr1: 'be',
  141. score1: 2,
  142. player2: 'USA',
  143. abbr2: 'us',
  144. score2: 1,
  145. description: 'round of 16',
  146. start: '2014-07-01 17:00'
  147. },
  148. // quarter-finals
  149. {
  150. player1: 'France',
  151. abbr1: 'fr',
  152. score1: 0,
  153. player2: 'Germany',
  154. abbr2: 'de',
  155. score2: 1,
  156. description: 'quarter-finals',
  157. start: '2014-07-04 13:00'
  158. },
  159. {
  160. player1: 'Brazil',
  161. abbr1: 'br',
  162. score1: 2,
  163. player2: 'Colombia',
  164. abbr2: 'co',
  165. score2: 1,
  166. description: 'quarter-finals',
  167. start: '2014-07-04 17:00'
  168. },
  169. {
  170. player1: 'Argentina',
  171. abbr1: 'ar',
  172. score1: 1,
  173. player2: 'Belgium',
  174. abbr2: 'be',
  175. score2: 0,
  176. description: 'quarter-finals',
  177. start: '2014-07-05 13:00'
  178. },
  179. {
  180. player1: 'Netherlands',
  181. abbr1: 'nl',
  182. score1: '0 (4)',
  183. player2: 'Costa Rica',
  184. abbr2: 'cr',
  185. score2: '0 (3)',
  186. description: 'quarter-finals',
  187. start: '2014-07-05 17:00'
  188. },
  189. // semi-finals
  190. {
  191. player1: 'Brazil',
  192. abbr1: 'br',
  193. score1: 1,
  194. player2: 'Germany',
  195. abbr2: 'de',
  196. score2: 7,
  197. description: 'semi-finals',
  198. start: '2014-07-08 17:00'
  199. },
  200. {
  201. player1: 'Netherlands',
  202. abbr1: 'nl',
  203. score1: '0 (2)',
  204. player2: 'Argentina',
  205. abbr2: 'ar',
  206. score2: '0 (4)',
  207. description: 'semi-finals',
  208. start: '2014-07-09 17:00'
  209. },
  210. // final
  211. {
  212. player1: 'Germany',
  213. score1: 1,
  214. abbr1: 'de',
  215. player2: 'Argentina',
  216. abbr2: 'ar',
  217. score2: 0,
  218. description: 'final',
  219. start: '2014-07-13 16:00'
  220. }
  221. ]);
  222. // Configuration for the Timeline
  223. var options = {
  224. // specify a template for the items
  225. template: template
  226. };
  227. // Create a Timeline
  228. var timeline = new vis.Timeline(container, items, options);
  229. </script>
  230. </body>
  231. </html>