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.

1452 lines
47 KiB

9 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[, id])</td>
  765. <td>Number | String</td>
  766. <td>
  767. Only applicable when the option showCustomTime is true.<br>
  768. Add new vertical bar representing custom time that can be dragged by the user. Parameter <code>time</code> can be a Date, Number, or String. Parameter <code>id</code> can be Number or String. If <code>id</code> is provided, it will be used as ID for the new vertical bar, otherwise the ID will be auto generated.<br>
  769. Returns ID of the newly created bar.
  770. </td>
  771. </tr>
  772. <tr>
  773. <td>clear([what])</td>
  774. <td>none</td>
  775. <td>
  776. Clear the Timeline. An object can be passed specifying which sections to clear: items, groups,
  777. and/or options. By Default, items, groups and options are cleared, i.e. <code>what = {items: true, groups: true, options: true}</code>. Example usage:
  778. <pre class="prettyprint lang-js">timeline.clear(); // clear items, groups, and options
  779. timeline.clear({options: true}); // clear options only
  780. </pre>
  781. </td>
  782. </tr>
  783. <tr>
  784. <td>destroy()</td>
  785. <td>none</td>
  786. <td>Destroy the Timeline. The timeline is removed from memory. all DOM elements and event listeners are cleaned up.
  787. </td>
  788. </tr>
  789. <tr>
  790. <td>fit([options])</td>
  791. <td>none</td>
  792. <td>Adjust the visible window such that it fits all items. See also function <code>focus(id)</code>.
  793. Available options:
  794. <ul>
  795. <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>
  796. </ul>
  797. </td>
  798. </tr>
  799. <tr>
  800. <td>focus(id | ids [, options])</td>
  801. <td>none</td>
  802. <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:
  803. <ul>
  804. <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>
  805. </ul>
  806. </td>
  807. </tr>
  808. <tr>
  809. <td>getCurrentTime()</td>
  810. <td>Date</td>
  811. <td>Get the current time. Only applicable when option <code>showCurrentTime</code> is true.
  812. </td>
  813. </tr>
  814. <tr>
  815. <td>getCustomTime([id])</td>
  816. <td>Date</td>
  817. <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.
  818. </td>
  819. </tr>
  820. <tr>
  821. <td>getSelection()</td>
  822. <td>Number[]</td>
  823. <td>Get an array with the ids of the currently selected items.</td>
  824. </tr>
  825. <tr>
  826. <td>getVisibleItems()</td>
  827. <td>Number[]</td>
  828. <td>Get an array with the ids of the currently visible items.</td>
  829. </tr>
  830. <tr>
  831. <td>getWindow()</td>
  832. <td>Object</td>
  833. <td>Get the current visible window. Returns an object with properties <code>start: Date</code> and <code>end: Date</code>.</td>
  834. </tr>
  835. <tr>
  836. <td>moveTo(time [, options])</td>
  837. <td>none</td>
  838. <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:
  839. <ul>
  840. <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>
  841. </ul>
  842. </td>
  843. </tr>
  844. <tr>
  845. <td>on(event, callback)</td>
  846. <td>none</td>
  847. <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>
  848. </tr>
  849. <tr>
  850. <td>off(event, callback)</td>
  851. <td>none</td>
  852. <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>
  853. </tr>
  854. <tr>
  855. <td>redraw()</td>
  856. <td>none</td>
  857. <td>Force a redraw of the Timeline. The size of all items will be recalculated.
  858. Can be useful to manually redraw when option <code>autoResize=false</code> and the window
  859. has been resized, or when the items CSS has been changed.
  860. </td>
  861. </tr>
  862. <tr>
  863. <td>removeCustomTime(id)</td>
  864. <td>none</td>
  865. <td>
  866. 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.
  867. </td>
  868. </tr>
  869. <tr>
  870. <td>setCurrentTime(time)</td>
  871. <td>none</td>
  872. <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.
  873. <code>time</code> can be a Date object, numeric timestamp, or ISO date string.
  874. Only applicable when option <code>showCurrentTime</code> is true.</td>
  875. </tr>
  876. <tr>
  877. <td>setCustomTime(time [, id])</td>
  878. <td>none</td>
  879. <td>Adjust the custom time bar. Only applicable when the option <code>showCustomTime</code> is true. Parameter <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 and can be a Number or String.
  880. </td>
  881. </tr>
  882. <tr>
  883. <td>setGroups(groups)</td>
  884. <td>none</td>
  885. <td>Set a data set with groups for the Timeline.
  886. <code>groups</code> can be an Array with Objects,
  887. a DataSet, or a DataView. For each of the groups, the items of the
  888. timeline are filtered on the property <code>group</code>, which
  889. must correspond with the id of the group.
  890. </td>
  891. </tr>
  892. <tr>
  893. <td>setItems(items)</td>
  894. <td>none</td>
  895. <td>Set a data set with items for the Timeline.
  896. <code>items</code> can be an Array with Objects,
  897. a DataSet, or a DataView.
  898. </td>
  899. </tr>
  900. <tr>
  901. <td>setOptions(options)</td>
  902. <td>none</td>
  903. <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.
  904. </td>
  905. </tr>
  906. <tr>
  907. <td>setSelection(id | ids [, options])</td>
  908. <td>none</td>
  909. <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:
  910. <ul>
  911. <li><code>focus: boolean</code><br>If true, focus will be set to the selected item(s)</li>
  912. <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>
  913. </ul>
  914. </td>
  915. </tr>
  916. <tr>
  917. <td>setWindow(start, end [, options])</td>
  918. <td>none</td>
  919. <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:
  920. <ul>
  921. <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>
  922. </ul>
  923. </td>
  924. </tr>
  925. </table>
  926. <h2 id="Events">Events</h2>
  927. <p>
  928. Timeline fires events when changing the visible window by dragging, when
  929. selecting items, and when dragging the custom time bar.
  930. </p>
  931. <p>
  932. Here an example on how to listen for a <code>select</code> event.
  933. </p>
  934. <pre class="prettyprint lang-js">
  935. timeline.on('select', function (properties) {
  936. alert('selected items: ' + properties.nodes);
  937. });
  938. </pre>
  939. <p>
  940. A listener can be removed via the function <code>off</code>:
  941. </p>
  942. <pre class="prettyprint lang-js">
  943. function onSelect (properties) {
  944. alert('selected items: ' + properties.nodes);
  945. }
  946. // add event listener
  947. timeline.on('select', onSelect);
  948. // do stuff...
  949. // remove event listener
  950. timeline.off('select', onSelect);
  951. </pre>
  952. <p>
  953. The following events are available.
  954. </p>
  955. <table>
  956. <colgroup>
  957. <col style="width: 20%;">
  958. <col style="width: 40%;">
  959. <col style="width: 40%;">
  960. </colgroup>
  961. <tr>
  962. <th>name</th>
  963. <th>Description</th>
  964. <th>Properties</th>
  965. </tr>
  966. <tr>
  967. <td>finishedRedraw</td>
  968. <td>Fired after a redraw is complete. When moving the timeline around, this could be fired frequently.
  969. </td>
  970. <td>
  971. none.
  972. </td>
  973. </tr>
  974. <tr>
  975. <td>rangechange</td>
  976. <td>Fired repeatedly when the timeline window is being changed.
  977. </td>
  978. <td>
  979. <ul>
  980. <li><code>start</code> (Number): timestamp of the current start of the window.</li>
  981. <li><code>end</code> (Number): timestamp of the current end of the window.</li>
  982. <li><code>byUser</code> (Boolean): change happened because of user drag/zoom.</li>
  983. </ul>
  984. </td>
  985. </tr>
  986. <tr>
  987. <td>rangechanged</td>
  988. <td>Fired once after the timeline window has been changed.
  989. </td>
  990. <td>
  991. <ul>
  992. <li><code>start</code> (Number): timestamp of the current start of the window.</li>
  993. <li><code>end</code> (Number): timestamp of the current end of the window.</li>
  994. <li><code>byUser</code> (Boolean): change happened because of user drag/zoom.</li>
  995. </ul>
  996. </td>
  997. </tr>
  998. <tr>
  999. <td>select</td>
  1000. <td>Fired after the user selects or deselects items by tapping or holding them.
  1001. When a use taps an already selected item, the select event is fired again.
  1002. Not fired when the method <code>setSelection</code>is executed.
  1003. </td>
  1004. <td>
  1005. <ul>
  1006. <li><code>items</code>: an array with the ids of the selected items</li>
  1007. </ul>
  1008. </td>
  1009. </tr>
  1010. <tr>
  1011. <td>timechange</td>
  1012. <td>Fired repeatedly when the user is dragging the custom time bar.
  1013. Only available when the custom time bar is enabled.
  1014. </td>
  1015. <td>
  1016. <ul>
  1017. <li><code>id</code> (Number | String): Vertical bar ID.</li>
  1018. <li><code>time</code> (Date): the current time.</li>
  1019. </ul>
  1020. </td>
  1021. </tr>
  1022. <tr>
  1023. <td>timechanged</td>
  1024. <td>Fired once after the user has dragged the custom time bar.
  1025. Only available when the custom time bar is enabled.
  1026. </td>
  1027. <td>
  1028. <ul>
  1029. <li><code>id</code> (Number | String): Vertical bar ID.</li>
  1030. <li><code>time</code> (Date): the current time.</li>
  1031. </ul>
  1032. </td>
  1033. </tr>
  1034. </table>
  1035. <h2 id="Editing_Items">Editing Items</h2>
  1036. <p>
  1037. 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.
  1038. </p>
  1039. <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>
  1040. <pre class="prettyprint lang-js">// enable or disable all manipulation actions
  1041. var options = {
  1042. editable: true // true or false
  1043. };
  1044. // enable or disable individual manipulation actions
  1045. var options = {
  1046. editable: {
  1047. add: true, // add new items by double tapping
  1048. updateTime: true, // drag items horizontally
  1049. updateGroup: true, // drag items from one group to another
  1050. remove: true // delete an item by tapping the delete button top right
  1051. }
  1052. };</pre>
  1053. <p>
  1054. One can specify callback functions to validate changes made by the user. There are a number of callback functions for this purpose:
  1055. </p>
  1056. <ul>
  1057. <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>
  1058. <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>
  1059. <li><code>onMove(item, callback)</code> Fired when an item has been moved. If not implemented, the move action will be accepted.</li>
  1060. <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>
  1061. <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>
  1062. </ul>
  1063. <p>
  1064. Each of the callbacks is invoked with two arguments:
  1065. </p>
  1066. <ul>
  1067. <li><code>item</code>: the item being manipulated</li>
  1068. <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>
  1069. </ul>
  1070. <p>
  1071. Example code:
  1072. </p>
  1073. <pre class="prettyprint lang-js">var options = {
  1074. onUpdate: function (item, callback) {
  1075. item.content = prompt('Edit items text:', item.content);
  1076. if (item.content != null) {
  1077. callback(item); // send back adjusted item
  1078. }
  1079. else {
  1080. callback(null); // cancel updating the item
  1081. }
  1082. }
  1083. };
  1084. </pre>
  1085. A full example is available here: <a href="../examples/timeline/08_edit_items.html">08_edit_items.html</a>.
  1086. <h2 id="Templates">Templates</h2>
  1087. <p>
  1088. 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:
  1089. </p>
  1090. <pre class="prettyprint lang-js">var options = {
  1091. template: function (item) {
  1092. var html = ... // generate HTML markup for this item
  1093. return html;
  1094. }
  1095. };
  1096. </pre>
  1097. <h3>Create HTML manually</h3>
  1098. The HTML for an item can be created manually:
  1099. <pre class="prettyprint lang-js">var options = {
  1100. template: function (item) {
  1101. return '&lt;h1&gt;' + item.header + '&lt;/h1&gt;&lt;p&gt;' + item.description + '&lt;/p&gt;';
  1102. }
  1103. };
  1104. </pre>
  1105. <h3>Using a template engine</h3>
  1106. Using <a href="http://handlebarsjs.com/">handlebars</a>, one can write the template in HTML:
  1107. <pre class="prettyprint lang-html">
  1108. &lt;script id="item-template" type="text/x-handlebars-template"&gt;
  1109. &lt;h1&gt;{{header}}&lt;/h1&gt;
  1110. &lt;p&gt;{{description}}&lt;/p&gt;
  1111. &lt;/script&gt;
  1112. </pre>
  1113. Compile the template:
  1114. <pre class="prettyprint lang-js">
  1115. var source = document.getElementById('item-template').innerHTML;
  1116. var template = Handlebars.compile(source);
  1117. </pre>
  1118. And then specify the template in the Timeline options
  1119. <pre class="prettyprint lang-js">var options = {
  1120. template: template
  1121. };
  1122. </pre>
  1123. <h3>Multiple templates</h3>
  1124. In order to support multiple templates, the template handler can be extended to switch between different templates, depending on a specific item property:
  1125. <pre class="prettyprint lang-js">
  1126. var templates = {
  1127. template1: Handlebars.compile(...),
  1128. template2: Handlebars.compile(...),
  1129. template2: Handlebars.compile(...),
  1130. ...
  1131. };
  1132. var options = {
  1133. template: function (item) {
  1134. var template = templates[item.template]; // choose the right template
  1135. return template(item); // execute the template
  1136. }
  1137. };
  1138. </pre>
  1139. Now the items can be extended with a property <code>template</code>, specifying which template to use for the item.
  1140. <h2 id="Localization">Localization</h2>
  1141. <p>
  1142. 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.
  1143. </p>
  1144. <p>
  1145. To set a locale for the Timeline, specify the option <code>locale</code>:
  1146. </p>
  1147. <pre class="prettyprint lang-js">var options = {
  1148. locale: 'nl'
  1149. };
  1150. </pre>
  1151. <h3>Create a new locale</h3>
  1152. To load a locale into the Timeline not supported by default, one can add a new locale to the option <code>locales</code>:
  1153. <pre class="prettyprint lang-js">var options = {
  1154. locales: {
  1155. // create a new locale (text strings should be replaced with localized strings)
  1156. mylocale: {
  1157. current: 'current',
  1158. time: 'time',
  1159. }
  1160. },
  1161. // use the new locale
  1162. locale: 'mylocale'
  1163. };
  1164. </pre>
  1165. <h3 id="available-locales">Available locales</h3>
  1166. <p>
  1167. Timeline comes with support for the following locales:
  1168. </p>
  1169. <table>
  1170. <tr><th>Language</th><th>Code</th></tr>
  1171. <tr>
  1172. <td>English</td>
  1173. <td>
  1174. <code>en</code><br>
  1175. <code>en_EN</code><br>
  1176. <code>en_US</code>
  1177. </td>
  1178. </tr>
  1179. <tr>
  1180. <td>Dutch</td>
  1181. <td>
  1182. <code>nl</code><br>
  1183. <code>nl_NL</code><br>
  1184. <code>nl_BE</code>
  1185. </td>
  1186. </tr>
  1187. </table>
  1188. <h2 id="Styles">Styles</h2>
  1189. <p>
  1190. All parts of the Timeline have a class name and a default css style.
  1191. The styles can be overwritten, which enables full customization of the layout
  1192. of the Timeline.
  1193. </p>
  1194. <p>For example, to change the border and background color of all items, include the
  1195. following code inside the head of your html code or in a separate stylesheet.</p>
  1196. <pre class="prettyprint lang-html">&lt;style&gt;
  1197. .vis.timeline .item {
  1198. border-color: orange;
  1199. background-color: yellow;
  1200. }
  1201. &lt;/style&gt;
  1202. </pre>
  1203. <h3 id="Grid_Backgrounds">Grid Backgrounds</h3>
  1204. <p>
  1205. The background grid of the time axis can be styled, for example to highlight
  1206. weekends or to create grids with an alternating white/lightgray background.
  1207. </p>
  1208. <p>
  1209. Depending on the zoom level, the grids get certain css classes attached.
  1210. The following classes are available:
  1211. </p>
  1212. <table>
  1213. <tr>
  1214. <th>Description</th><th>values</th>
  1215. </tr>
  1216. <tr>
  1217. <td>Alternating columns</td><td><code>even</code>, <code>odd</code></td>
  1218. </tr>
  1219. <tr>
  1220. <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>
  1221. </tr>
  1222. <tr>
  1223. <td>Hours</td><td><code>0h</code>, <code>1h</code>, ..., <code>23h</code></td>
  1224. </tr>
  1225. <tr>
  1226. <td>Grouped hours</td><td><code>0-4h</code> to <code>20-24h</code></td>
  1227. </tr>
  1228. <tr>
  1229. <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>
  1230. </tr>
  1231. <tr>
  1232. <td>Days</td><td><code>date1</code>, <code>date2</code>, ..., <code>date31</code></td>
  1233. </tr>
  1234. <tr>
  1235. <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>
  1236. </tr>
  1237. <tr>
  1238. <td>Years</td><td><code>year2014</code>, <code>year2015</code>, ...</td>
  1239. </tr>
  1240. </table>
  1241. <p>Examples:</p>
  1242. <pre class="prettyprint lang-html">&lt;style&gt;
  1243. /* alternating column backgrounds */
  1244. .vis.timeline .timeaxis .grid.odd {
  1245. background: #f5f5f5;
  1246. }
  1247. /* gray background in weekends, white text color */
  1248. .vis.timeline .timeaxis .grid.saturday,
  1249. .vis.timeline .timeaxis .grid.sunday {
  1250. background: gray;
  1251. }
  1252. .vis.timeline .timeaxis .text.saturday,
  1253. .vis.timeline .timeaxis .text.sunday {
  1254. color: white;
  1255. }
  1256. &lt;/style&gt;
  1257. </pre>
  1258. <h2 id="Data_Policy">Data Policy</h2>
  1259. <p>
  1260. All code and data is processed and rendered in the browser.
  1261. No data is sent to any server.
  1262. </p>
  1263. </div>
  1264. </body>
  1265. </html>