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.

1643 lines
63 KiB

9 years ago
  1. <!DOCTYPE html>
  2. <html lang="en"><head>
  3. <meta charset="utf-8">
  4. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <meta name="description" content="">
  7. <meta name="author" content="">
  8. <link rel="icon" HREF="favicon.ico">
  9. <title>timeline - vis.js - A dynamic, browser based visualization library.</title>
  10. <!-- Bootstrap core CSS -->
  11. <link href="../css/bootstrap.css" rel="stylesheet">
  12. <!-- Tipue vendor css -->
  13. <link href="../css/tipuesearch.css" rel="stylesheet">
  14. <link href="../css/style.css" rel="stylesheet">
  15. <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  16. <!--[if lt IE 9]>
  17. <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  18. <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  19. <![endif]-->
  20. <link href="../css/prettify.css" type="text/css" rel="stylesheet"/>
  21. <script type="text/javascript" src="../js/googleAnalytics.js"></script>
  22. <script type="text/javascript" src="../js/prettify/prettify.js"></script>
  23. <script src="../js/smooth-scroll.min.js"></script>
  24. <script language="JavaScript">
  25. smoothScroll.init();
  26. </script>
  27. <!-- Tipue vendor css -->
  28. <link href="../css/tipuesearch.css" rel="stylesheet">
  29. <!-- Tipue vendor css -->
  30. <link href="../css/tipuesearch.css" rel="stylesheet">
  31. <script type="text/javascript" src="../js/toggleTable.js"></script>
  32. </head>
  33. <body onload="prettyPrint();">
  34. <div class="navbar-wrapper">
  35. <div class="container">
  36. <nav class="navbar navbar-inverse navbar-static-top" role="navigation">
  37. <div class="container">
  38. <div class="navbar-header">
  39. <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
  40. aria-expanded="false" aria-controls="navbar">
  41. <span class="sr-only">Toggle navigation</span>
  42. <span class="icon-bar"></span>
  43. <span class="icon-bar"></span>
  44. <span class="icon-bar"></span>
  45. </button>
  46. <a class="navbar-brand hidden-sm" href="./index.html">vis.js</a>
  47. </div>
  48. <div id="navbar" class="navbar-collapse collapse">
  49. <ul class="nav navbar-nav">
  50. <li><a href="http://www.visjs.org/index.html#modules">Modules</a></li>
  51. <li><a href="http://www.visjs.org/blog.html">Blog</a></li>
  52. <li><a href="http://www.visjs.org/index.html#download_install">Download</a></li>
  53. <li><a href="http://www.visjs.org/showcase/index.html">Showcase</a></li>
  54. <li><a href="http://www.visjs.org/index.html#contribute">Contribute</a></li>
  55. <li><a href="http://www.visjs.org/featureRequests.html">Feature requests</a></li>
  56. <li><a href="http://www.visjs.org/index.html#licenses">License</a></li>
  57. </ul>
  58. </div>
  59. </div>
  60. </nav>
  61. </div>
  62. </div>
  63. <a href="https://github.com/almende/vis" class="hidden-xs hidden-sm hidden-md"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
  64. <div class="container full">
  65. <h1>Timeline</h1>
  66. <h2 id="Overview">Overview</h2>
  67. <p>
  68. The Timeline is an interactive visualization chart to visualize data in time.
  69. The data items can take place on a single date, or have a start and end date (a range).
  70. You can freely move and zoom in the timeline by dragging and scrolling in the
  71. Timeline. Items can be created, edited, and deleted in the timeline.
  72. The time scale on the axis is adjusted automatically, and supports scales ranging
  73. from milliseconds to years.
  74. </p>
  75. <p>
  76. Timeline uses regular HTML DOM to render the timeline and items put on the
  77. timeline. This allows for flexible customization using css styling.
  78. </p>
  79. <h2 id="Contents">Contents</h2>
  80. <ul>
  81. <li><a href="#Overview">Overview</a></li>
  82. <li><a href="#Example">Example</a></li>
  83. <li><a href="#Loading">Loading</a></li>
  84. <li><a href="#Data_Format">Data Format</a>
  85. <ul>
  86. <li><a href="#items">Items</a></li>
  87. <li><a href="#groups">Groups</a></li>
  88. </ul>
  89. </li>
  90. <li><a href="#Configuration_Options">Configuration Options</a></li>
  91. <li><a href="#Methods">Methods</a></li>
  92. <li><a href="#Events">Events</a></li>
  93. <li><a href="#Editing_Items">Editing Items</a></li>
  94. <li><a href="#Templates">Templates</a></li>
  95. <li><a href="#Localization">Localization</a></li>
  96. <li><a href="#Styles">Styles</a></li>
  97. <li><a href="#Data_Policy">Data Policy</a></li>
  98. </ul>
  99. <h2 id="Example">Example</h2>
  100. <p>
  101. The following code shows how to create a Timeline and provide it with data.
  102. More examples can be found in the <a href="../examples">examples</a> directory.
  103. </p>
  104. <pre class="prettyprint lang-html">&lt;!DOCTYPE HTML&gt;
  105. &lt;html&gt;
  106. &lt;head&gt;
  107. &lt;title&gt;Timeline | Basic demo&lt;/title&gt;
  108. &lt;style type="text/css"&gt;
  109. body, html {
  110. font-family: sans-serif;
  111. }
  112. &lt;/style&gt;
  113. &lt;script src="../../dist/vis.js"&gt;&lt;/script&gt;
  114. &lt;link href="../../dist/vis.css" rel="stylesheet" type="text/css" /&gt;
  115. &lt;/head&gt;
  116. &lt;body&gt;
  117. &lt;div id="visualization"&gt;&lt;/div&gt;
  118. &lt;script type="text/javascript"&gt;
  119. // DOM element where the Timeline will be attached
  120. var container = document.getElementById('visualization');
  121. // Create a DataSet (allows two way data-binding)
  122. var items = new vis.DataSet([
  123. {id: 1, content: 'item 1', start: '2013-04-20'},
  124. {id: 2, content: 'item 2', start: '2013-04-14'},
  125. {id: 3, content: 'item 3', start: '2013-04-18'},
  126. {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
  127. {id: 5, content: 'item 5', start: '2013-04-25'},
  128. {id: 6, content: 'item 6', start: '2013-04-27'}
  129. ]);
  130. // Configuration for the Timeline
  131. var options = {};
  132. // Create a Timeline
  133. var timeline = new vis.Timeline(container, items, options);
  134. &lt;/script&gt;
  135. &lt;/body&gt;
  136. &lt;/html&gt;
  137. </pre>
  138. <h2 id="Loading">Loading</h2>
  139. <p>
  140. Install or download the <a href="http://visjs.org" target="_blank">vis.js</a> library.
  141. in a subfolder of your project. Include the libraries script and css files in the
  142. head of your html code:
  143. </p>
  144. <pre class="prettyprint lang-html">
  145. &lt;script src="vis/dist/vis.js"&gt;&lt;/script&gt;
  146. &lt;link href="vis/dist/vis.css" rel="stylesheet" type="text/css" /&gt;
  147. </pre>
  148. The constructor of the Timeline is <code>vis.Timeline</code>
  149. <pre class="prettyprint lang-js">var timeline = new vis.Timeline(container, items, options);</pre>
  150. or when using groups:
  151. <pre class="prettyprint lang-js">var timeline = new vis.Timeline(container, items, groups, options);</pre>
  152. The constructor accepts four parameters:
  153. <ul>
  154. <li>
  155. <code>container</code> is the DOM element in which to create the timeline.
  156. </li>
  157. <li>
  158. <code>items</code> is an Array containing items. The properties of an
  159. item are described in section <a href="#Data_Format">Data Format, items</a>.
  160. </li><li>
  161. <code>groups</code> is an Array containing groups. The properties of a
  162. group are described in section <a href="#groups">Data Format, groups</a>.
  163. </li>
  164. <li>
  165. <code>options</code> is an optional Object containing a name-value map
  166. with options. Options can also be set using the method
  167. <code>setOptions</code>.
  168. </li>
  169. </ul>
  170. <h2 id="Data_Format">Data Format</h2>
  171. <p>
  172. The timeline can be provided with two types of data:
  173. </p>
  174. <ul>
  175. <li><a href="#items">Items</a> containing a set of items to be displayed in time.</li>
  176. <li><a href="#groups">Groups</a> containing a set of groups used to group items
  177. together.</li>
  178. </ul>
  179. <h3 id="items">Items</h3>
  180. <p>
  181. The Timeline uses regular Arrays and Objects as data format.
  182. Data items can contain the properties <code>start</code>,
  183. <code>end</code> (optional), <code>content</code>,
  184. <code>group</code> (optional), <code>className</code> (optional),
  185. <code>editable</code> (optional), and <code>style</code> (optional).
  186. </p>
  187. <p>
  188. A table is constructed as:
  189. </p>
  190. <pre class="prettyprint lang-js">
  191. var items = [
  192. {
  193. start: new Date(2010, 7, 15),
  194. end: new Date(2010, 8, 2), // end is optional
  195. content: 'Trajectory A'
  196. // Optional: fields 'id', 'type', 'group', 'className', 'style'
  197. }
  198. // more items...
  199. ]);
  200. </pre>
  201. <p>
  202. The item properties are defined as:
  203. </p>
  204. <table class="properties">
  205. <tr>
  206. <th>Name</th>
  207. <th>Type</th>
  208. <th>Required</th>
  209. <th>Description</th>
  210. </tr>
  211. <tr>
  212. <td>className</td>
  213. <td>String</td>
  214. <td>no</td>
  215. <td>This field is optional. A className can be used to give items
  216. an individual css style. For example, when an item has className
  217. 'red', one can define a css style like:
  218. <pre class="prettyprint lang-css">
  219. .vis-item.red {
  220. color: white;
  221. background-color: red;
  222. border-color: darkred;
  223. }</pre>
  224. More details on how to style items can be found in the section
  225. <a href="#Styles">Styles</a>.
  226. </td>
  227. </tr>
  228. <tr>
  229. <td>content</td>
  230. <td>String</td>
  231. <td>yes</td>
  232. <td>The contents of the item. This can be plain text or html code.</td>
  233. </tr>
  234. <tr>
  235. <td>end</td>
  236. <td>Date or number or string or Moment</td>
  237. <td>no</td>
  238. <td>The end date of the item. The end date is optional, and can be left <code>null</code>.
  239. If end date is provided, the item is displayed as a range.
  240. If not, the item is displayed as a box.</td>
  241. </tr>
  242. <tr>
  243. <td>group</td>
  244. <td>any type</td>
  245. <td>no</td>
  246. <td>This field is optional. When the group column is provided,
  247. all items with the same group are placed on one line.
  248. A vertical axis is displayed showing the groups.
  249. Grouping items can be useful for example when showing availability of multiple
  250. people, rooms, or other resources next to each other.<br>
  251. </td>
  252. </tr>
  253. <tr>
  254. <td>id</td>
  255. <td>String or Number</td>
  256. <td>no</td>
  257. <td>An id for the item. Using an id is not required but highly
  258. recommended. An id is needed when dynamically adding, updating,
  259. and removing items in a DataSet.</td>
  260. </tr>
  261. <tr>
  262. <td>start</td>
  263. <td>Date or number or string or Moment</td>
  264. <td>yes</td>
  265. <td>The start date of the item, for example <code>new Date(2010,9,23)</code>.</td>
  266. </tr>
  267. <tr>
  268. <td>style</td>
  269. <td>String</td>
  270. <td>no</td>
  271. <td>
  272. A css text string to apply custom styling for an individual item, for
  273. example <code>"color: red; background-color: pink;"</code>.
  274. </td>
  275. </tr>
  276. <tr>
  277. <td>subgroup</td>
  278. <td>String or Number</td>
  279. <td>none</td>
  280. <td>The id of a subgroup.
  281. Groups all items within a group per subgroup, and positions them on the
  282. same height instead of staking them on top of each other. can be ordered
  283. by specifying the option <code>subgroupOrder</code> of a group.
  284. </td>
  285. </tr>
  286. <tr>
  287. <td>title</td>
  288. <td>String</td>
  289. <td>none</td>
  290. <td>Add a title for the item, displayed when holding the mouse on the item.
  291. The title can only contain plain text.
  292. </td>
  293. </tr>
  294. <tr>
  295. <td>type</td>
  296. <td>String</td>
  297. <td>no</td>
  298. <td>The type of the item. Can be 'box' (default), 'point', 'range', or 'background'.
  299. Types 'box' and 'point' need a start date, the types 'range' and 'background' needs both a start and end date.
  300. </td>
  301. </tr>
  302. <tr>
  303. <td>editable</td>
  304. <td>Boolean</td>
  305. <td>no</td>
  306. <td>Override the editable option of the timeline for a specific item.</td>
  307. </table>
  308. <h3 id="groups">Groups</h3>
  309. <p>
  310. Like the items, groups are regular JavaScript Arrays and Objects.
  311. Using groups, items can be grouped together.
  312. Items are filtered per group, and displayed as
  313. Group items can contain the properties <code>id</code>,
  314. <code>content</code>, and <code>className</code> (optional).
  315. </p>
  316. <p>
  317. Groups can be applied to a timeline using the method <code>setGroups</code> or supplied in the constructor.
  318. A table with groups can be created like:
  319. </p>
  320. <pre class="prettyprint lang-js">
  321. var groups = [
  322. {
  323. id: 1,
  324. content: 'Group 1'
  325. // Optional: a field 'className', 'style'
  326. }
  327. // more groups...
  328. ]);
  329. </pre>
  330. <p>
  331. Groups can have the following properties:
  332. </p>
  333. <table class="properties">
  334. <tr>
  335. <th>Name</th>
  336. <th>Type</th>
  337. <th>Required</th>
  338. <th>Description</th>
  339. </tr>
  340. <tr>
  341. <td>className</td>
  342. <td>String</td>
  343. <td>no</td>
  344. <td>This field is optional. A className can be used to give groups
  345. an individual css style. For example, when a group has className
  346. 'red', one can define a css style
  347. <code>
  348. .red {
  349. color: red;
  350. }
  351. </code>.
  352. More details on how to style groups can be found in the section
  353. <a href="#Styles">Styles</a>.
  354. </td>
  355. </tr>
  356. <tr>
  357. <td>content</td>
  358. <td>String</td>
  359. <td>yes</td>
  360. <td>The contents of the group. This can be plain text or html code.</td>
  361. </tr>
  362. <tr>
  363. <td>id</td>
  364. <td>String or Number</td>
  365. <td>yes</td>
  366. <td>An id for the group. The group will display all items having a
  367. property <code>group</code> which matches the <code>id</code>
  368. of the group.</td>
  369. </tr>
  370. <tr>
  371. <td>style</td>
  372. <td>String</td>
  373. <td>no</td>
  374. <td>
  375. A css text string to apply custom styling for an individual group label, for
  376. example <code>"color: red; background-color: pink;"</code>.
  377. </td>
  378. </tr>
  379. <tr>
  380. <td>subgroupOrder</td>
  381. <td>String or Function</td>
  382. <td>none</td>
  383. <td>Order the subgroups by a field name or custom sort function.
  384. By default, groups are ordered by first-come, first-show.
  385. </td>
  386. </tr>
  387. <tr>
  388. <td>title</td>
  389. <td>String</td>
  390. <td>none</td>
  391. <td>A title for the group, displayed when holding the mouse on the groups label.
  392. The title can only contain plain text.
  393. </td>
  394. </tr>
  395. </table>
  396. <h2 id="Configuration_Options">Configuration Options</h2>
  397. <p>
  398. Options can be used to customize the timeline.
  399. Options are defined as a JSON object. All options are optional.
  400. </p>
  401. <pre class="prettyprint lang-js">
  402. var options = {
  403. width: '100%',
  404. height: '30px',
  405. margin: {
  406. item: 20
  407. }
  408. };
  409. </pre>
  410. <p>
  411. The following options are available.
  412. </p>
  413. <table class="options" id="optionTable">
  414. <tr>
  415. <th>Name</th>
  416. <th>Type</th>
  417. <th>Default</th>
  418. <th>Description</th>
  419. </tr>
  420. <tr>
  421. <td>align</td>
  422. <td>String</td>
  423. <td><code>'center'</code></td>
  424. <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>
  425. </tr>
  426. <tr>
  427. <td>autoResize</td>
  428. <td>boolean</td>
  429. <td><code>true</code></td>
  430. <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>
  431. </tr>
  432. <tr>
  433. <td>clickToUse</td>
  434. <td>boolean</td>
  435. <td><code>false</code></td>
  436. <td>When a Timeline is configured to be <code>clickToUse</code>, it will react to mouse and touch events only when active.
  437. 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>
  438. </tr>
  439. <tr>
  440. <td>configure</td>
  441. <td>boolean or function</td>
  442. <td><code>false</code></td>
  443. <td>When true, a configurator is loaded where all configuration options of the Timeline can be changed live.
  444. The displayed options can be filtered by providing a filter function. This function is invoked with two arguments: the current <code>option</code> and the <code>path</code> (an Array) of the option within the options object. The option will be displayed when the filter function returns true. For example to only display format options:
  445. <pre class="prettyprint lang-js">
  446. function (option, path) {
  447. return option === 'format' || path.indexOf('format') !== -1;
  448. }</pre>
  449. </td>
  450. </tr>
  451. <tr>
  452. <td>dataAttributes</td>
  453. <td>string[] or 'all'</string></td>
  454. <td><code>false</code></td>
  455. <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>
  456. If value is <code>'all'</code> then each field defined on the timeline item will become a <code>data-</code> attribute.</td>
  457. </tr>
  458. <tr class='toggle collapsible' onclick="toggleTable('optionTable','editable', this);">
  459. <td><span parent="editable" class="right-caret"></span> editable</td>
  460. <td>boolean or Object</td>
  461. <td><code>false</code></td>
  462. <td>If true, the items in the timeline can be manipulated. Only applicable when option <code>selectable</code> is <code><code>true</code></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.
  463. See section <a href="#Editing_Items">Editing Items</a> for a detailed explanation.
  464. </td>
  465. </tr>
  466. <tr parent="editable" class="hidden">
  467. <td class="indent">editable.add</td>
  468. <td>boolean</td>
  469. <td><code>false</code></td>
  470. <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>
  471. </tr>
  472. <tr parent="editable" class="hidden">
  473. <td class="indent">editable.remove</td>
  474. <td>boolean</td>
  475. <td><code>false</code></td>
  476. <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>
  477. </tr>
  478. <tr parent="editable" class="hidden">
  479. <td class="indent">editable.updateGroup</td>
  480. <td>boolean</td>
  481. <td><code>false</code></td>
  482. <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>
  483. </tr>
  484. <tr parent="editable" class="hidden">
  485. <td class="indent">editable.updateTime</td>
  486. <td>boolean</td>
  487. <td><code>false</code></td>
  488. <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>
  489. </tr>
  490. <tr>
  491. <td>end</td>
  492. <td>Date or Number or String or Moment</td>
  493. <td>none</td>
  494. <td>The initial end date for the axis of the timeline.
  495. If not provided, the latest date present in the items set is taken as
  496. end date.</td>
  497. </tr>
  498. <tr>
  499. <td>format</td>
  500. <td>Object</td>
  501. <td>none</td>
  502. <td>
  503. Apply custom date formatting of the labels on the time axis. The default value of <code>format</code> is:
  504. <pre class="prettyprint lang-js">{
  505. minorLabels: {
  506. millisecond:'SSS',
  507. second: 's',
  508. minute: 'HH:mm',
  509. hour: 'HH:mm',
  510. weekday: 'ddd D',
  511. day: 'D',
  512. month: 'MMM',
  513. year: 'YYYY'
  514. },
  515. majorLabels: {
  516. millisecond:'HH:mm:ss',
  517. second: 'D MMMM HH:mm',
  518. minute: 'ddd D MMMM',
  519. hour: 'ddd D MMMM',
  520. weekday: 'MMMM YYYY',
  521. day: 'MMMM YYYY',
  522. month: 'YYYY',
  523. year: ''
  524. }
  525. }</pre>
  526. For values which not provided in the customized <code>options.format</code>, the default values will be used.
  527. All available formatting syntax is described in the <a href="http://momentjs.com/docs/#/displaying/format/">docs of moment.js</a>.
  528. </td>
  529. </tr>
  530. <tr>
  531. <td>groupOrder</td>
  532. <td>String or Function</td>
  533. <td>none</td>
  534. <td>Order the groups by a field name or custom sort function.
  535. By default, groups are not ordered.
  536. </td>
  537. </tr>
  538. <tr>
  539. <td>groupTemplate</td>
  540. <td>function</td>
  541. <td>none</td>
  542. <td>A template function used to generate the contents of the groups. The function is called by the Timeline with a groups data as argument, and must return HTML code as result. When the option groupTemplate is specified, the groups do not need to have a field <code>content</code>. See section <a href="#Templates">Templates</a> for a detailed explanation.</td>
  543. </tr>
  544. <tr>
  545. <td>height</td>
  546. <td>number or String</td>
  547. <td>none</td>
  548. <td>The height of the timeline in pixels or as a percentage.
  549. When height is undefined or null, the height of the timeline is automatically
  550. adjusted to fit the contents.
  551. It is possible to set a maximum height using option <code>maxHeight</code>
  552. to prevent the timeline from getting too high in case of automatically
  553. calculated height.
  554. </td>
  555. </tr>
  556. <tr>
  557. <td>hiddenDates</td>
  558. <td>Object</td>
  559. <td>none</td>
  560. <td>This option allows you to hide specific timespans from the time axis. The dates can be supplied as an object:
  561. <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.
  562. 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
  563. and set repeat to weekly.
  564. </td>
  565. </tr>
  566. <tr>
  567. <td>locale</td>
  568. <td>String</td>
  569. <td>none</td>
  570. <td>Select a locale for the Timeline. See section <a href="#Localization">Localization</a> for more information.</td>
  571. </tr>
  572. <tr>
  573. <td>locales</td>
  574. <td>Object</td>
  575. <td>none</td>
  576. <td>A map with i18n locales. See section <a href="#Localization">Localization</a> for more information.</td>
  577. </tr>
  578. <tr class='toggle collapsible' onclick="toggleTable('optionTable','margin', this);">
  579. <td><span parent="margin" class="right-caret"></span> margin</td>
  580. <td>number or Object</td>
  581. <td>Object</td>
  582. <td>When a number, applies the margin to <code>margin.axis</code>, <code>margin.item.horizontal</code>, and <code>margin.item.vertical</code>.</td>
  583. </tr>
  584. <tr parent="margin" class="hidden">
  585. <td class="indent">margin.axis</td>
  586. <td>number</td>
  587. <td><code>20</code></td>
  588. <td>The minimal margin in pixels between items and the time axis.</td>
  589. </tr>
  590. <tr parent="margin" class="hidden">
  591. <td class="indent">margin.item</td>
  592. <td>number</td>
  593. <td><code>10</code></td>
  594. <td>The minimal margin in pixels between items in both horizontal and vertical direction.</td>
  595. </tr>
  596. <tr parent="margin" class="hidden">
  597. <td class="indent2">margin.item.horizontal</td>
  598. <td>number</td>
  599. <td><code>10</code></td>
  600. <td>The minimal horizontal margin in pixels between items.</td>
  601. </tr>
  602. <tr parent="margin" class="hidden">
  603. <td class="indent2">margin.item.vertical</td>
  604. <td>number</td>
  605. <td><code>10</code></td>
  606. <td>The minimal vertical margin in pixels between items.</td>
  607. </tr>
  608. <tr>
  609. <td>max</td>
  610. <td>Date or Number or String or Moment</td>
  611. <td>none</td>
  612. <td>Set a maximum Date for the visible range.
  613. It will not be possible to move beyond this maximum.
  614. </td>
  615. </tr>
  616. <tr>
  617. <td>maxHeight</td>
  618. <td>number or String</td>
  619. <td>none</td>
  620. <td>Specifies the maximum height for the Timeline. Can be a number in pixels or a string like "300px".</td>
  621. </tr>
  622. <tr>
  623. <td>min</td>
  624. <td>Date or Number or String or Moment</td>
  625. <td>none</td>
  626. <td>Set a minimum Date for the visible range.
  627. It will not be possible to move beyond this minimum.
  628. </td>
  629. </tr>
  630. <tr>
  631. <td>minHeight</td>
  632. <td>number or String</td>
  633. <td>none</td>
  634. <td>Specifies the minimum height for the Timeline. Can be a number in pixels or a string like "300px".</td>
  635. </tr>
  636. <tr>
  637. <td>moveable</td>
  638. <td>boolean</td>
  639. <td><code>true</code></td>
  640. <td>
  641. Specifies whether the Timeline can be moved and zoomed by dragging the window.
  642. See also option <code>zoomable</code>.
  643. </td>
  644. </tr>
  645. <tr>
  646. <td>multiselect</td>
  647. <td>boolean</td>
  648. <td><code>false</code></td>
  649. <td>
  650. If true, multiple items can be selected using ctrl+click, shift+click, or by holding items.
  651. Only applicable when option <code>selectable</code> is <code>true</code>.
  652. </td>
  653. </tr>
  654. <tr>
  655. <td>onAdd</td>
  656. <td>function</td>
  657. <td>none</td>
  658. <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><code>true</code></code>.
  659. </td>
  660. </tr>
  661. <tr>
  662. <td>onUpdate</td>
  663. <td>function</td>
  664. <td>none</td>
  665. <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><code>true</code></code>.
  666. </td>
  667. </tr>
  668. <tr>
  669. <td>onMove</td>
  670. <td>function</td>
  671. <td>none</td>
  672. <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><code>true</code></code>.
  673. </td>
  674. </tr>
  675. <tr>
  676. <td>onMoving</td>
  677. <td>function</td>
  678. <td>none</td>
  679. <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><code>true</code></code>.
  680. </td>
  681. </tr>
  682. <tr>
  683. <td>onRemove</td>
  684. <td>function</td>
  685. <td>none</td>
  686. <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><code>true</code></code>.
  687. </td>
  688. </tr>
  689. <tr>
  690. <td>order</td>
  691. <td>function</td>
  692. <td>none</td>
  693. <td>
  694. <p>Provide a custom sort function to order the items. The order of the
  695. items is determining the way they are stacked. The function
  696. order is called with two arguments containing the data of two items to be
  697. compared.
  698. </p>
  699. <p style="font-style: italic">WARNING: Use with caution. Custom ordering is not suitable for large amounts of items. On load, the Timeline will render all items once to determine their width and height. Keep the number of items in this configuration limited to a maximum of a few hundred items.</p>
  700. </td>
  701. </tr>
  702. <tr class='toggle collapsible' onclick="toggleTable('optionTable','orientation', this);">
  703. <td><span parent="orientation" class="right-caret"></span> orientation</td>
  704. <td>String or Object</td>
  705. <td><code>'bottom'</code></td>
  706. <td>Orientation of the timelines axis and items. When orientation is a string, the value is applied to both items and axis. Can be 'top', 'bottom' (default), 'both', or 'none'.</td>
  707. </tr>
  708. <tr parent="orientation" class="hidden">
  709. <td class="indent">orientation.axis</td>
  710. <td>String</td>
  711. <td><code>'bottom'</code></td>
  712. <td>Orientation of the timeline axis: 'top', 'bottom' (default), 'both', or 'none'. If orientation is 'bottom', the time axis is drawn at the bottom. When 'top', the axis is drawn on top. When 'both', two axes are drawn, both on top and at the bottom. In case of 'none', no axis is drawn at all.</td>
  713. </tr>
  714. <tr parent="orientation" class="hidden">
  715. <td class="indent">orientation.item</td>
  716. <td>String</td>
  717. <td><code>'bottom'</code></td>
  718. <td>Orientation of the timeline items: 'top' or 'bottom' (default). Determines whether items are aligned to the top or bottom of the Timeline.</td>
  719. </tr>
  720. <tr>
  721. <td>selectable</td>
  722. <td>boolean</td>
  723. <td><code>true</code></td>
  724. <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>
  725. </tr>
  726. <tr>
  727. <td>showCurrentTime</td>
  728. <td>boolean</td>
  729. <td><code>true</code></td>
  730. <td>Show a vertical bar at the current time.</td>
  731. </tr>
  732. <tr>
  733. <tr>
  734. <td>showMajorLabels</td>
  735. <td>boolean</td>
  736. <td><code>true</code></td>
  737. <td>By default, the timeline shows both minor and major date labels on the
  738. time axis.
  739. For example the minor labels show minutes and the major labels show hours.
  740. When <code>showMajorLabels</code> is <code><code>false</code></code>, no major labels
  741. are shown.</td>
  742. </tr>
  743. <tr>
  744. <td>showMinorLabels</td>
  745. <td>boolean</td>
  746. <td><code>true</code></td>
  747. <td>By default, the timeline shows both minor and major date labels on the
  748. time axis.
  749. For example the minor labels show minutes and the major labels show hours.
  750. When <code>showMinorLabels</code> is <code><code>false</code></code>, no minor labels
  751. are shown. When both <code>showMajorLabels</code> and
  752. <code>showMinorLabels</code> are false, no horizontal axis will be
  753. visible.</td>
  754. </tr>
  755. <tr>
  756. <td>stack</td>
  757. <td>boolean</td>
  758. <td><code>true</code></td>
  759. <td>If true (default), items will be stacked on top of each other such that they do not overlap.</td>
  760. </tr>
  761. <tr>
  762. <td>snap</td>
  763. <td>function or null</td>
  764. <td>function</td>
  765. <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:
  766. <pre class="prettyprint lang-js">function snap(date: Date, scale: string, step: number) : Date or number</pre>
  767. 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.
  768. </td>
  769. </tr>
  770. <tr>
  771. <td>start</td>
  772. <td>Date or Number or String or Moment</td>
  773. <td>none</td>
  774. <td>The initial start date for the axis of the timeline.
  775. If not provided, the earliest date present in the events is taken as start date.</td>
  776. </tr>
  777. <tr>
  778. <td>template</td>
  779. <td>function</td>
  780. <td>none</td>
  781. <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>
  782. </tr>
  783. <tr class='toggle collapsible' onclick="toggleTable('optionTable','timeAxis', this);">
  784. <td><span parent="timeAxis" class="right-caret"></span> timeAxis</td>
  785. <td>Object</td>
  786. <td><code>Object</code></td>
  787. <td>Specify a fixed scale and step size for the time axis.</td>
  788. </tr>
  789. <tr parent="timeAxis" class="hidden">
  790. <td class="indent">timeAxis.scale</td>
  791. <td>String</td>
  792. <td>none</td>
  793. <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:
  794. <pre class="prettyprint lang-js">var options = {
  795. timeAxis: {scale: 'minute', step: 5}
  796. }</pre>
  797. </td>
  798. </tr>
  799. <tr parent="timeAxis" class="hidden">
  800. <td class="indent">timeAxis.step</td>
  801. <td>number</td>
  802. <td><code>1</code></td>
  803. <td>
  804. Set a fixed step size for the time axis. Only applicable when used together with <code>timeAxis.scale</code>.
  805. Choose for example 1, 2, 5, or 10.</td>
  806. </tr>
  807. <tr>
  808. <td>type</td>
  809. <td>String</td>
  810. <td>none</td>
  811. <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.
  812. </td>
  813. </tr>
  814. <tr>
  815. <td>width</td>
  816. <td>String or Number</td>
  817. <td><code>'100%'</code></td>
  818. <td>The width of the timeline in pixels or as a percentage.</td>
  819. </tr>
  820. <tr>
  821. <td>zoomable</td>
  822. <td>boolean</td>
  823. <td><code>true</code></td>
  824. <td>
  825. Specifies whether the Timeline can be zoomed by pinching or scrolling in the window.
  826. Only applicable when option <code>moveable</code> is set <code><code>true</code></code>.
  827. </td>
  828. </tr>
  829. <tr>
  830. <td>zoomKey</td>
  831. <td>String</td>
  832. <td><code>''</code></td>
  833. <td>Specifies whether the Timeline is only zoomed when an additional key is down.
  834. Available values are '' (does not apply), 'altKey', 'ctrlKey', or 'metaKey'.
  835. Only applicable when option <code>moveable</code> is set <code><code>true</code></code>.
  836. </td>
  837. </tr>
  838. <tr>
  839. <td>zoomMax</td>
  840. <td>number</td>
  841. <td><code>315360000000000</code></td>
  842. <td>Set a maximum zoom interval for the visible range in milliseconds.
  843. It will not be possible to zoom out further than this maximum.
  844. Default value equals about 10000 years.
  845. </td>
  846. </tr>
  847. <tr>
  848. <td>zoomMin</td>
  849. <td>number</td>
  850. <td><code>10</code></td>
  851. <td>Set a minimum zoom interval for the visible range in milliseconds.
  852. It will not be possible to zoom in further than this minimum.
  853. </td>
  854. </tr>
  855. </table>
  856. <h2 id="Methods">Methods</h2>
  857. <p>
  858. The Timeline supports the following methods.
  859. </p>
  860. <table class="methods">
  861. <tr>
  862. <th>Method</th>
  863. <th>Return&nbsp;Type</th>
  864. <th>Description</th>
  865. </tr>
  866. <tr>
  867. <td>addCustomTime([time] [, id])</td>
  868. <td>number or String</td>
  869. <td>
  870. Add new vertical bar representing a custom time that can be dragged by the user.
  871. Parameter <code>time</code> can be a Date, Number, or String, and is <code>new Date()</code> by default.
  872. Parameter <code>id</code> can be Number or String and is <code>undefined</code> by default.
  873. The <code>id</code>code> is added as CSS class name of the custom time bar, allowing to style multiple time bars differently.
  874. The method returns id of the created bar.
  875. </td>
  876. </tr>
  877. <tr>
  878. <td>destroy()</td>
  879. <td>none</td>
  880. <td>Destroy the Timeline. The timeline is removed from memory. all DOM elements and event listeners are cleaned up.
  881. </td>
  882. </tr>
  883. <tr>
  884. <td>fit([options])</td>
  885. <td>none</td>
  886. <td>Adjust the visible window such that it fits all items. See also function <code>focus(id)</code>.
  887. Available options:
  888. <ul>
  889. <li><code>animation: boolean or {duration: number, easingFunction: string}</code><br>If true (default) or an Object, the range is animated smoothly to the new window. An object can be provided to specify duration and easing function. Default duration is 500 ms, and default easing function is <code>'easeInOutQuad'</code>. Available easing functions: <code>"linear"</code>, <code>"easeInQuad"</code>, <code>"easeOutQuad"</code>, <code>"easeInOutQuad"</code>, <code>"easeInCubic"</code>, <code>"easeOutCubic"</code>, <code>"easeInOutCubic"</code>, <code>"easeInQuart"</code>, <code>"easeOutQuart"</code>, <code>"easeInOutQuart"</code>, <code>"easeInQuint"</code>, <code>"easeOutQuint"</code>, <code>"easeInOutQuint"</code>.
  890. </li>
  891. </ul>
  892. </td>
  893. </tr>
  894. <tr>
  895. <td>focus(id or ids [, options])</td>
  896. <td>none</td>
  897. <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:
  898. <ul>
  899. <li><code>animation: boolean or {duration: number, easingFunction: string}</code><br>If true (default) or an Object, the range is animated smoothly to the new window. An object can be provided to specify duration and easing function. Default duration is 500 ms, and default easing function is <code>'easeInOutQuad'</code>. Available easing functions: <code>"linear"</code>, <code>"easeInQuad"</code>, <code>"easeOutQuad"</code>, <code>"easeInOutQuad"</code>, <code>"easeInCubic"</code>, <code>"easeOutCubic"</code>, <code>"easeInOutCubic"</code>, <code>"easeInQuart"</code>, <code>"easeOutQuart"</code>, <code>"easeInOutQuart"</code>, <code>"easeInQuint"</code>, <code>"easeOutQuint"</code>, <code>"easeInOutQuint"</code>.</li>
  900. </ul>
  901. </td>
  902. </tr>
  903. <tr>
  904. <td>getCurrentTime()</td>
  905. <td>Date</td>
  906. <td>Get the current time. Only applicable when option <code>showCurrentTime</code> is true.
  907. </td>
  908. </tr>
  909. <tr>
  910. <td>getCustomTime([id])</td>
  911. <td>Date</td>
  912. <td>Retrieve the custom time from the custom time bar with given id. Id is <code>undefined</code> by default.
  913. </td>
  914. </tr>
  915. <tr id="getEventProperties">
  916. <td>getEventProperties(event)</td>
  917. <td>Object</td>
  918. <td>
  919. Returns an Object with relevant properties from an event:
  920. <ul>
  921. <li><code>group</code> (Number or null): the id of the clicked group.</li>
  922. <li><code>item</code> (Number or null): the id of the clicked item.</li>
  923. <li><code>pageX</code> (Number): absolute horizontal position of the click event.</li>
  924. <li><code>pageY</code> (Number): absolute vertical position of the click event.</li>
  925. <li><code>x</code> (Number): relative horizontal position of the click event.</li>
  926. <li><code>y</code> (Number): relative vertical position of the click event.</li>
  927. <li><code>time</code> (Date): Date of the clicked event.</li>
  928. <li><code>snappedTime</code> (Date): Date of the clicked event, snapped to a nice value.</li>
  929. <li><code>what</code> (String or null): name of the clicked thing: <code>item</code>, <code>background</code>, <code>axis</code>, <code>group-label</code>, <code>custom-time</code>, or <code>current-time</code>.</li>
  930. <li><code>event</code> (Object): the original click event.</li>
  931. </ul>
  932. Example usage:
  933. <pre class="prettyprint lang-js">
  934. document.getElementById('myTimeline').onclick = function (event) {
  935. var props = timeline.getEventProperties(event)
  936. console.log(props);
  937. }</pre>
  938. </td>
  939. </tr>
  940. <tr>
  941. <td>getSelection()</td>
  942. <td>number[]</td>
  943. <td>Get an array with the ids of the currently selected items.</td>
  944. </tr>
  945. <tr>
  946. <td>getVisibleItems()</td>
  947. <td>number[]</td>
  948. <td>Get an array with the ids of the currently visible items.</td>
  949. </tr>
  950. <tr>
  951. <td>getWindow()</td>
  952. <td>Object</td>
  953. <td>Get the current visible window. Returns an object with properties <code>start: Date</code> and <code>end: Date</code>.</td>
  954. </tr>
  955. <tr>
  956. <td>moveTo(time [, options])</td>
  957. <td>none</td>
  958. <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:
  959. <ul>
  960. <li><code>animation: boolean or {duration: number, easingFunction: string}</code><br>If true (default) or an Object, the range is animated smoothly to the new window. An object can be provided to specify duration and easing function. Default duration is 500 ms, and default easing function is <code>'easeInOutQuad'</code>. Available easing functions: <code>"linear"</code>, <code>"easeInQuad"</code>, <code>"easeOutQuad"</code>, <code>"easeInOutQuad"</code>, <code>"easeInCubic"</code>, <code>"easeOutCubic"</code>, <code>"easeInOutCubic"</code>, <code>"easeInQuart"</code>, <code>"easeOutQuart"</code>, <code>"easeInOutQuart"</code>, <code>"easeInQuint"</code>, <code>"easeOutQuint"</code>, <code>"easeInOutQuint"</code>.</li>
  961. </ul>
  962. </td>
  963. </tr>
  964. <tr>
  965. <td>on(event, callback)</td>
  966. <td>none</td>
  967. <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>
  968. </tr>
  969. <tr>
  970. <td>off(event, callback)</td>
  971. <td>none</td>
  972. <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>
  973. </tr>
  974. <tr>
  975. <td>redraw()</td>
  976. <td>none</td>
  977. <td>Force a redraw of the Timeline. The size of all items will be recalculated.
  978. Can be useful to manually redraw when option <code>autoResize=false</code> and the window
  979. has been resized, or when the items CSS has been changed.
  980. </td>
  981. </tr>
  982. <tr>
  983. <td>removeCustomTime(id)</td>
  984. <td>none</td>
  985. <td>
  986. 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.
  987. </td>
  988. </tr>
  989. <tr>
  990. <td>setCurrentTime(time)</td>
  991. <td>none</td>
  992. <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.
  993. <code>time</code> can be a Date object, numeric timestamp, or ISO date string.
  994. Only applicable when option <code>showCurrentTime</code> is true.</td>
  995. </tr>
  996. <tr>
  997. <td>setCustomTime(time [, id])</td>
  998. <td>none</td>
  999. <td>Adjust the time of a custom time bar.
  1000. Parameter <code>time</code> can be a Date object, numeric timestamp, or ISO date string.
  1001. Parameter <code>id</code> is the idof the custom time bar, and is <code>undefined</code> by default.
  1002. </td>
  1003. </tr>
  1004. <tr>
  1005. <td>setData({<br>&nbsp;&nbsp;groups: groups,<br>&nbsp;&nbsp;items: items<br>})</td>
  1006. <td>none</td>
  1007. <td>Set both groups and items at once. Both properties are optional. This is a convenience method for individually calling both <code>setItems(items)</code> and <code>setGroups(groups)</code>.
  1008. Both <code>items</code> and <code>groups</code> can be an Array with Objects,
  1009. a DataSet, or a DataView. For each of the groups, the items of the
  1010. timeline are filtered on the property <code>group</code>, which
  1011. must correspond with the id of the group.
  1012. </td>
  1013. </tr>
  1014. <tr>
  1015. <td>setGroups(groups)</td>
  1016. <td>none</td>
  1017. <td>Set a data set with groups for the Timeline.
  1018. <code>groups</code> can be an Array with Objects,
  1019. a DataSet, or a DataView. For each of the groups, the items of the
  1020. timeline are filtered on the property <code>group</code>, which
  1021. must correspond with the id of the group.
  1022. </td>
  1023. </tr>
  1024. <tr>
  1025. <td>setItems(items)</td>
  1026. <td>none</td>
  1027. <td>Set a data set with items for the Timeline.
  1028. <code>items</code> can be an Array with Objects,
  1029. a DataSet, or a DataView.
  1030. </td>
  1031. </tr>
  1032. <tr>
  1033. <td>setOptions(options)</td>
  1034. <td>none</td>
  1035. <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.
  1036. </td>
  1037. </tr>
  1038. <tr>
  1039. <td>setSelection(id or ids [, options])</td>
  1040. <td>none</td>
  1041. <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:
  1042. <ul>
  1043. <li><code>focus: boolean</code><br>If true, focus will be set to the selected item(s)</li>
  1044. <li><code>animation: boolean or {duration: number, easingFunction: string}</code><br>If true (default) or an Object, the range is animated smoothly to the new window. An object can be provided to specify duration and easing function. Default duration is 500 ms, and default easing function is <code>'easeInOutQuad'</code>. Only applicable when option focus is true. Available easing functions: <code>"linear"</code>, <code>"easeInQuad"</code>, <code>"easeOutQuad"</code>, <code>"easeInOutQuad"</code>, <code>"easeInCubic"</code>, <code>"easeOutCubic"</code>, <code>"easeInOutCubic"</code>, <code>"easeInQuart"</code>, <code>"easeOutQuart"</code>, <code>"easeInOutQuart"</code>, <code>"easeInQuint"</code>, <code>"easeOutQuint"</code>, <code>"easeInOutQuint"</code>.</li>
  1045. </ul>
  1046. </td>
  1047. </tr>
  1048. <tr>
  1049. <td>setWindow(start, end [, options])</td>
  1050. <td>none</td>
  1051. <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:
  1052. <ul>
  1053. <li><code>animation: boolean or {duration: number, easingFunction: string}</code><br>If true (default) or an Object, the range is animated smoothly to the new window. An object can be provided to specify duration and easing function. Default duration is 500 ms, and default easing function is <code>'easeInOutQuad'</code>. Available easing functions: <code>"linear"</code>, <code>"easeInQuad"</code>, <code>"easeOutQuad"</code>, <code>"easeInOutQuad"</code>, <code>"easeInCubic"</code>, <code>"easeOutCubic"</code>, <code>"easeInOutCubic"</code>, <code>"easeInQuart"</code>, <code>"easeOutQuart"</code>, <code>"easeInOutQuart"</code>, <code>"easeInQuint"</code>, <code>"easeOutQuint"</code>, <code>"easeInOutQuint"</code>.</li>
  1054. </ul>
  1055. </td>
  1056. </tr>
  1057. </table>
  1058. <h2 id="Events">Events</h2>
  1059. <p>
  1060. Timeline fires events when changing the visible window by dragging, when
  1061. selecting items, and when dragging the custom time bar.
  1062. </p>
  1063. <p>
  1064. Here an example on how to listen for a <code>select</code> event.
  1065. </p>
  1066. <pre class="prettyprint lang-js">
  1067. timeline.on('select', function (properties) {
  1068. alert('selected items: ' + properties.nodes);
  1069. });
  1070. </pre>
  1071. <p>
  1072. A listener can be removed via the function <code>off</code>:
  1073. </p>
  1074. <pre class="prettyprint lang-js">
  1075. function onSelect (properties) {
  1076. alert('selected items: ' + properties.nodes);
  1077. }
  1078. // add event listener
  1079. timeline.on('select', onSelect);
  1080. // do stuff...
  1081. // remove event listener
  1082. timeline.off('select', onSelect);
  1083. </pre>
  1084. <p>
  1085. The following events are available.
  1086. </p>
  1087. <table class="events">
  1088. <tr>
  1089. <th>Name</th>
  1090. <th>Properties</th>
  1091. <th>Description</th>
  1092. </tr>
  1093. <tr>
  1094. <td>click</td>
  1095. <td>
  1096. Passes a properties object as returned by the method <a href="#getEventProperties"><code>Timeline.getEventProperties(event)</code></a>.
  1097. </td>
  1098. <td>Fired when clicked inside the Timeline.
  1099. </td>
  1100. </tr>
  1101. <tr>
  1102. <td>contextmenu</td>
  1103. <td>
  1104. Passes a properties object as returned by the method <a href="#getEventProperties"><code>Timeline.getEventProperties(event)</code></a>.
  1105. </td>
  1106. <td>Fired when right-clicked inside the Timeline. Note that in order to prevent the context menu from showing up, default behavior of the event must be stopped:
  1107. <pre class="prettyprint lang-js">timeline.on('contextmenu', function (props) {
  1108. alert('Right click!');
  1109. props.event.preventDefault();
  1110. });
  1111. </pre>
  1112. </td>
  1113. </tr>
  1114. <tr>
  1115. <td>doubleClick</td>
  1116. <td>
  1117. Passes a properties object as returned by the method <a href="#getEventProperties"><code>Timeline.getEventProperties(event)</code></a>.
  1118. </td>
  1119. <td>Fired when double clicked inside the Timeline.
  1120. </td>
  1121. </tr>
  1122. <tr>
  1123. <td>rangechange</td>
  1124. <td>
  1125. <ul>
  1126. <li><code>start</code> (Number): timestamp of the current start of the window.</li>
  1127. <li><code>end</code> (Number): timestamp of the current end of the window.</li>
  1128. <li><code>byUser</code> (Boolean): change happened because of user drag/zoom.</li>
  1129. </ul>
  1130. </td>
  1131. <td>Fired repeatedly when the timeline window is being changed.
  1132. </td>
  1133. </tr>
  1134. <tr>
  1135. <td>rangechanged</td>
  1136. <td>
  1137. <ul>
  1138. <li><code>start</code> (Number): timestamp of the current start of the window.</li>
  1139. <li><code>end</code> (Number): timestamp of the current end of the window.</li>
  1140. <li><code>byUser</code> (Boolean): change happened because of user drag/zoom.</li>
  1141. </ul>
  1142. </td>
  1143. <td>Fired once after the timeline window has been changed.
  1144. </td>
  1145. </tr>
  1146. <tr>
  1147. <td>select</td>
  1148. <td>
  1149. <ul>
  1150. <li><code>items</code>: an array with the ids of the selected items</li>
  1151. <li><code>event</code>: the original click event</li>
  1152. </ul>
  1153. </td>
  1154. <td>Fired after the user selects or deselects items by tapping or holding them.
  1155. When a use taps an already selected item, the select event is fired again.
  1156. Not fired when the method <code>setSelection</code>is executed.
  1157. </td>
  1158. </tr>
  1159. <tr>
  1160. <td>timechange</td>
  1161. <td>
  1162. <ul>
  1163. <li><code>id</code> (Number or String): custom time bar id.</li>
  1164. <li><code>time</code> (Date): the custom time.</li>
  1165. </ul>
  1166. </td>
  1167. <td>Fired repeatedly when the user is dragging the custom time bar.
  1168. Only available when the custom time bar is enabled.
  1169. </td>
  1170. </tr>
  1171. <tr>
  1172. <td>timechanged</td>
  1173. <td>
  1174. <ul>
  1175. <li><code>id</code> (Number or String): custom time bar id.</li>
  1176. <li><code>time</code> (Date): the custom time.</li>
  1177. </ul>
  1178. </td>
  1179. <td>Fired once after the user has dragged the custom time bar.
  1180. Only available when the custom time bar is enabled.
  1181. </td>
  1182. </tr>
  1183. </table>
  1184. <h2 id="Editing_Items">Editing Items</h2>
  1185. <p>
  1186. When the Timeline is configured to be editable (both options <code>selectable</code> and <code>editable</code> are <code><code>true</code></code>), the user can:
  1187. </p>
  1188. <ul>
  1189. <li>Select an item by clicking it, and use ctrl+click to or shift+click to select multiple items (when <code>multiselect: true</code>).</li>
  1190. <li>Move selected items by dragging them.</li>
  1191. <li>Create a new item by double tapping on an empty space.</li>
  1192. <li>Create a new range item by dragging on an empty space with the ctrl key down.</li>
  1193. <li>Update an item by double tapping it.</li>
  1194. <li>Delete a selected item by clicking the delete button on the top right.</li>
  1195. </ul>
  1196. <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>
  1197. <pre class="prettyprint lang-js">// enable or disable all manipulation actions
  1198. var options = {
  1199. editable: true // true or false
  1200. };
  1201. // enable or disable individual manipulation actions
  1202. var options = {
  1203. editable: {
  1204. add: true, // add new items by double tapping
  1205. updateTime: true, // drag items horizontally
  1206. updateGroup: true, // drag items from one group to another
  1207. remove: true // delete an item by tapping the delete button top right
  1208. }
  1209. };</pre>
  1210. <p>
  1211. Editing can be enabled/disabled for specific items. Setting the property <code>editable</code> to <code>true</code> or <code>false</code> on a data item will override the timeline option.
  1212. </p>
  1213. <pre class="prettyprint lang-js">
  1214. var items = new vis.DataSet([
  1215. {id: 1, content: 'read-only item', start: '2013-04-20', editable: false},
  1216. {id: 2, content: 'editable item', start: '2013-04-14'}
  1217. ]);
  1218. </pre>
  1219. <p>
  1220. One can specify callback functions to validate changes made by the user. There are a number of callback functions for this purpose:
  1221. </p>
  1222. <ul>
  1223. <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>
  1224. <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>
  1225. <li><code>onMove(item, callback)</code> Fired when an item has been moved. If not implemented, the move action will be accepted.</li>
  1226. <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>
  1227. <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>
  1228. </ul>
  1229. <p>
  1230. Each of the callbacks is invoked with two arguments:
  1231. </p>
  1232. <ul>
  1233. <li><code>item</code>: the item being manipulated</li>
  1234. <li><code>callback</code>: a callback function which must be invoked to report back. The callback must be invoked as <code>callback(item or 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>
  1235. </ul>
  1236. <p>
  1237. Example code:
  1238. </p>
  1239. <pre class="prettyprint lang-js">var options = {
  1240. onUpdate: function (item, callback) {
  1241. item.content = prompt('Edit items text:', item.content);
  1242. if (item.content != null) {
  1243. callback(item); // send back adjusted item
  1244. }
  1245. else {
  1246. callback(null); // cancel updating the item
  1247. }
  1248. }
  1249. };
  1250. </pre>
  1251. A full example is available here: <a href="../../examples/timeline/08_manipulation_callbacks.html">08_manipulation_callbacks.html</a>.
  1252. <h2 id="Templates">Templates</h2>
  1253. <p>
  1254. 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:
  1255. </p>
  1256. <pre class="prettyprint lang-js">var options = {
  1257. template: function (item) {
  1258. var html = ... // generate HTML markup for this item
  1259. return html;
  1260. }
  1261. };
  1262. </pre>
  1263. <h3>Create HTML manually</h3>
  1264. The HTML for an item can be created manually:
  1265. <pre class="prettyprint lang-js">var options = {
  1266. template: function (item) {
  1267. return '&lt;h1&gt;' + item.header + '&lt;/h1&gt;&lt;p&gt;' + item.description + '&lt;/p&gt;';
  1268. }
  1269. };
  1270. </pre>
  1271. <h3>Using a template engine</h3>
  1272. Using <a href="http://handlebarsjs.com/">handlebars</a>, one can write the template in HTML:
  1273. <pre class="prettyprint lang-html">
  1274. &lt;script id="item-template" type="text/x-handlebars-template"&gt;
  1275. &lt;h1&gt;{{header}}&lt;/h1&gt;
  1276. &lt;p&gt;{{description}}&lt;/p&gt;
  1277. &lt;/script&gt;
  1278. </pre>
  1279. Compile the template:
  1280. <pre class="prettyprint lang-js">
  1281. var source = document.getElementById('item-template').innerHTML;
  1282. var template = Handlebars.compile(source);
  1283. </pre>
  1284. And then specify the template in the Timeline options
  1285. <pre class="prettyprint lang-js">var options = {
  1286. template: template
  1287. };
  1288. </pre>
  1289. <h3>Multiple templates</h3>
  1290. In order to support multiple templates, the template handler can be extended to switch between different templates, depending on a specific item property:
  1291. <pre class="prettyprint lang-js">
  1292. var templates = {
  1293. template1: Handlebars.compile(...),
  1294. template2: Handlebars.compile(...),
  1295. template2: Handlebars.compile(...),
  1296. ...
  1297. };
  1298. var options = {
  1299. template: function (item) {
  1300. var template = templates[item.template]; // choose the right template
  1301. return template(item); // execute the template
  1302. }
  1303. };
  1304. </pre>
  1305. Now the items can be extended with a property <code>template</code>, specifying which template to use for the item.
  1306. <h2 id="Localization">Localization</h2>
  1307. <p>
  1308. 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.
  1309. </p>
  1310. <p>
  1311. To set a locale for the Timeline, specify the option <code>locale</code>:
  1312. </p>
  1313. <pre class="prettyprint lang-js">var options = {
  1314. locale: 'nl'
  1315. };
  1316. </pre>
  1317. <h3>Create a new locale</h3>
  1318. To load a locale into the Timeline not supported by default, one can add a new locale to the option <code>locales</code>:
  1319. <pre class="prettyprint lang-js">var options = {
  1320. locales: {
  1321. // create a new locale (text strings should be replaced with localized strings)
  1322. mylocale: {
  1323. current: 'current',
  1324. time: 'time',
  1325. }
  1326. },
  1327. // use the new locale
  1328. locale: 'mylocale'
  1329. };
  1330. </pre>
  1331. <h3 id="available-locales">Available locales</h3>
  1332. <p>
  1333. Timeline comes with support for the following locales:
  1334. </p>
  1335. <table>
  1336. <tr>
  1337. <th>Language</th>
  1338. <th>Code</th>
  1339. </tr>
  1340. <tr>
  1341. <td>English</td>
  1342. <td>
  1343. <code>en</code><br>
  1344. <code>en_EN</code><br>
  1345. <code>en_US</code>
  1346. </td>
  1347. </tr>
  1348. <tr>
  1349. <td>Dutch</td>
  1350. <td>
  1351. <code>nl</code><br>
  1352. <code>nl_NL</code><br>
  1353. <code>nl_BE</code>
  1354. </td>
  1355. </tr>
  1356. </table>
  1357. <h2 id="Styles">Styles</h2>
  1358. <p>
  1359. All parts of the Timeline have a class name and a default css style.
  1360. The styles can be overwritten, which enables full customization of the layout
  1361. of the Timeline.
  1362. </p>
  1363. <p>For example, to change the border and background color of all items, include the
  1364. following code inside the head of your html code or in a separate stylesheet.</p>
  1365. <pre class="prettyprint lang-html">&lt;style&gt;
  1366. .vis-item {
  1367. border-color: orange;
  1368. background-color: yellow;
  1369. }
  1370. &lt;/style&gt;
  1371. </pre>
  1372. <h3 id="Grid_Backgrounds">Grid Backgrounds</h3>
  1373. <p>
  1374. The background grid of the time axis can be styled, for example to highlight
  1375. weekends or to create grids with an alternating white/lightgray background.
  1376. </p>
  1377. <p>
  1378. Depending on the zoom level, the grids get certain css classes attached.
  1379. The following classes are available:
  1380. </p>
  1381. <table class="styles">
  1382. <tr>
  1383. <th>Description</th><th>Values</th>
  1384. </tr>
  1385. <tr>
  1386. <td>Alternating columns</td><td><code>vis-even</code>, <code>vis-odd</code></td>
  1387. </tr>
  1388. <tr>
  1389. <td>Current date</td><td><code>vis-today</code>, <code>vis-tomorrow</code>, <code>vis-yesterday</code>, <code>vis-current-week</code>, <code>vis-current-month</code>, <code>vis-current-year</code></td>
  1390. </tr>
  1391. <tr>
  1392. <td>Hours</td><td><code>vis-h0</code>, <code>vis-h1</code>, ..., <code>vis-h23</code></td>
  1393. </tr>
  1394. <tr>
  1395. <td>Grouped hours</td><td><code>vis-h0-h4</code> to <code>vis-h20-h24</code></td>
  1396. </tr>
  1397. <tr>
  1398. <td>Weekday</td><td><code>vis-monday</code>, <code>vis-tuesday</code>, <code>vis-wednesday</code>, <code>vis-thursday</code>, <code>vis-friday</code>, <code>vis-saturday</code>, <code>vis-sunday</code></td>
  1399. </tr>
  1400. <tr>
  1401. <td>Days</td><td><code>vis-date1</code>, <code>vis-date2</code>, ..., <code>vis-date31</code></td>
  1402. </tr>
  1403. <tr>
  1404. <td>Months</td><td><code>vis-januari</code>, <code>vis-februari</code>, <code>vis-march</code>, <code>vis-april</code>, <code>vis-may</code>, <code>vis-june</code>, <code>vis-july</code>, <code>vis-august</code>, <code>vis-september</code>, <code>vis-october</code>, <code>vis-november</code>, <code>vis-december</code></td>
  1405. </tr>
  1406. <tr>
  1407. <td>Years</td><td><code>vis-year2014</code>, <code>vis-year2015</code>, ...</td>
  1408. </tr>
  1409. </table>
  1410. <p>Examples:</p>
  1411. <pre class="prettyprint lang-html">&lt;style&gt;
  1412. /* alternating column backgrounds */
  1413. .vis-time-axis .grid.vis-odd {
  1414. background: #f5f5f5;
  1415. }
  1416. /* gray background in weekends, white text color */
  1417. .vis-time-axis .vis-grid.vis-saturday,
  1418. .vis-time-axis .vis-grid.vis-sunday {
  1419. background: gray;
  1420. }
  1421. .vis-time-axis .vis-text.vis-saturday,
  1422. .vis-time-axis .vis-text.vis-sunday {
  1423. color: white;
  1424. }
  1425. &lt;/style&gt;
  1426. </pre>
  1427. <h2 id="Data_Policy">Data Policy</h2>
  1428. <p>
  1429. All code and data is processed and rendered in the browser.
  1430. No data is sent to any server.
  1431. </p>
  1432. </div>
  1433. <!-- Bootstrap core JavaScript
  1434. ================================================== -->
  1435. <!-- Placed at the end of the document so the pages load faster -->
  1436. <script src="../js/jquery.min.js"></script>
  1437. <script src="../js/bootstrap.min.js"></script>
  1438. <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
  1439. <script src="../js/ie10-viewport-bug-workaround.js"></script>
  1440. <!-- jquery extensions -->
  1441. <script src="../js/jquery.highlight.js"></script>
  1442. <script src="../js/jquery.url.min.js"></script>
  1443. <!-- Tipue vendor js -->
  1444. <script src="../js/tipuesearch.config.js"></script>
  1445. <script src="../js/tipuesearch.min.js"></script>
  1446. <!-- controller -->
  1447. <script src="../js/main.js"></script>