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.

1450 lines
47 KiB

10 years ago
  1. <html>
  2. <head>
  3. <title>vis.js | timeline documentation</title>
  4. <link href='css/prettify.css' type='text/css' rel='stylesheet'>
  5. <link href='css/style.css' type='text/css' rel='stylesheet'>
  6. <script type="text/javascript" src="lib/prettify/prettify.js"></script>
  7. </head>
  8. <body onload="prettyPrint();">
  9. <div id="container">
  10. <h1>Timeline documentation</h1>
  11. <h2 id="Overview">Overview</h2>
  12. <p>
  13. The Timeline is an interactive visualization chart to visualize data in time.
  14. The data items can take place on a single date, or have a start and end date (a range).
  15. You can freely move and zoom in the timeline by dragging and scrolling in the
  16. Timeline. Items can be created, edited, and deleted in the timeline.
  17. The time scale on the axis is adjusted automatically, and supports scales ranging
  18. from milliseconds to years.
  19. </p>
  20. <p>
  21. Timeline uses regular HTML DOM to render the timeline and items put on the
  22. timeline. This allows for flexible customization using css styling.
  23. </p>
  24. <h2 id="Contents">Contents</h2>
  25. <ul>
  26. <li><a href="#Overview">Overview</a></li>
  27. <li><a href="#Example">Example</a></li>
  28. <li><a href="#Loading">Loading</a></li>
  29. <li><a href="#Data_Format">Data Format</a>
  30. <ul>
  31. <li><a href="#items">Items</a></li>
  32. <li><a href="#groups">Groups</a></li>
  33. </ul>
  34. </li>
  35. <li><a href="#Configuration_Options">Configuration Options</a></li>
  36. <li><a href="#Methods">Methods</a></li>
  37. <li><a href="#Events">Events</a></li>
  38. <li><a href="#Editing_Items">Editing Items</a></li>
  39. <li><a href="#Templates">Templates</a></li>
  40. <li><a href="#Localization">Localization</a></li>
  41. <li><a href="#Styles">Styles</a></li>
  42. <li><a href="#Data_Policy">Data Policy</a></li>
  43. </ul>
  44. <h2 id="Example">Example</h2>
  45. <p>
  46. The following code shows how to create a Timeline and provide it with data.
  47. More examples can be found in the <a href="../examples">examples</a> directory.
  48. </p>
  49. <pre class="prettyprint lang-html">&lt;!DOCTYPE HTML&gt;
  50. &lt;html&gt;
  51. &lt;head&gt;
  52. &lt;title&gt;Timeline | Basic demo&lt;/title&gt;
  53. &lt;style type="text/css"&gt;
  54. body, html {
  55. font-family: sans-serif;
  56. }
  57. &lt;/style&gt;
  58. &lt;script src="../../dist/vis.js"&gt;&lt;/script&gt;
  59. &lt;link href="../../dist/vis.css" rel="stylesheet" type="text/css" /&gt;
  60. &lt;/head&gt;
  61. &lt;body&gt;
  62. &lt;div id="visualization"&gt;&lt;/div&gt;
  63. &lt;script type="text/javascript"&gt;
  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. {id: 1, content: 'item 1', start: '2013-04-20'},
  69. {id: 2, content: 'item 2', start: '2013-04-14'},
  70. {id: 3, content: 'item 3', start: '2013-04-18'},
  71. {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
  72. {id: 5, content: 'item 5', start: '2013-04-25'},
  73. {id: 6, content: 'item 6', start: '2013-04-27'}
  74. ]);
  75. // Configuration for the Timeline
  76. var options = {};
  77. // Create a Timeline
  78. var timeline = new vis.Timeline(container, items, options);
  79. &lt;/script&gt;
  80. &lt;/body&gt;
  81. &lt;/html&gt;
  82. </pre>
  83. <h2 id="Loading">Loading</h2>
  84. <p>
  85. Install or download the <a href="http://visjs.org" target="_blank">vis.js</a> library.
  86. in a subfolder of your project. Include the libraries script and css files in the
  87. head of your html code:
  88. </p>
  89. <pre class="prettyprint lang-html">
  90. &lt;script src="vis/dist/vis.js"&gt;&lt;/script&gt;
  91. &lt;link href="vis/dist/vis.css" rel="stylesheet" type="text/css" /&gt;
  92. </pre>
  93. The constructor of the Timeline is <code>vis.Timeline</code>
  94. <pre class="prettyprint lang-js">var timeline = new vis.Timeline(container, items, options);</pre>
  95. or when using groups:
  96. <pre class="prettyprint lang-js">var timeline = new vis.Timeline(container, items, groups, options);</pre>
  97. The constructor accepts four parameters:
  98. <ul>
  99. <li>
  100. <code>container</code> is the DOM element in which to create the timeline.
  101. </li>
  102. <li>
  103. <code>items</code> is an Array containing items. The properties of an
  104. item are described in section <a href="#Data_Format">Data Format, items</a>.
  105. </li><li>
  106. <code>groups</code> is an Array containing groups. The properties of a
  107. group are described in section <a href="#groups">Data Format, groups</a>.
  108. </li>
  109. <li>
  110. <code>options</code> is an optional Object containing a name-value map
  111. with options. Options can also be set using the method
  112. <code>setOptions</code>.
  113. </li>
  114. </ul>
  115. <h2 id="Data_Format">Data Format</h2>
  116. <p>
  117. The timeline can be provided with two types of data:
  118. </p>
  119. <ul>
  120. <li><a href="#items">Items</a> containing a set of items to be displayed in time.</li>
  121. <li><a href="#groups">Groups</a> containing a set of groups used to group items
  122. together.</li>
  123. </ul>
  124. <h3 id="items">Items</h3>
  125. <p>
  126. The Timeline uses regular Arrays and Objects as data format.
  127. Data items can contain the properties <code>start</code>,
  128. <code>end</code> (optional), <code>content</code>,
  129. <code>group</code> (optional), <code>className</code> (optional),
  130. and <code>style</code> (optional).
  131. </p>
  132. <p>
  133. A table is constructed as:
  134. </p>
  135. <pre class="prettyprint lang-js">
  136. var items = [
  137. {
  138. start: new Date(2010, 7, 15),
  139. end: new Date(2010, 8, 2), // end is optional
  140. content: 'Trajectory A'
  141. // Optional: fields 'id', 'type', 'group', 'className', 'style'
  142. }
  143. // more items...
  144. ]);
  145. </pre>
  146. <p>
  147. The item properties are defined as:
  148. </p>
  149. <table>
  150. <tr>
  151. <th>Name</th>
  152. <th>Type</th>
  153. <th>Required</th>
  154. <th>Description</th>
  155. </tr>
  156. <tr>
  157. <td>className</td>
  158. <td>String</td>
  159. <td>no</td>
  160. <td>This field is optional. A className can be used to give items
  161. an individual css style. For example, when an item has className
  162. 'red', one can define a css style like:
  163. <pre class="prettyprint lang-css">
  164. .vis.timeline .red {
  165. color: white;
  166. background-color: red;
  167. border-color: darkred;
  168. }</pre>
  169. More details on how to style items can be found in the section
  170. <a href="#Styles">Styles</a>.
  171. </td>
  172. </tr>
  173. <tr>
  174. <td>content</td>
  175. <td>String</td>
  176. <td>yes</td>
  177. <td>The contents of the item. This can be plain text or html code.</td>
  178. </tr>
  179. <tr>
  180. <td>end</td>
  181. <td>Date</td>
  182. <td>no</td>
  183. <td>The end date of the item. The end date is optional, and can be left <code>null</code>.
  184. If end date is provided, the item is displayed as a range.
  185. If not, the item is displayed as a box.</td>
  186. </tr>
  187. <tr>
  188. <td>group</td>
  189. <td>any type</td>
  190. <td>no</td>
  191. <td>This field is optional. When the group column is provided,
  192. all items with the same group are placed on one line.
  193. A vertical axis is displayed showing the groups.
  194. Grouping items can be useful for example when showing availability of multiple
  195. people, rooms, or other resources next to each other.<br>
  196. </td>
  197. </tr>
  198. <tr>
  199. <td>id</td>
  200. <td>String | Number</td>
  201. <td>no</td>
  202. <td>An id for the item. Using an id is not required but highly
  203. recommended. An id is needed when dynamically adding, updating,
  204. and removing items in a DataSet.</td>
  205. </tr>
  206. <tr>
  207. <td>start</td>
  208. <td>Date</td>
  209. <td>yes</td>
  210. <td>The start date of the item, for example <code>new Date(2010,9,23)</code>.</td>
  211. </tr>
  212. <tr>
  213. <td>style</td>
  214. <td>String</td>
  215. <td>no</td>
  216. <td>
  217. A css text string to apply custom styling for an individual item, for
  218. example <code>"color: red; background-color: pink;"</code>.
  219. </td>
  220. </tr>
  221. <tr>
  222. <td>subgroup</td>
  223. <td>String | Number</td>
  224. <td>none</td>
  225. <td>The id of a subgroup.
  226. Groups all items within a group per subgroup, and positions them on the
  227. same height instead of staking them on top of each other. can be ordered
  228. by specifying the option <code>subgroupOrder</code> of a group.
  229. </td>
  230. </tr>
  231. <tr>
  232. <td>title</td>
  233. <td>String</td>
  234. <td>none</td>
  235. <td>Add a title for the item, displayed when holding the mouse on the item.
  236. The title can only contain plain text.
  237. </td>
  238. </tr>
  239. <tr>
  240. <td>type</td>
  241. <td>String</td>
  242. <td>'box'</td>
  243. <td>The type of the item. Can be 'box' (default), 'point', 'range', or 'background'.
  244. Types 'box' and 'point' need a start date, the types 'range' and 'background' needs both a start and end date.
  245. </td>
  246. </tr>
  247. </table>
  248. <h3 id="groups">Groups</h3>
  249. <p>
  250. Like the items, groups are regular JavaScript Arrays and Objects.
  251. Using groups, items can be grouped together.
  252. Items are filtered per group, and displayed as
  253. Group items can contain the properties <code>id</code>,
  254. <code>content</code>, and <code>className</code> (optional).
  255. </p>
  256. <p>
  257. Groups can be applied to a timeline using the method <code>setGroups</code> or supplied in the constructor.
  258. A table with groups can be created like:
  259. </p>
  260. <pre class="prettyprint lang-js">
  261. var groups = [
  262. {
  263. id: 1,
  264. content: 'Group 1'
  265. // Optional: a field 'className', 'style'
  266. }
  267. // more groups...
  268. ]);
  269. </pre>
  270. <p>
  271. Groups can have the following properties:
  272. </p>
  273. <table>
  274. <tr>
  275. <th>Name</th>
  276. <th>Type</th>
  277. <th>Required</th>
  278. <th>Description</th>
  279. </tr>
  280. <tr>
  281. <td>className</td>
  282. <td>String</td>
  283. <td>no</td>
  284. <td>This field is optional. A className can be used to give groups
  285. an individual css style. For example, when a group has className
  286. 'red', one can define a css style
  287. <code>
  288. .red {
  289. color: red;
  290. }
  291. </code>.
  292. More details on how to style groups can be found in the section
  293. <a href="#Styles">Styles</a>.
  294. </td>
  295. </tr>
  296. <tr>
  297. <td>content</td>
  298. <td>String</td>
  299. <td>yes</td>
  300. <td>The contents of the group. This can be plain text or html code.</td>
  301. </tr>
  302. <tr>
  303. <td>id</td>
  304. <td>String | Number</td>
  305. <td>yes</td>
  306. <td>An id for the group. The group will display all items having a
  307. property <code>group</code> which matches the <code>id</code>
  308. of the group.</td>
  309. </tr>
  310. <tr>
  311. <td>style</td>
  312. <td>String</td>
  313. <td>no</td>
  314. <td>
  315. A css text string to apply custom styling for an individual group label, for
  316. example <code>"color: red; background-color: pink;"</code>.
  317. </td>
  318. </tr>
  319. <tr>
  320. <td>subgroupOrder</td>
  321. <td>String | Function</td>
  322. <td>none</td>
  323. <td>Order the subgroups by a field name or custom sort function.
  324. By default, groups are ordered by first-come, first-show.
  325. </td>
  326. </tr>
  327. <tr>
  328. <td>title</td>
  329. <td>String</td>
  330. <td>none</td>
  331. <td>A title for the group, displayed when holding the mouse on the groups label.
  332. The title can only contain plain text.
  333. </td>
  334. </tr>
  335. </table>
  336. <h2 id="Configuration_Options">Configuration Options</h2>
  337. <p>
  338. Options can be used to customize the timeline.
  339. Options are defined as a JSON object. All options are optional.
  340. </p>
  341. <pre class="prettyprint lang-js">
  342. var options = {
  343. width: '100%',
  344. height: '30px',
  345. margin: {
  346. item: 20
  347. }
  348. };
  349. </pre>
  350. <p>
  351. The following options are available.
  352. </p>
  353. <table>
  354. <tr>
  355. <th>Name</th>
  356. <th>Type</th>
  357. <th>Default</th>
  358. <th>Description</th>
  359. </tr>
  360. <tr>
  361. <td>align</td>
  362. <td>String</td>
  363. <td>"center"</td>
  364. <td>Alignment of items with type 'box', 'range', and 'background'. Available values are 'auto' (default), 'center', 'left', or 'right'. For 'box' items, the 'auto' alignment is 'center'. For 'range' items, the auto alignment is dynamic: positioned left and shifted such that the contents is always visible on screen.</td>
  365. </tr>
  366. <tr>
  367. <td>autoResize</td>
  368. <td>boolean</td>
  369. <td>true</td>
  370. <td>If true, the Timeline will automatically detect when its container is resized, and redraw itself accordingly. If false, the Timeline can be forced to repaint after its container has been resized using the function <code>redraw()</code>.</td>
  371. </tr>
  372. <tr>
  373. <td>clickToUse</td>
  374. <td>boolean</td>
  375. <td>false</td>
  376. <td>When a Timeline is configured to be <code>clickToUse</code>, it will react to mouse and touch events only when active.
  377. When active, a blue shadow border is displayed around the Timeline. The Timeline is set active by clicking on it, and is changed to inactive again by clicking outside the Timeline or by pressing the ESC key.</td>
  378. </tr>
  379. <tr>
  380. <td>dataAttributes</td>
  381. <td>Array[String] | 'all'</td>
  382. <td>false</td>
  383. <td>An array of fields optionally defined on the timeline items that will be appended as <code>data-</code> attributes to the DOM element of the items.<br>
  384. If value is <code>'all'</code> then each field defined on the timeline item will become a <code>data-</code> attribute.</td>
  385. </tr>
  386. <tr>
  387. <td>editable</td>
  388. <td>Boolean | Object</td>
  389. <td>false</td>
  390. <td>If true, the items in the timeline can be manipulated. Only applicable when option <code>selectable</code> is <code>true</code>. See also the callbacks <code>onAdd</code>, <code>onUpdate</code>, <code>onMove</code>, and <code>onRemove</code>. When <code>editable</code> is an object, one can enable or disable individual manipulation actions.
  391. See section <a href="#Editing_Items">Editing Items</a> for a detailed explanation.
  392. </td>
  393. </tr>
  394. <tr>
  395. <td>editable.add</td>
  396. <td>Boolean</td>
  397. <td>false</td>
  398. <td>If true, new items can be created by double tapping an empty space in the Timeline. See section <a href="#Editing_Items">Editing Items</a> for a detailed explanation.</td>
  399. </tr>
  400. <tr>
  401. <td>editable.remove</td>
  402. <td>Boolean</td>
  403. <td>false</td>
  404. <td>If true, items can be deleted by first selecting them, and then clicking the delete button on the top right of the item. See section <a href="#Editing_Items">Editing Items</a> for a detailed explanation.</td>
  405. </tr>
  406. <tr>
  407. <td>editable.updateGroup</td>
  408. <td>Boolean</td>
  409. <td>false</td>
  410. <td>If true, items can be dragged from one group to another. Only applicable when the Timeline has groups. See section <a href="#Editing_Items">Editing Items</a> for a detailed explanation.</td>
  411. </tr>
  412. <tr>
  413. <td>editable.updateTime</td>
  414. <td>Boolean</td>
  415. <td>false</td>
  416. <td>If true, items can be dragged to another moment in time. See section <a href="#Editing_Items">Editing Items</a> for a detailed explanation.</td>
  417. </tr>
  418. <tr>
  419. <td>end</td>
  420. <td>Date | Number | String</td>
  421. <td>none</td>
  422. <td>The initial end date for the axis of the timeline.
  423. If not provided, the latest date present in the items set is taken as
  424. end date.</td>
  425. </tr>
  426. <tr>
  427. <td>format</td>
  428. <td>Object</td>
  429. <td>none</td>
  430. <td>
  431. Apply custom date formatting of the labels on the time axis. The default value of <code>format</code> is:
  432. <pre class="prettyprint lang-js">{
  433. minorLabels: {
  434. millisecond:'SSS',
  435. second: 's',
  436. minute: 'HH:mm',
  437. hour: 'HH:mm',
  438. weekday: 'ddd D',
  439. day: 'D',
  440. month: 'MMM',
  441. year: 'YYYY'
  442. },
  443. majorLabels: {
  444. millisecond:'HH:mm:ss',
  445. second: 'D MMMM HH:mm',
  446. minute: 'ddd D MMMM',
  447. hour: 'ddd D MMMM',
  448. weekday: 'MMMM YYYY',
  449. day: 'MMMM YYYY',
  450. month: 'YYYY',
  451. year: ''
  452. }
  453. }</pre>
  454. For values which not provided in the customized <code>options.format</code>, the default values will be used.
  455. All available formatting syntax is described in the <a href="http://momentjs.com/docs/#/displaying/format/">docs of moment.js</a>.
  456. </td>
  457. </tr>
  458. <tr>
  459. <td>groupOrder</td>
  460. <td>String | Function</td>
  461. <td>none</td>
  462. <td>Order the groups by a field name or custom sort function.
  463. By default, groups are not ordered.
  464. </td>
  465. </tr>
  466. <tr>
  467. <td>height</td>
  468. <td>Number | String</td>
  469. <td>none</td>
  470. <td>The height of the timeline in pixels or as a percentage.
  471. When height is undefined or null, the height of the timeline is automatically
  472. adjusted to fit the contents.
  473. It is possible to set a maximum height using option <code>maxHeight</code>
  474. to prevent the timeline from getting too high in case of automatically
  475. calculated height.
  476. </td>
  477. </tr>
  478. <tr>
  479. <td>hiddenDates</td>
  480. <td>Object</td>
  481. <td>none</td>
  482. <td>This option allows you to hide specific timespans from the time axis. The dates can be supplied as an object:
  483. <code>{start: '2014-03-21 00:00:00', end: '2014-03-28 00:00:00', [repeat:'daily']}</code> or as an Array of these objects. The repeat argument is optional.
  484. The possible values are (case-sensitive): <code>daily, weekly, monthly, yearly</code>. To hide a weekend, pick any Saturday as start and the following Monday as end
  485. and set repeat to weekly.
  486. </td>
  487. </tr>
  488. <tr>
  489. <td>locale</td>
  490. <td>String</td>
  491. <td>none</td>
  492. <td>Select a locale for the Timeline. See section <a href="#Localization">Localization</a> for more information.</td>
  493. </tr>
  494. <tr>
  495. <td>locales</td>
  496. <td>Object</td>
  497. <td>none</td>
  498. <td>A map with i18n locales. See section <a href="#Localization">Localization</a> for more information.</td>
  499. </tr>
  500. <tr>
  501. <td>margin.axis</td>
  502. <td>Number</td>
  503. <td>20</td>
  504. <td>The minimal margin in pixels between items and the time axis.</td>
  505. </tr>
  506. <tr>
  507. <td>margin.item</td>
  508. <td>Number</td>
  509. <td>10</td>
  510. <td>The minimal margin in pixels between items in both horizontal and vertical direction.</td>
  511. </tr>
  512. <tr>
  513. <td>margin.item.horizontal</td>
  514. <td>Number</td>
  515. <td>10</td>
  516. <td>The minimal horizontal margin in pixels between items.</td>
  517. </tr>
  518. <tr>
  519. <td>margin.item.vertical</td>
  520. <td>Number</td>
  521. <td>10</td>
  522. <td>The minimal vertical margin in pixels between items.</td>
  523. </tr>
  524. <tr>
  525. <td>max</td>
  526. <td>Date | Number | String</td>
  527. <td>none</td>
  528. <td>Set a maximum Date for the visible range.
  529. It will not be possible to move beyond this maximum.
  530. </td>
  531. </tr>
  532. <tr>
  533. <td>maxHeight</td>
  534. <td>Number | String</td>
  535. <td>none</td>
  536. <td>Specifies the maximum height for the Timeline. Can be a number in pixels or a string like "300px".</td>
  537. </tr>
  538. <tr>
  539. <td>min</td>
  540. <td>Date | Number | String</td>
  541. <td>none</td>
  542. <td>Set a minimum Date for the visible range.
  543. It will not be possible to move beyond this minimum.
  544. </td>
  545. </tr>
  546. <tr>
  547. <td>minHeight</td>
  548. <td>Number | String</td>
  549. <td>none</td>
  550. <td>Specifies the minimum height for the Timeline. Can be a number in pixels or a string like "300px".</td>
  551. </tr>
  552. <tr>
  553. <td>moveable</td>
  554. <td>Boolean</td>
  555. <td>true</td>
  556. <td>
  557. Specifies whether the Timeline can be moved and zoomed by dragging the window.
  558. See also option <code>zoomable</code>.
  559. </td>
  560. </tr>
  561. <tr>
  562. <td>onAdd</td>
  563. <td>Function</td>
  564. <td>none</td>
  565. <td>Callback function triggered when an item is about to be added: when the user double taps an empty space in the Timeline. See section <a href="#Editing_Items">Editing Items</a> for more information. Only applicable when both options <code>selectable</code> and <code>editable.add</code> are set <code>true</code>.
  566. </td>
  567. </tr>
  568. <tr>
  569. <td>onUpdate</td>
  570. <td>Function</td>
  571. <td>none</td>
  572. <td>Callback function triggered when an item is about to be updated, when the user double taps an item in the Timeline. See section <a href="#Editing_Items">Editing Items</a> for more information. Only applicable when both options <code>selectable</code> and <code>editable.updateTime</code> or <code>editable.updateGroup</code> are set <code>true</code>.
  573. </td>
  574. </tr>
  575. <tr>
  576. <td>onMove</td>
  577. <td>Function</td>
  578. <td>none</td>
  579. <td>Callback function triggered when an item has been moved: after the user has dragged the item to an other position. See section <a href="#Editing_Items">Editing Items</a> for more information. Only applicable when both options <code>selectable</code> and <code>editable.updateTime</code> or <code>editable.updateGroup</code> are set <code>true</code>.
  580. </td>
  581. </tr>
  582. <tr>
  583. <td>onMoving</td>
  584. <td>Function</td>
  585. <td>none</td>
  586. <td>Callback function triggered repeatedly when an item is being moved. See section <a href="#Editing_Items">Editing Items</a> for more information. Only applicable when both options <code>selectable</code> and <code>editable.updateTime</code> or <code>editable.updateGroup</code> are set <code>true</code>.
  587. </td>
  588. </tr>
  589. <tr>
  590. <td>onRemove</td>
  591. <td>Function</td>
  592. <td>none</td>
  593. <td>Callback function triggered when an item is about to be removed: when the user tapped the delete button on the top right of a selected item. See section <a href="#Editing_Items">Editing Items</a> for more information. Only applicable when both options <code>selectable</code> and <code>editable.remove</code> are set <code>true</code>.
  594. </td>
  595. </tr>
  596. <!-- TODO: cleanup option order
  597. <tr>
  598. <td>order</td>
  599. <td>Function</td>
  600. <td>none</td>
  601. <td>Provide a custom sort function to order the items. The order of the
  602. items is determining the way they are stacked. The function
  603. order is called with two parameters, both of type
  604. `vis.components.items.Item`.
  605. </td>
  606. </tr>
  607. -->
  608. <tr>
  609. <td>orientation</td>
  610. <td>String</td>
  611. <td>'bottom'</td>
  612. <td>Orientation of the timeline: 'top' or 'bottom' (default). If orientation is 'bottom', the time axis is drawn at the bottom, and if 'top', the axis is drawn on top.</td>
  613. </tr>
  614. <tr>
  615. <td>padding</td>
  616. <td>Number</td>
  617. <td>5</td>
  618. <td>The padding of items, needed to correctly calculate the size
  619. of item ranges. Must correspond with the css of items, for example when setting <code>options.padding=10</code>, corresponding css is:
  620. <pre class="prettyprint lang-css">
  621. .vis.timeline .item {
  622. padding: 10px;
  623. }</pre>
  624. </td>
  625. </tr>
  626. <tr>
  627. <td>selectable</td>
  628. <td>Boolean</td>
  629. <td>true</td>
  630. <td>If true, the items on the timeline can be selected. Multiple items can be selected by long pressing them, or by using ctrl+click or shift+click. The event <code>select</code> is fired each time the selection has changed (see section <a href="#Events">Events</a>).</td>
  631. </tr>
  632. <tr>
  633. <td>showCurrentTime</td>
  634. <td>boolean</td>
  635. <td>true</td>
  636. <td>Show a vertical bar at the current time.</td>
  637. </tr>
  638. <tr>
  639. <td>showCustomTime</td>
  640. <td>boolean</td>
  641. <td>false</td>
  642. <td>Show a vertical bar displaying a custom time. This line can be dragged by the user. The custom time can be utilized to show a state in the past or in the future. When the custom time bar is dragged by the user, the event <code>timechange</code> is fired repeatedly. After the bar is dragged, the event <code>timechanged</code> is fired once.</td>
  643. </tr>
  644. <tr>
  645. <tr>
  646. <td>showMajorLabels</td>
  647. <td>boolean</td>
  648. <td>true</td>
  649. <td>By default, the timeline shows both minor and major date labels on the
  650. time axis.
  651. For example the minor labels show minutes and the major labels show hours.
  652. When <code>showMajorLabels</code> is <code>false</code>, no major labels
  653. are shown.</td>
  654. </tr>
  655. <tr>
  656. <td>showMinorLabels</td>
  657. <td>boolean</td>
  658. <td>true</td>
  659. <td>By default, the timeline shows both minor and major date labels on the
  660. time axis.
  661. For example the minor labels show minutes and the major labels show hours.
  662. When <code>showMinorLabels</code> is <code>false</code>, no minor labels
  663. are shown. When both <code>showMajorLabels</code> and
  664. <code>showMinorLabels</code> are false, no horizontal axis will be
  665. visible.</td>
  666. </tr>
  667. <tr>
  668. <td>stack</td>
  669. <td>Boolean</td>
  670. <td>true</td>
  671. <td>If true (default), items will be stacked on top of each other such that they do not overlap.</td>
  672. </tr>
  673. <tr>
  674. <td>snap</td>
  675. <td>function | null</td>
  676. <td>function</td>
  677. <td>When moving items on the Timeline, they will be snapped to nice dates like full hours or days, depending on the current scale. The <code>snap</code> function can be replaced with a custom function, or can be set to <code>null</code> to disable snapping. The signature of the snap function is:
  678. <pre class="prettyprint lang-js">function snap(date: Date, scale: string, step: number) : Date | number</pre>
  679. The parameter <code>scale</code> can be can be 'millisecond', 'second', 'minute', 'hour', 'weekday, 'day, 'month, or 'year'. The parameter <code>step</code> is a number like 1, 2, 4, 5.
  680. </td>
  681. </tr>
  682. <tr>
  683. <td>start</td>
  684. <td>Date | Number | String</td>
  685. <td>none</td>
  686. <td>The initial start date for the axis of the timeline.
  687. If not provided, the earliest date present in the events is taken as start date.</td>
  688. </tr>
  689. <tr>
  690. <td>template</td>
  691. <td>Function</td>
  692. <td>none</td>
  693. <td>A template function used to generate the contents of the items. The function is called by the Timeline with an items data as argument, and must return HTML code as result. When the option template is specified, the items do not need to have a field <code>content</code>. See section <a href="#Templates">Templates</a> for a detailed explanation.</td>
  694. </tr>
  695. <tr>
  696. <td>timeAxis.scale</td>
  697. <td>string</td>
  698. <td>none</td>
  699. <td>Set a fixed scale for the time axis of the Timeline. Choose from <code>'millisecond'</code>, <code>'second'</code>, <code>'minute'</code>, <code>'hour'</code>, <code>'weekday'</code>, <code>'day'</code>, <code>'month'</code>, <code>'year'</code>. Example usage:
  700. <pre class="prettyprint lang-js">var options = {
  701. timeAxis: {scale: 'minute', step: 5}
  702. }</pre>
  703. </td>
  704. </tr>
  705. <tr>
  706. <td>timeAxis.step</td>
  707. <td>number</td>
  708. <td>1</td>
  709. <td>
  710. Set a fixed step size for the time axis. Only applicable when used together with <code>timeAxis.scale</code>.
  711. Choose for example 1, 2, 5, or 10.</td>
  712. </tr>
  713. <tr>
  714. <td>type</td>
  715. <td>String</td>
  716. <td>none</td>
  717. <td>Specifies the default type for the timeline items. Choose from 'box', 'point', 'range', and 'background'. Note that individual items can override this default type. If undefined, the Timeline will auto detect the type from the items data: if a start and end date is available, a 'range' will be created, and else, a 'box' is created. Items of type 'background' are not editable.
  718. </td>
  719. </tr>
  720. <tr>
  721. <td>width</td>
  722. <td>String</td>
  723. <td>'100%'</td>
  724. <td>The width of the timeline in pixels or as a percentage.</td>
  725. </tr>
  726. <tr>
  727. <td>zoomable</td>
  728. <td>Boolean</td>
  729. <td>true</td>
  730. <td>
  731. Specifies whether the Timeline can be zoomed by pinching or scrolling in the window.
  732. Only applicable when option <code>moveable</code> is set <code>true</code>.
  733. </td>
  734. </tr>
  735. <tr>
  736. <td>zoomMax</td>
  737. <td>Number</td>
  738. <td>315360000000000</td>
  739. <td>Set a maximum zoom interval for the visible range in milliseconds.
  740. It will not be possible to zoom out further than this maximum.
  741. Default value equals about 10000 years.
  742. </td>
  743. </tr>
  744. <tr>
  745. <td>zoomMin</td>
  746. <td>Number</td>
  747. <td>10</td>
  748. <td>Set a minimum zoom interval for the visible range in milliseconds.
  749. It will not be possible to zoom in further than this minimum.
  750. </td>
  751. </tr>
  752. </table>
  753. <h2 id="Methods">Methods</h2>
  754. <p>
  755. The Timeline supports the following methods.
  756. </p>
  757. <table>
  758. <tr>
  759. <th>Method</th>
  760. <th>Return Type</th>
  761. <th>Description</th>
  762. </tr>
  763. <tr>
  764. <td>addCustomTime(time)</td>
  765. <td>Number</td>
  766. <td>
  767. Add new vertical bar representing custom time. Each new line is assigned a unique ID and can be dragged by the user. Parameter <code>time</code> can be a Date, Number, or String. Returns ID of the newly created bar. Only applicable when the option showCustomTime is true.
  768. </td>
  769. </tr>
  770. <tr>
  771. <td>clear([what])</td>
  772. <td>none</td>
  773. <td>
  774. Clear the Timeline. An object can be passed specifying which sections to clear: items, groups,
  775. and/or options. By Default, items, groups and options are cleared, i.e. <code>what = {items: true, groups: true, options: true}</code>. Example usage:
  776. <pre class="prettyprint lang-js">timeline.clear(); // clear items, groups, and options
  777. timeline.clear({options: true}); // clear options only
  778. </pre>
  779. </td>
  780. </tr>
  781. <tr>
  782. <td>destroy()</td>
  783. <td>none</td>
  784. <td>Destroy the Timeline. The timeline is removed from memory. all DOM elements and event listeners are cleaned up.
  785. </td>
  786. </tr>
  787. <tr>
  788. <td>fit([options])</td>
  789. <td>none</td>
  790. <td>Adjust the visible window such that it fits all items. See also function <code>focus(id)</code>.
  791. Available options:
  792. <ul>
  793. <li><code>animate: boolean | number</code><br>If true (default), the range is animated smoothly to the new window. If a number, the number is taken as duration for the animation. Default duration is 500 ms.</li>
  794. </ul>
  795. </td>
  796. </tr>
  797. <tr>
  798. <td>focus(id | ids [, options])</td>
  799. <td>none</td>
  800. <td>Adjust the visible window such that the selected item (or multiple items) are centered on screen. See also function <code>fit()</code>. Available options:
  801. <ul>
  802. <li><code>animate: boolean | number</code><br>If true (default), the range is animated smoothly to the new window. If a number, the number is taken as duration for the animation. Default duration is 500 ms.</li>
  803. </ul>
  804. </td>
  805. </tr>
  806. <tr>
  807. <td>getCurrentTime()</td>
  808. <td>Date</td>
  809. <td>Get the current time. Only applicable when option <code>showCurrentTime</code> is true.
  810. </td>
  811. </tr>
  812. <tr>
  813. <td>getCustomTime([id])</td>
  814. <td>Date</td>
  815. <td>Retrieve the custom time. Only applicable when the option <code>showCustomTime</code> is true. If parameter <code>id</code> is provided, time of the custom time bar under that ID is returned.
  816. </td>
  817. </tr>
  818. <tr>
  819. <td>getSelection()</td>
  820. <td>Number[]</td>
  821. <td>Get an array with the ids of the currently selected items.</td>
  822. </tr>
  823. <tr>
  824. <td>getVisibleItems()</td>
  825. <td>Number[]</td>
  826. <td>Get an array with the ids of the currently visible items.</td>
  827. </tr>
  828. <tr>
  829. <td>getWindow()</td>
  830. <td>Object</td>
  831. <td>Get the current visible window. Returns an object with properties <code>start: Date</code> and <code>end: Date</code>.</td>
  832. </tr>
  833. <tr>
  834. <td>moveTo(time [, options])</td>
  835. <td>none</td>
  836. <td>Move the window such that given time is centered on screen. Parameter <code>time</code> can be a <code>Date</code>, <code>Number</code>, or <code>String</code>. Available options:
  837. <ul>
  838. <li><code>animate: boolean | number</code><br>If true (default), the range is animated smoothly to the new window. If a number, the number is taken as duration for the animation. Default duration is 500 ms.</li>
  839. </ul>
  840. </td>
  841. </tr>
  842. <tr>
  843. <td>on(event, callback)</td>
  844. <td>none</td>
  845. <td>Create an event listener. The callback function is invoked every time the event is triggered. Avialable events: <code>rangechange</code>, <code>rangechanged</code>, <code>select</code>. The callback function is invoked as <code>callback(properties)</code>, where <code>properties</code> is an object containing event specific properties. See section <a href="#Events">Events for more information</a>.</td>
  846. </tr>
  847. <tr>
  848. <td>off(event, callback)</td>
  849. <td>none</td>
  850. <td>Remove an event listener created before via function <code>on(event, callback)</code>. See section <a href="#Events">Events for more information</a>.</td>
  851. </tr>
  852. <tr>
  853. <td>redraw()</td>
  854. <td>none</td>
  855. <td>Force a redraw of the Timeline. The size of all items will be recalculated.
  856. Can be useful to manually redraw when option <code>autoResize=false</code> and the window
  857. has been resized, or when the items CSS has been changed.
  858. </td>
  859. </tr>
  860. <tr>
  861. <td>removeCustomTime(id)</td>
  862. <td>none</td>
  863. <td>
  864. Remove vertical bars previously added to the timeline via <code>addCustomTime</code> method. Parameter <code>id</code> is the ID of the custom vertical bar returned by <code>addCustomTime</code> method.
  865. </td>
  866. </tr>
  867. <tr>
  868. <td>setCurrentTime(time)</td>
  869. <td>none</td>
  870. <td>Set a current time. This can be used for example to ensure that a client's time is synchronized with a shared server time.
  871. <code>time</code> can be a Date object, numeric timestamp, or ISO date string.
  872. Only applicable when option <code>showCurrentTime</code> is true.</td>
  873. </tr>
  874. <tr>
  875. <td>setCustomTime(time [, id])</td>
  876. <td>none</td>
  877. <td>Adjust the custom time bar. Only applicable when the option <code>showCustomTime</code> is true. <code>time</code> can be a Date object, numeric timestamp, or ISO date string. Parameter <code>id</code> represents ID of the custom time bar, provided by <code>addCustomTime</code> method.
  878. </td>
  879. </tr>
  880. <tr>
  881. <td>setGroups(groups)</td>
  882. <td>none</td>
  883. <td>Set a data set with groups for the Timeline.
  884. <code>groups</code> can be an Array with Objects,
  885. a DataSet, or a DataView. For each of the groups, the items of the
  886. timeline are filtered on the property <code>group</code>, which
  887. must correspond with the id of the group.
  888. </td>
  889. </tr>
  890. <tr>
  891. <td>setItems(items)</td>
  892. <td>none</td>
  893. <td>Set a data set with items for the Timeline.
  894. <code>items</code> can be an Array with Objects,
  895. a DataSet, or a DataView.
  896. </td>
  897. </tr>
  898. <tr>
  899. <td>setOptions(options)</td>
  900. <td>none</td>
  901. <td>Set or update options. It is possible to change any option of the timeline at any time. You can for example switch orientation on the fly.
  902. </td>
  903. </tr>
  904. <tr>
  905. <td>setSelection(id | ids [, options])</td>
  906. <td>none</td>
  907. <td>Select one or multiple items by their id. The currently selected items will be unselected. To unselect all selected items, call `setSelection([])`. Available options:
  908. <ul>
  909. <li><code>focus: boolean</code><br>If true, focus will be set to the selected item(s)</li>
  910. <li><code>animate: boolean | number</code><br>If true (default), the range is animated smoothly to the new window. If a number, the number is taken as duration for the animation. Default duration is 500 ms. Only applicable when option focus is true.</li>
  911. </ul>
  912. </td>
  913. </tr>
  914. <tr>
  915. <td>setWindow(start, end [, options])</td>
  916. <td>none</td>
  917. <td>Set the current visible window. The parameters <code>start</code> and <code>end</code> can be a <code>Date</code>, <code>Number</code>, or <code>String</code>. If the parameter value of <code>start</code> or <code>end</code> is null, the parameter will be left unchanged. Available options:
  918. <ul>
  919. <li><code>animate: boolean | number</code><br>If true (default), the range is animated smoothly to the new window. If a number, the number is taken as duration for the animation. Default duration is 500 ms.</li>
  920. </ul>
  921. </td>
  922. </tr>
  923. </table>
  924. <h2 id="Events">Events</h2>
  925. <p>
  926. Timeline fires events when changing the visible window by dragging, when
  927. selecting items, and when dragging the custom time bar.
  928. </p>
  929. <p>
  930. Here an example on how to listen for a <code>select</code> event.
  931. </p>
  932. <pre class="prettyprint lang-js">
  933. timeline.on('select', function (properties) {
  934. alert('selected items: ' + properties.nodes);
  935. });
  936. </pre>
  937. <p>
  938. A listener can be removed via the function <code>off</code>:
  939. </p>
  940. <pre class="prettyprint lang-js">
  941. function onSelect (properties) {
  942. alert('selected items: ' + properties.nodes);
  943. }
  944. // add event listener
  945. timeline.on('select', onSelect);
  946. // do stuff...
  947. // remove event listener
  948. timeline.off('select', onSelect);
  949. </pre>
  950. <p>
  951. The following events are available.
  952. </p>
  953. <table>
  954. <colgroup>
  955. <col style="width: 20%;">
  956. <col style="width: 40%;">
  957. <col style="width: 40%;">
  958. </colgroup>
  959. <tr>
  960. <th>name</th>
  961. <th>Description</th>
  962. <th>Properties</th>
  963. </tr>
  964. <tr>
  965. <td>finishedRedraw</td>
  966. <td>Fired after a redraw is complete. When moving the timeline around, this could be fired frequently.
  967. </td>
  968. <td>
  969. none.
  970. </td>
  971. </tr>
  972. <tr>
  973. <td>rangechange</td>
  974. <td>Fired repeatedly when the timeline window is being changed.
  975. </td>
  976. <td>
  977. <ul>
  978. <li><code>start</code> (Number): timestamp of the current start of the window.</li>
  979. <li><code>end</code> (Number): timestamp of the current end of the window.</li>
  980. <li><code>byUser</code> (Boolean): change happened because of user drag/zoom.</li>
  981. </ul>
  982. </td>
  983. </tr>
  984. <tr>
  985. <td>rangechanged</td>
  986. <td>Fired once after the timeline window has been changed.
  987. </td>
  988. <td>
  989. <ul>
  990. <li><code>start</code> (Number): timestamp of the current start of the window.</li>
  991. <li><code>end</code> (Number): timestamp of the current end of the window.</li>
  992. <li><code>byUser</code> (Boolean): change happened because of user drag/zoom.</li>
  993. </ul>
  994. </td>
  995. </tr>
  996. <tr>
  997. <td>select</td>
  998. <td>Fired after the user selects or deselects items by tapping or holding them.
  999. When a use taps an already selected item, the select event is fired again.
  1000. Not fired when the method <code>setSelection</code>is executed.
  1001. </td>
  1002. <td>
  1003. <ul>
  1004. <li><code>items</code>: an array with the ids of the selected items</li>
  1005. </ul>
  1006. </td>
  1007. </tr>
  1008. <tr>
  1009. <td>timechange</td>
  1010. <td>Fired repeatedly when the user is dragging the custom time bar.
  1011. Only available when the custom time bar is enabled.
  1012. </td>
  1013. <td>
  1014. <ul>
  1015. <li><code>id</code> (Number): Vertical bar ID.</li>
  1016. <li><code>time</code> (Date): the current time.</li>
  1017. </ul>
  1018. </td>
  1019. </tr>
  1020. <tr>
  1021. <td>timechanged</td>
  1022. <td>Fired once after the user has dragged the custom time bar.
  1023. Only available when the custom time bar is enabled.
  1024. </td>
  1025. <td>
  1026. <ul>
  1027. <li><code>id</code> (Number): Vertical bar ID.</li>
  1028. <li><code>time</code> (Date): the current time.</li>
  1029. </ul>
  1030. </td>
  1031. </tr>
  1032. </table>
  1033. <h2 id="Editing_Items">Editing Items</h2>
  1034. <p>
  1035. When the Timeline is configured to be editable (both options <code>selectable</code> and <code>editable</code> are <code>true</code>), the user can move items by dragging them, can create a new item by double tapping on an empty space, can update an item by double tapping it, and can delete a selected item by clicking the delete button on the top right.
  1036. </p>
  1037. <p>Option <code>editable</code> accepts a boolean or an object. When <code>editable</code> is a boolean, all manipulation actions will be either enabled or disabled. When <code>editable</code> is an object, one can enable individual manipulation actions:</p>
  1038. <pre class="prettyprint lang-js">// enable or disable all manipulation actions
  1039. var options = {
  1040. editable: true // true or false
  1041. };
  1042. // enable or disable individual manipulation actions
  1043. var options = {
  1044. editable: {
  1045. add: true, // add new items by double tapping
  1046. updateTime: true, // drag items horizontally
  1047. updateGroup: true, // drag items from one group to another
  1048. remove: true // delete an item by tapping the delete button top right
  1049. }
  1050. };</pre>
  1051. <p>
  1052. One can specify callback functions to validate changes made by the user. There are a number of callback functions for this purpose:
  1053. </p>
  1054. <ul>
  1055. <li><code>onAdd(item, callback)</code> Fired when a new item is about to be added. If not implemented, the item will be added with default text contents.</li>
  1056. <li><code>onUpdate(item, callback)</code> Fired when an item is about to be updated. This function typically has to show a dialog where the user change the item. If not implemented, nothing happens.</li>
  1057. <li><code>onMove(item, callback)</code> Fired when an item has been moved. If not implemented, the move action will be accepted.</li>
  1058. <li><code>onMoving(item, callback)</code> Fired repeatedly while an item is being moved (dragged). Can be used to adjust the items start, end, and/or group to allowed regions.</li>
  1059. <li><code>onRemove(item, callback)</code> Fired when an item is about to be deleted. If not implemented, the item will be always removed.</li>
  1060. </ul>
  1061. <p>
  1062. Each of the callbacks is invoked with two arguments:
  1063. </p>
  1064. <ul>
  1065. <li><code>item</code>: the item being manipulated</li>
  1066. <li><code>callback</code>: a callback function which must be invoked to report back. The callback must be invoked as <code>callback(item | null)</code>. Here, <code>item</code> can contain changes to the passed item. Parameter `item` typically contains fields `content`, `start`, and optionally `end`. The type of `start` and `end` is determined by the DataSet type configuration and is `Date` by default. When invoked as <code>callback(null)</code>, the action will be cancelled.</li>
  1067. </ul>
  1068. <p>
  1069. Example code:
  1070. </p>
  1071. <pre class="prettyprint lang-js">var options = {
  1072. onUpdate: function (item, callback) {
  1073. item.content = prompt('Edit items text:', item.content);
  1074. if (item.content != null) {
  1075. callback(item); // send back adjusted item
  1076. }
  1077. else {
  1078. callback(null); // cancel updating the item
  1079. }
  1080. }
  1081. };
  1082. </pre>
  1083. A full example is available here: <a href="../examples/timeline/08_edit_items.html">08_edit_items.html</a>.
  1084. <h2 id="Templates">Templates</h2>
  1085. <p>
  1086. Timeline supports templates to format item contents. Any template engine (such as <a href="http://handlebarsjs.com/">handlebars</a> or <a href="http://mustache.github.io/">mustache</a>) can be used, and one can also manually build HTML. In the options, one can provide a template handler. This handler is a function accepting an items data as argument, and outputs formatted HTML:
  1087. </p>
  1088. <pre class="prettyprint lang-js">var options = {
  1089. template: function (item) {
  1090. var html = ... // generate HTML markup for this item
  1091. return html;
  1092. }
  1093. };
  1094. </pre>
  1095. <h3>Create HTML manually</h3>
  1096. The HTML for an item can be created manually:
  1097. <pre class="prettyprint lang-js">var options = {
  1098. template: function (item) {
  1099. return '&lt;h1&gt;' + item.header + '&lt;/h1&gt;&lt;p&gt;' + item.description + '&lt;/p&gt;';
  1100. }
  1101. };
  1102. </pre>
  1103. <h3>Using a template engine</h3>
  1104. Using <a href="http://handlebarsjs.com/">handlebars</a>, one can write the template in HTML:
  1105. <pre class="prettyprint lang-html">
  1106. &lt;script id="item-template" type="text/x-handlebars-template"&gt;
  1107. &lt;h1&gt;{{header}}&lt;/h1&gt;
  1108. &lt;p&gt;{{description}}&lt;/p&gt;
  1109. &lt;/script&gt;
  1110. </pre>
  1111. Compile the template:
  1112. <pre class="prettyprint lang-js">
  1113. var source = document.getElementById('item-template').innerHTML;
  1114. var template = Handlebars.compile(source);
  1115. </pre>
  1116. And then specify the template in the Timeline options
  1117. <pre class="prettyprint lang-js">var options = {
  1118. template: template
  1119. };
  1120. </pre>
  1121. <h3>Multiple templates</h3>
  1122. In order to support multiple templates, the template handler can be extended to switch between different templates, depending on a specific item property:
  1123. <pre class="prettyprint lang-js">
  1124. var templates = {
  1125. template1: Handlebars.compile(...),
  1126. template2: Handlebars.compile(...),
  1127. template2: Handlebars.compile(...),
  1128. ...
  1129. };
  1130. var options = {
  1131. template: function (item) {
  1132. var template = templates[item.template]; // choose the right template
  1133. return template(item); // execute the template
  1134. }
  1135. };
  1136. </pre>
  1137. Now the items can be extended with a property <code>template</code>, specifying which template to use for the item.
  1138. <h2 id="Localization">Localization</h2>
  1139. <p>
  1140. Timeline can be localized. For localization, Timeline depends largely on the localization of <a href="http://momentjs.com">moment.js</a>. Locales are not included in vis.js by default. To enable localization, moment.js must be loaded with locales. Moment.js offers a bundle named "moment-with-locales.min.js" for this and there are various alternative ways to load locales.
  1141. </p>
  1142. <p>
  1143. To set a locale for the Timeline, specify the option <code>locale</code>:
  1144. </p>
  1145. <pre class="prettyprint lang-js">var options = {
  1146. locale: 'nl'
  1147. };
  1148. </pre>
  1149. <h3>Create a new locale</h3>
  1150. To load a locale into the Timeline not supported by default, one can add a new locale to the option <code>locales</code>:
  1151. <pre class="prettyprint lang-js">var options = {
  1152. locales: {
  1153. // create a new locale (text strings should be replaced with localized strings)
  1154. mylocale: {
  1155. current: 'current',
  1156. time: 'time',
  1157. }
  1158. },
  1159. // use the new locale
  1160. locale: 'mylocale'
  1161. };
  1162. </pre>
  1163. <h3 id="available-locales">Available locales</h3>
  1164. <p>
  1165. Timeline comes with support for the following locales:
  1166. </p>
  1167. <table>
  1168. <tr><th>Language</th><th>Code</th></tr>
  1169. <tr>
  1170. <td>English</td>
  1171. <td>
  1172. <code>en</code><br>
  1173. <code>en_EN</code><br>
  1174. <code>en_US</code>
  1175. </td>
  1176. </tr>
  1177. <tr>
  1178. <td>Dutch</td>
  1179. <td>
  1180. <code>nl</code><br>
  1181. <code>nl_NL</code><br>
  1182. <code>nl_BE</code>
  1183. </td>
  1184. </tr>
  1185. </table>
  1186. <h2 id="Styles">Styles</h2>
  1187. <p>
  1188. All parts of the Timeline have a class name and a default css style.
  1189. The styles can be overwritten, which enables full customization of the layout
  1190. of the Timeline.
  1191. </p>
  1192. <p>For example, to change the border and background color of all items, include the
  1193. following code inside the head of your html code or in a separate stylesheet.</p>
  1194. <pre class="prettyprint lang-html">&lt;style&gt;
  1195. .vis.timeline .item {
  1196. border-color: orange;
  1197. background-color: yellow;
  1198. }
  1199. &lt;/style&gt;
  1200. </pre>
  1201. <h3 id="Grid_Backgrounds">Grid Backgrounds</h3>
  1202. <p>
  1203. The background grid of the time axis can be styled, for example to highlight
  1204. weekends or to create grids with an alternating white/lightgray background.
  1205. </p>
  1206. <p>
  1207. Depending on the zoom level, the grids get certain css classes attached.
  1208. The following classes are available:
  1209. </p>
  1210. <table>
  1211. <tr>
  1212. <th>Description</th><th>values</th>
  1213. </tr>
  1214. <tr>
  1215. <td>Alternating columns</td><td><code>even</code>, <code>odd</code></td>
  1216. </tr>
  1217. <tr>
  1218. <td>Current date</td><td><code>today</code>, <code>tomorrow</code>, <code>yesterday</code>, <code>current-week</code>, <code>current-month</code>, <code>current-year</code></td>
  1219. </tr>
  1220. <tr>
  1221. <td>Hours</td><td><code>0h</code>, <code>1h</code>, ..., <code>23h</code></td>
  1222. </tr>
  1223. <tr>
  1224. <td>Grouped hours</td><td><code>0-4h</code> to <code>20-24h</code></td>
  1225. </tr>
  1226. <tr>
  1227. <td>Weekday</td><td><code>monday</code>, <code>tuesday</code>, <code>wednesday</code>, <code>thursday</code>, <code>friday</code>, <code>saturday</code>, <code>sunday</code></td>
  1228. </tr>
  1229. <tr>
  1230. <td>Days</td><td><code>date1</code>, <code>date2</code>, ..., <code>date31</code></td>
  1231. </tr>
  1232. <tr>
  1233. <td>Months</td><td><code>januari</code>, <code>februari</code>, <code>march</code>, <code>april</code>, <code>may</code>, <code>june</code>, <code>july</code>, <code>august</code>, <code>september</code>, <code>october</code>, <code>november</code>, <code>december</code></td>
  1234. </tr>
  1235. <tr>
  1236. <td>Years</td><td><code>year2014</code>, <code>year2015</code>, ...</td>
  1237. </tr>
  1238. </table>
  1239. <p>Examples:</p>
  1240. <pre class="prettyprint lang-html">&lt;style&gt;
  1241. /* alternating column backgrounds */
  1242. .vis.timeline .timeaxis .grid.odd {
  1243. background: #f5f5f5;
  1244. }
  1245. /* gray background in weekends, white text color */
  1246. .vis.timeline .timeaxis .grid.saturday,
  1247. .vis.timeline .timeaxis .grid.sunday {
  1248. background: gray;
  1249. }
  1250. .vis.timeline .timeaxis .text.saturday,
  1251. .vis.timeline .timeaxis .text.sunday {
  1252. color: white;
  1253. }
  1254. &lt;/style&gt;
  1255. </pre>
  1256. <h2 id="Data_Policy">Data Policy</h2>
  1257. <p>
  1258. All code and data is processed and rendered in the browser.
  1259. No data is sent to any server.
  1260. </p>
  1261. </div>
  1262. </body>
  1263. </html>