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.

248 lines
5.4 KiB

  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Timeline | Templates</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. // round of 16
  69. {
  70. player1: 'Brazil',
  71. abbr1: 'br',
  72. score1: '1 (3)',
  73. player2: 'Chile',
  74. abbr2: 'cl',
  75. score2: '1 (2)',
  76. description: 'round of 16',
  77. start: '2014-06-28 13:00'
  78. },
  79. {
  80. player1: 'Colombia',
  81. abbr1: 'co',
  82. score1: 2,
  83. player2: 'Uruguay',
  84. abbr2: 'uy',
  85. score2: 0,
  86. description: 'round of 16',
  87. start: '2014-06-28 17:00'
  88. },
  89. {
  90. player1: 'Netherlands',
  91. abbr1: 'nl',
  92. score1: 2,
  93. player2: 'Mexico',
  94. abbr2: 'mx',
  95. score2: 1,
  96. description: 'round of 16',
  97. start: '2014-06-29 13:00'
  98. },
  99. {
  100. player1: 'Costa Rica',
  101. abbr1: 'cr',
  102. score1: '1 (5)',
  103. player2: 'Greece',
  104. abbr2: 'gr',
  105. score2: '1 (3)',
  106. description: 'round of 16',
  107. start: '2014-06-29 17:00'
  108. },
  109. {
  110. player1: 'France',
  111. abbr1: 'fr',
  112. score1: 2,
  113. player2: 'Nigeria',
  114. abbr2: 'ng',
  115. score2: 0,
  116. description: 'round of 16',
  117. start: '2014-06-30 13:00'
  118. },
  119. {
  120. player1: 'Germany',
  121. abbr1: 'de',
  122. score1: 2,
  123. player2: 'Algeria',
  124. abbr2: 'dz',
  125. score2: 1,
  126. description: 'round of 16',
  127. start: '2014-06-30 17:00'
  128. },
  129. {
  130. player1: 'Argentina',
  131. abbr1: 'ar',
  132. score1: 1,
  133. player2: 'Switzerland',
  134. abbr2: 'ch',
  135. score2: 0,
  136. description: 'round of 16',
  137. start: '2014-07-01 13:00'
  138. },
  139. {
  140. player1: 'Belgium',
  141. abbr1: 'be',
  142. score1: 2,
  143. player2: 'USA',
  144. abbr2: 'us',
  145. score2: 1,
  146. description: 'round of 16',
  147. start: '2014-07-01 17:00'
  148. },
  149. // quarter-finals
  150. {
  151. player1: 'France',
  152. abbr1: 'fr',
  153. score1: 0,
  154. player2: 'Germany',
  155. abbr2: 'de',
  156. score2: 1,
  157. description: 'quarter-finals',
  158. start: '2014-07-04 13:00'
  159. },
  160. {
  161. player1: 'Brazil',
  162. abbr1: 'br',
  163. score1: 2,
  164. player2: 'Colombia',
  165. abbr2: 'co',
  166. score2: 1,
  167. description: 'quarter-finals',
  168. start: '2014-07-04 17:00'
  169. },
  170. {
  171. player1: 'Argentina',
  172. abbr1: 'ar',
  173. score1: 1,
  174. player2: 'Belgium',
  175. abbr2: 'be',
  176. score2: 0,
  177. description: 'quarter-finals',
  178. start: '2014-07-05 13:00'
  179. },
  180. {
  181. player1: 'Netherlands',
  182. abbr1: 'nl',
  183. score1: '0 (4)',
  184. player2: 'Costa Rica',
  185. abbr2: 'cr',
  186. score2: '0 (3)',
  187. description: 'quarter-finals',
  188. start: '2014-07-05 17:00'
  189. },
  190. // semi-finals
  191. {
  192. player1: 'Brazil',
  193. abbr1: 'br',
  194. score1: 1,
  195. player2: 'Germany',
  196. abbr2: 'de',
  197. score2: 7,
  198. description: 'semi-finals',
  199. start: '2014-07-08 17:00'
  200. },
  201. {
  202. player1: 'Netherlands',
  203. abbr1: 'nl',
  204. score1: '0 (2)',
  205. player2: 'Argentina',
  206. abbr2: 'ar',
  207. score2: '0 (4)',
  208. description: 'semi-finals',
  209. start: '2014-07-09 17:00'
  210. },
  211. // final
  212. {
  213. player1: 'Germany',
  214. score1: 1,
  215. abbr1: 'de',
  216. player2: 'Argentina',
  217. abbr2: 'ar',
  218. score2: 0,
  219. description: 'final',
  220. start: '2014-07-13 16:00'
  221. }
  222. ]);
  223. // Configuration for the Timeline
  224. var options = {
  225. // specify a template for the items
  226. template: template
  227. };
  228. // Create a Timeline
  229. var timeline = new vis.Timeline(container, items, options);
  230. </script>
  231. </body>
  232. </html>