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.

1370 lines
54 KiB

10 years ago
10 years ago
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5. <meta charset="utf-8">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <meta name="viewport" content="width=device-width, initial-scale=1">
  8. <meta name="description" content="">
  9. <meta name="author" content="">
  10. <title>vis.js - A dynamic, browser based visualization library.</title>
  11. <!-- Bootstrap core CSS -->
  12. <link href="../css/bootstrap.css" rel="stylesheet">
  13. <link href="../css/style.css" rel="stylesheet">
  14. <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  15. <!--[if lt IE 9]>
  16. <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  17. <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  18. <![endif]-->
  19. <link href="../css/prettify.css" type="text/css" rel="stylesheet"/>
  20. <script type="text/javascript" src="../js/googleAnalytics.js"></script>
  21. <script type="text/javascript" src="../js/prettify/prettify.js"></script>
  22. <script src="../js/smooth-scroll.min.js"></script>
  23. <script language="JavaScript">
  24. smoothScroll.init();
  25. </script>
  26. <style>
  27. tr.subHeader {
  28. font-weight: bold;
  29. font-style: italic;
  30. }
  31. tr.subHeader td {
  32. padding-top: 30px;
  33. }
  34. td.midMethods {
  35. width: 150px;
  36. background-color: #ffffff;
  37. border: 1px solid #dddddd;
  38. }
  39. tr.visible td {
  40. padding: 10px;
  41. }
  42. h2 {
  43. margin-top:50px;
  44. }
  45. td.greenField {
  46. background-color: #b8e030;
  47. }
  48. </style>
  49. <script>
  50. function toggleGettingStarted(aThis) {
  51. var gettingStartedDiv = document.getElementById('gettingStarted');
  52. if (aThis.innerHTML.indexOf("Show") !== -1) {
  53. gettingStartedDiv.className = '';
  54. aThis.innerHTML = 'Hide the getting started again.';
  55. }
  56. else {
  57. gettingStartedDiv.className = 'hidden';
  58. aThis.innerHTML = 'Show the getting started!';
  59. }
  60. }
  61. </script>
  62. <script type="text/javascript" src="../js/toggleTable.js"></script>
  63. </head>
  64. <body onload="prettyPrint();">
  65. <!-- NAVBAR
  66. ================================================== -->
  67. <div class="navbar-wrapper">
  68. <div class="container">
  69. <nav class="navbar navbar-inverse navbar-static-top" role="navigation">
  70. <div class="container">
  71. <div class="navbar-header">
  72. <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
  73. aria-expanded="false" aria-controls="navbar">
  74. <span class="sr-only">Toggle navigation</span>
  75. <span class="icon-bar"></span>
  76. <span class="icon-bar"></span>
  77. <span class="icon-bar"></span>
  78. </button>
  79. <a class="navbar-brand hidden-sm" href="http://www.visjs.org/index.html">vis.js</a>
  80. </div>
  81. <div id="navbar" class="navbar-collapse collapse">
  82. <ul class="nav navbar-nav">
  83. <li><a href="http://www.visjs.org/index.html#modules">Modules</a></li>
  84. <li class="active"><a href="./docs/index.html" target="_blank">Documentation <img class="icon"
  85. src="../img/external-link-icons/external-link-icon-white.png"></a>
  86. </li>
  87. <li><a href="http://www.visjs.org/blog.html">Blog</a></li>
  88. <li><a href="http://www.visjs.org/index.html#download_install">Download</a></li>
  89. <li><a href="http://www.visjs.org/showcase/index.html">Showcase</a></li>
  90. <li><a href="http://www.visjs.org/index.html#contribute">Contribute</a></li>
  91. <li><a href="http://www.visjs.org/featureRequests.html">Feature requests</a></li>
  92. <li><a href="http://www.visjs.org/index.html#licenses">License</a></li>
  93. </ul>
  94. </div>
  95. </div>
  96. </nav>
  97. </div>
  98. </div>
  99. <a href="https://github.com/almende/vis" class="hidden-xs hidden-sm hidden-md"><img
  100. style="position: absolute; top: 0; right: 0; border: 0;"
  101. src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67"
  102. alt="Fork me on GitHub"
  103. data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
  104. <div class="container full">
  105. <h1>Graph2d</h1>
  106. <p>
  107. Graph2d is an interactive visualization chart to draw data in a 2D graph.
  108. You can freely move and zoom in the graph by dragging and scrolling in the
  109. window.
  110. </p>
  111. <p>
  112. Graph2d uses HTML DOM and SVG for rendering. This allows for flexible
  113. customization using css styling.
  114. </p>
  115. <h2 id="Contents">Contents</h2>
  116. <ul>
  117. <li><a href="#Overview">Overview</a></li>
  118. <li><a href="#Data_Format">Data Format</a>
  119. <ul>
  120. <li><a href="#items">Items</a></li>
  121. <li><a href="#groups">Groups</a></li>
  122. </ul>
  123. </li>
  124. <li><a href="#Configuration_Options">Configuration Options</a>
  125. <ul>
  126. <li><a href="#graph2dOptions">Graph2d options</a></li>
  127. <li><a href="#timelineOptions">Timeline options</a></li>
  128. </ul>
  129. </li>
  130. <li><a href="#Methods">Methods</a></li>
  131. <li><a href="#Events">Events</a></li>
  132. <li><a href="#Localization">Localization</a></li>
  133. <li><a href="#Styles">Styles</a></li>
  134. <li><a href="#Data_Policy">Data Policy</a></li>
  135. </ul>
  136. <a class="btn btn-primary" role="button" onclick="toggleGettingStarted(this)">Show the getting started!</a>
  137. <div id="gettingStarted" class="hidden">
  138. <h3>Creating a Graph2d</h3>
  139. <p>
  140. The following code shows how to create a Graph2d and provide it with data.
  141. More examples can be found in the <a href="../examples">examples</a> directory.</p>
  142. <pre class="prettyprint lang-html options">
  143. &lt;!DOCTYPE HTML&gt;
  144. &lt;html&gt;
  145. &lt;head&gt;
  146. &lt;title&gt;Graph2d or Basic Example&lt;/title&gt;
  147. &lt;style type="text/css"&gt;
  148. body, html {
  149. font-family: sans-serif;
  150. }
  151. &lt;/style&gt;
  152. &lt;script src="../../dist/vis.js"&gt;&lt;/script&gt;
  153. &lt;link href="../../dist/vis.css" rel="stylesheet" type="text/css" /&gt;
  154. &lt;/head&gt;
  155. &lt;body&gt;
  156. &lt;div id="visualization"&gt;&lt;/div&gt;
  157. &lt;script type="text/javascript"&gt;
  158. var container = document.getElementById('visualization');
  159. var items = [
  160. {x: '2014-06-11', y: 10},
  161. {x: '2014-06-12', y: 25},
  162. {x: '2014-06-13', y: 30},
  163. {x: '2014-06-14', y: 10},
  164. {x: '2014-06-15', y: 15},
  165. {x: '2014-06-16', y: 30}
  166. ];
  167. var dataset = new vis.DataSet(items);
  168. var options = {
  169. start: '2014-06-10',
  170. end: '2014-06-18'
  171. };
  172. var Graph2d = new vis.Graph2d(container, dataset, options);
  173. &lt;/script&gt;
  174. &lt;/body&gt;
  175. &lt;/html&gt;
  176. </pre>
  177. <p><a href="http://visjs.org/examples/graph2d/01_basic.html" target="_blank">The result of the code above will be the basic example which is shown here.</a></p>
  178. <h2 id="Loading">Loading</h2>
  179. <p>
  180. The class name of the Graph2d is <code>vis.Graph2d</code>.
  181. When constructing a Graph2d, an HTML DOM container must be provided to attach
  182. the graph to. Optionally, data an options can be provided.
  183. Data is a vis <code>DataSet</code> or an <code>Array</code>, described in
  184. section <a href="#Data_Format">Data Format</a>.
  185. Options is a name-value map in the JSON format. The available options
  186. are described in section <a href="#Configuration_Options">Configuration Options</a>.
  187. Groups is a vis <code>DataSet</code> containing groups. The available options and the method of construction
  188. are described in section <a href="#Group_Options">Data Format</a>.
  189. </p>
  190. <pre class="prettyprint lang-js options">var graph = new vis.Graph2d(container [, data] [, groups] [, options]);</pre>
  191. For backwards compatibility, groups and options can be interchanged.
  192. <p>
  193. Data, options and groups can be set or changed later on using the functions
  194. <code>Graph2d.setItems(data)</code>, <code>Graph2d.setOptions(options)</code> and <code>Graph2d.setGroups(groups)</code>.
  195. </p>
  196. <br>
  197. </div>
  198. <br>
  199. <br>
  200. <h2 id="Data_Format">Data Format</h2>
  201. <p>
  202. Graph2d can load data from an <code>Array</code>, a <code>DataSet</code> or a <code>DataView</code>.
  203. Objects are added to this DataSet by using the <code>add()</code> function.
  204. Data points must have properties <code>x</code>, <code>y</code>, and <code>z</code>,
  205. and can optionally have a property <code>style</code> and <code>filter</code>.
  206. <p>
  207. Graph2d can be provided with two types of data:
  208. </p>
  209. <ul>
  210. <li><a href="#items">Items</a> containing a set of points to be displayed.</li>
  211. <li><a href="#groups">Groups</a> containing a set of groups used to group items
  212. together. All items belonging to a group will be drawn as a single graph.</li>
  213. </ul>
  214. <h3 id="items">Items</h3>
  215. <pre class="prettyprint lang-js options">
  216. var items = [
  217. {x: '2014-06-13', y: 30, group: 0},
  218. {x: '2014-06-14', y: 10, group: 0},
  219. {x: '2014-06-15', y: 15, group: 1},
  220. {x: '2014-06-16', y: 30, group: 1},
  221. {x: '2014-06-17', y: 10, group: 1},
  222. {x: '2014-06-18', y: 15, group: 1}
  223. ];
  224. </pre>
  225. <table class="properties">
  226. <tr>
  227. <th>Name</th>
  228. <th>Type</th>
  229. <th>Required</th>
  230. <th>Description</th>
  231. </tr>
  232. <tr>
  233. <td>x</td>
  234. <td>Number</td>
  235. <td>yes</td>
  236. <td>Location on the x-axis.</td>
  237. </tr>
  238. <tr>
  239. <td>y</td>
  240. <td>Number</td>
  241. <td>yes</td>
  242. <td>Location on the y-axis.</td>
  243. </tr>
  244. <tr>
  245. <td>group</td>
  246. <td>Number or string</td>
  247. <td>no</td>
  248. <td>The ID of the group this point belongs to.</td>
  249. </tr>
  250. <tr>
  251. <td>label</td>
  252. <td>Object</td>
  253. <td>no</td>
  254. <td>A label object which will be displayed near to the item. A label object has one requirement - a <b> content </b> property. In addition you can set the <b> xOffset, yOffset and className </b> for further appearance customisations </td>
  255. </tr>
  256. </table>
  257. <h3 id="groups">Groups</h3>
  258. <p>
  259. Like the items, groups are regular JavaScript Arrays and Objects.
  260. Using groups, items can be grouped together.
  261. Items are filtered per group, and displayed as individual graphs. Groups can contain the properties <code>id</code>,
  262. <code>content</code>, <code>className</code> (optional) and <code>options</code> (optional).
  263. </p>
  264. <p>
  265. Groups can be applied to a timeline using the method <code>setGroups</code>.
  266. A table with groups can be created like:
  267. </p>
  268. <pre class="prettyprint lang-js options">
  269. var groups = new vis.DataSet();
  270. groups.add({
  271. id: 1,
  272. content: 'Group 1',
  273. // Optional: a field 'visible'
  274. // Optional: a field 'className'
  275. // Optional: options
  276. })
  277. groups.add({
  278. // more groups...
  279. });
  280. </pre>
  281. <p>
  282. Groups can have the following properties:
  283. </p>
  284. <table class="properties">
  285. <tr>
  286. <th>Name</th>
  287. <th>Type</th>
  288. <th>Required</th>
  289. <th>Description</th>
  290. </tr>
  291. <tr>
  292. <td>id</td>
  293. <td>String or Number</td>
  294. <td>yes</td>
  295. <td>An id for the group. The group will display all items having a
  296. property <code>group</code> which matches the <code>id</code>
  297. of the group.</td>
  298. </tr>
  299. <tr>
  300. <td>content</td>
  301. <td>String</td>
  302. <td>yes</td>
  303. <td>The contents of the group. This can be plain text or html code.</td>
  304. </tr>
  305. <tr>
  306. <td>className</td>
  307. <td>String</td>
  308. <td>no</td>
  309. <td>This field is optional. A className can be used to give groups
  310. an individual css style.
  311. </td>
  312. </tr>
  313. <tr>
  314. <td>style</td>
  315. <td>String</td>
  316. <td>no</td>
  317. <td>This field is optional. A style can be used to give groups
  318. an individual css style, and any style tags specified in style will
  319. override the definition in the className style defined in css.
  320. </td>
  321. </tr>
  322. <tr>
  323. <td>options</td>
  324. <td>Object</td>
  325. <td>no</td>
  326. <td>This field is optional. The options can be used to give a group a specific draw style.
  327. Any options that are colored green in the Configuration Options can be used as options here.
  328. </tr>
  329. <tr>
  330. <td>visible</td>
  331. <td>Boolean</td>
  332. <td>true</td>
  333. <td>This field is optional. If false, this group will not be drawn.
  334. </tr>
  335. </table>
  336. <h2 id="Configuration_Options">Configuration Options</h2>
  337. <h3 id="graph2dOptions">Graph2d Options</h3>
  338. Options can be used to customize the Graph2d to your purposes. These options can be passed to the Graph2d object either in
  339. the constructor, or by the <code>setOptions</code> function.
  340. <pre class="prettyprint lang-js options">
  341. var options = {
  342. width: '100%',
  343. height: '400px',
  344. style: 'surface'
  345. };
  346. </pre>
  347. The options colored in green can also be used as options for the groups. All options are optional.
  348. <table class="options" id="g2dOptions">
  349. <tr>
  350. <th>Name</th>
  351. <th>Type</th>
  352. <th>Default</th>
  353. <th>Description</th>
  354. </tr>
  355. <tr>
  356. <td>defaultGroup</td>
  357. <td>String</td>
  358. <td>'default'</td>
  359. <td>This is the label for the default, ungrouped items when shown in a legend.</td>
  360. </tr>
  361. <tr class='toggle collapsible' onclick="toggleTable('g2dOptions','barChart', this);">
  362. <td class="greenField"><span parent="barChart" class="right-caret"></span> barChart</td>
  363. <td>Object</td>
  364. <td></td>
  365. <td>Define the properties of the barchart style.</td>
  366. </tr>
  367. <tr parent="barChart" class="hidden">
  368. <td class="greenField indent">barChart.align</td>
  369. <td>String</td>
  370. <td>'center'</td>
  371. <td>The alignment of the bars with regards to the coordinate. The options are 'left', 'right' or 'center'.</td>
  372. </tr>
  373. <tr parent="barChart" class="hidden">
  374. <td class="greenField indent">barChart.sideBySide</td>
  375. <td>Boolean</td>
  376. <td>false</td>
  377. <td>If two datapoints of a barchart overlap, they are drawn over eachother by default. If sideBySide is set to true, they will be drawn side by side.
  378. See <a href="../examples/graph2d/10_barsSideBySide.html">example 10</a> for more information.
  379. When using groups, see <a href="../examples/graph2d/11_barsSideBySideGroups.html">example 11</a>.
  380. </td>
  381. </tr>
  382. <tr parent="barChart" class="hidden">
  383. <td class="greenField indent">barChart.width</td>
  384. <td>Number</td>
  385. <td>50</td>
  386. <td>The width of the bars.</td>
  387. </tr>
  388. <tr class='toggle collapsible' onclick="toggleTable('g2dOptions','dataAxis', this);">
  389. <td><span parent="dataAxis" class="right-caret"></span> dataAxis</td>
  390. <td>Object</td>
  391. <td></td>
  392. <td>Define the properties of the left and right dataAxis.</td>
  393. </tr>
  394. <tr parent="dataAxis" class="hidden">
  395. <td class="indent">dataAxis.alignZeros</td>
  396. <td>Boolean</td>
  397. <td>true</td>
  398. <td>When using multiple axis, the right one is slaved to the left one. If you need to ensure that the zero-lines are on the same
  399. height, you can turn this option on.</td>
  400. </tr>
  401. <tr parent="dataAxis" class="hidden">
  402. <td class="indent">dataAxis.icons</td>
  403. <td>Boolean</td>
  404. <td>false</td>
  405. <td>Toggle the drawing of automatically generated icons the Y axis.</td>
  406. </tr>
  407. <tr parent="dataAxis" class="hidden">
  408. <td class="indent2">dataAxis.left.format</td>
  409. <td>Function</td>
  410. <td></td>
  411. <td>Insert a custom function on how to format the label. The function will receive a numeric value and has to return a string. Default function is:
  412. <pre class="code">
  413. function (value) {
  414. return value;
  415. }
  416. </pre>
  417. which does nothing to it.</td>
  418. </tr>
  419. <tr parent="dataAxis" class="hidden">
  420. <td class="indent2">dataAxis.left.range.min</td>
  421. <td>Number</td>
  422. <td>undefined</td>
  423. <td>Set the minimum value of the left y-Axis.</td>
  424. </tr>
  425. <tr parent="dataAxis" class="hidden">
  426. <td class="indent2">dataAxis.left.range.max</td>
  427. <td>Number</td>
  428. <td>undefined</td>
  429. <td>Set the maximum value of the left y-Axis.</td>
  430. </tr>
  431. <tr parent="dataAxis" class="hidden">
  432. <td class="indent2">dataAxis.left.title.style</td>
  433. <td>String</td>
  434. <td>undefined</td>
  435. <td>Set the title style for the left axis. This is a css string and it will override the attributes set in the class.</td>
  436. </tr>
  437. <tr parent="dataAxis" class="hidden">
  438. <td class="indent2">dataAxis.left.title.text</td>
  439. <td>String</td>
  440. <td>undefined</td>
  441. <td>Set the title for the left axis.</td>
  442. </tr>
  443. <tr parent="dataAxis" class="hidden">
  444. <td class="indent2">dataAxis.right.format</td>
  445. <td>Function</td>
  446. <td></td>
  447. <td>Same explaination as the left side.</td>
  448. </tr>
  449. <tr parent="dataAxis" class="hidden">
  450. <td class="indent2">dataAxis.right.range.min</td>
  451. <td>Number</td>
  452. <td>undefined</td>
  453. <td>Set the minimum value of the right y-Axis.</td>
  454. </tr>
  455. <tr parent="dataAxis" class="hidden">
  456. <td class="indent2">dataAxis.right.range.max</td>
  457. <td>Number</td>
  458. <td>undefined</td>
  459. <td>Set the maximum value of the right y-Axis.</td>
  460. </tr>
  461. <tr parent="dataAxis" class="hidden">
  462. <td class="indent2">dataAxis.right.title.style</td>
  463. <td>String</td>
  464. <td>undefined</td>
  465. <td>Set the title style for the right axis. This is a css string and it will override the attributes set in the class.</td>
  466. </tr>
  467. <tr parent="dataAxis" class="hidden">
  468. <td class="indent2">dataAxis.right.title.text</td>
  469. <td>String</td>
  470. <td>undefined</td>
  471. <td>Set the title for the right axis.</td>
  472. </tr>
  473. <tr parent="dataAxis" class="hidden">
  474. <td class="indent">dataAxis.showMinorLabels</td>
  475. <td>Boolean</td>
  476. <td>true</td>
  477. <td>Toggle the drawing of the minor labels on the Y axis.</td>
  478. </tr>
  479. <tr parent="dataAxis" class="hidden">
  480. <td class="indent">dataAxis.showMajorLabels</td>
  481. <td>Boolean</td>
  482. <td>true</td>
  483. <td>Toggle the drawing of the major labels on the Y axis.</td>
  484. </tr>
  485. <tr parent="dataAxis" class="hidden">
  486. <td class="indent">dataAxis.visible</td>
  487. <td>Boolean</td>
  488. <td>true</td>
  489. <td>Show or hide the data axis.</td>
  490. </tr>
  491. <tr parent="dataAxis" class="hidden">
  492. <td class="indent">dataAxis.width</td>
  493. <td>Number or String</td>
  494. <td>'40px'</td>
  495. <td>Set the (minimal) width of the yAxis. The axis will resize to accomodate the labels of the Y values.</td>
  496. </tr>
  497. <tr class='toggle collapsible' onclick="toggleTable('g2dOptions','drawPoints', this);">
  498. <td class="greenField"><span parent="drawPoints" class="right-caret"></span> drawPoints</td>
  499. <td>Boolean or Object</td>
  500. <td>true</td>
  501. <td>Toggle the drawing of the datapoints with the default settings.</td>
  502. </tr>
  503. <tr parent="drawPoints" class="hidden">
  504. <td class="greenField indent">drawPoints.enabled</td>
  505. <td>Boolean</td>
  506. <td>true</td>
  507. <td>Toggle the drawing of the datapoints.</td>
  508. </tr>
  509. <tr parent="drawPoints" class="hidden">
  510. <td class="greenField indent">drawPoints.size</td>
  511. <td>Number</td>
  512. <td>6</td>
  513. <td>Determine the size at which the data points are drawn.</td>
  514. </tr>
  515. <tr parent="drawPoints" class="hidden">
  516. <td class="greenField indent">drawPoints.style</td>
  517. <td>String</td>
  518. <td>'square'</td>
  519. <td>Determine the shape of the data points. The options are 'square' or 'circle'.</td>
  520. </tr>
  521. <tr>
  522. <td>graphHeight</td>
  523. <td>Number or String</td>
  524. <td>'400px'</td>
  525. <td>This is the height of the graph SVG canvas.
  526. If it is larger than the height of the outer frame, you can drag up and down
  527. the vertical direction as well as the usual horizontal direction.</td>
  528. </tr>
  529. <tr>
  530. <td>groups.visibility</td>
  531. <td>Object</td>
  532. <td></td>
  533. <td>You can use this to toggle the visibility of groups per graph2D instance. This is different from setting the visibility flag of the groups since
  534. this is not communicated across instances of graph2d. Take a look at <a href="../examples/graph2d/14_toggleGroups.html">Example 14</a>
  535. for more explanation.
  536. </td>
  537. </tr>
  538. <tr class='toggle collapsible' onclick="toggleTable('g2dOptions','interpolation', this);">
  539. <td class="greenField"><span parent="interpolation" class="right-caret"></span> interpolation</td>
  540. <td>Boolean or Object</td>
  541. <td>true</td>
  542. <td>Toggle the interpolation with the default settings. For more customization use the JSON format.</td>
  543. </tr>
  544. <tr parent="interpolation" class="hidden">
  545. <td class="greenField indent">interpolation.enabled</td>
  546. <td>Boolean</td>
  547. <td>true</td>
  548. <td>Toggle the interpolation.</td>
  549. </tr>
  550. <tr parent="interpolation" class="hidden">
  551. <td class="greenField indent">interpolation.parametrization</td>
  552. <td>String</td>
  553. <td>'centripetal'</td>
  554. <td>Define the type of parametrizaion for the catmullRom interpolation. <a href="../examples/graph2d/07_scrollingAndSorting.html">Example 7</a> shows the different parametrizations. The options are 'centripetal' (best results), 'chordal' and 'uniform'. Uniform is the computationally cheapest variant.
  555. If interpolation is disabled, linear interpolation is used.</td>
  556. </tr>
  557. <tr class='toggle collapsible' onclick="toggleTable('g2dOptions','legend', this);">
  558. <td><span parent="legend" class="right-caret"></span> legend</td>
  559. <td>Boolean or Object</td>
  560. <td>false</td>
  561. <td>Toggle the legend with the default settings.</td>
  562. </tr>
  563. <tr parent="legend" class="hidden">
  564. <td class="indent">legend.enabled</td>
  565. <td>Boolean</td>
  566. <td>false</td>
  567. <td>Toggle the legend.</td>
  568. </tr>
  569. <tr parent="legend" class="hidden">
  570. <td class="indent">legend.icons</td>
  571. <td>Boolean</td>
  572. <td>true</td>
  573. <td>Show automatically generated icons on the legend.</td>
  574. </tr>
  575. <tr parent="legend" class="hidden">
  576. <td class="indent2">legend.left.visible</td>
  577. <td>Boolean</td>
  578. <td>true</td>
  579. <td>Both axis, left and right, have a corresponding legend. This toggles the visibility of the legend that is coupled with the left axis.</td>
  580. </tr>
  581. <tr parent="legend" class="hidden">
  582. <td class="indent2">legend.left.position</td>
  583. <td>String</td>
  584. <td>'top-left'</td>
  585. <td>Determine the position of the legend coupled to the left axis. Options are 'top-left', 'top-right', 'bottom-left' or 'bottom-right'.</td>
  586. </tr>
  587. <tr parent="legend" class="hidden">
  588. <td class="indent2">legend.right.visible</td>
  589. <td>Boolean</td>
  590. <td>true</td>
  591. <td>This toggles the visibility of the legend that is coupled with the right axis.</td>
  592. </tr>
  593. <tr parent="legend" class="hidden">
  594. <td class="indent2">legend.right.position</td>
  595. <td>String</td>
  596. <td>'top-right'</td>
  597. <td>Determine the position of the legend coupled to the right axis. Options are 'top-left', 'top-right', 'bottom-left' or 'bottom-right'.</td>
  598. </tr>
  599. <tr>
  600. <td class="greenField">sampling</td>
  601. <td>Boolean</td>
  602. <td>true</td>
  603. <td>If sampling is enabled, Graph2d will automatically determine the amount of points per pixel.
  604. If there are more than 1 point per pixel, not all points will be drawn. Disabling sampling will cause a decrease in performance.</td>
  605. </tr>
  606. <tr>
  607. <td class="greenField">sort</td>
  608. <td>Boolean</td>
  609. <td>true</td>
  610. <td>This determines if the items are sorted automatically.
  611. They are sorted by the x value. If sort is enabled, more optimizations are possible, increasing the performance.</td>
  612. </tr>
  613. <tr>
  614. <td class="greenField">stack</td>
  615. <td>Boolean</td>
  616. <td>true</td>
  617. <td>If stack is enabled, the graphs will be stacked upon eachother when applicable. This currently only works with bar graphs but linegraph support is being worked on.</td>
  618. </tr>
  619. <tr class='toggle collapsible' onclick="toggleTable('g2dOptions','shaded', this);">
  620. <td class="greenField"><span parent="shaded" class="right-caret"></span> shaded</td>
  621. <td>Boolean or Object</td>
  622. <td>false</td>
  623. <td>Toggle a shaded area with the default settings.</td>
  624. </tr>
  625. <tr parent="shaded" class="hidden">
  626. <td class="greenField indent">shaded.enabled</td>
  627. <td>Boolean</td>
  628. <td>false</td>
  629. <td>This toggles the shading.</td>
  630. </tr>
  631. <tr parent="shaded" class="hidden">
  632. <td class="greenField indent">shaded.orientation</td>
  633. <td>String</td>
  634. <td>'bottom'</td>
  635. <td>This determines if the shaded area is at the bottom or at the top of the curve. The options are 'bottom' or 'top'.</td>
  636. </tr>
  637. <tr parent="shaded" class="hidden">
  638. <td class="greenField indent">shaded.style</td>
  639. <td>String</td>
  640. <td>undefined</td>
  641. <td>Set the style for the shading. This is a css string and it will override the attributes set in the class.</td>
  642. </tr>
  643. <tr parent="shaded" class="hidden">
  644. <td class="greenField indent">style</td>
  645. <td>String</td>
  646. <td>'line'</td>
  647. <td>This allows the user to define if this should be a linegraph, barchart or pointcloud. The options are: 'line', 'bar', 'points'.</td>
  648. </tr>
  649. <tr>
  650. <td class="greenField">yAxisOrientation</td>
  651. <td>String</td>
  652. <td>'left'</td>
  653. <td>This defines with which axis, left or right, the graph is coupled. <a href="../examples/graph2d/05_bothAxis.html">Example 5</a> shows groups with different Y axis. If no groups are coupled
  654. with an axis, it will not be shown.</td>
  655. </tr>
  656. </table>
  657. <h3 id="timelineOptions">Timeline Options</h3>
  658. <p>
  659. Graph2d is built upon the framework of the timeline. These options from the timeline can be used with graph2D.
  660. All options are optional.
  661. </p>
  662. <table class="options" id="optionTable">
  663. <tr>
  664. <th>Name</th>
  665. <th>Type</th>
  666. <th>Default</th>
  667. <th>Description</th>
  668. </tr>
  669. <tr>
  670. <td>autoResize</td>
  671. <td>Boolean</td>
  672. <td>true</td>
  673. <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>
  674. </tr>
  675. <tr>
  676. <td>configure</td>
  677. <td>boolean or function</td>
  678. <td><code>false</code></td>
  679. <td>When true, a configurator is loaded where all configuration options of the Graph2d can be changed live.
  680. 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:
  681. <pre class="prettyprint lang-js">
  682. function (option, path) {
  683. return option === 'format' || path.indexOf('format') !== -1;
  684. }</pre>
  685. </td>
  686. </tr>
  687. <tr>
  688. <td>clickToUse</td>
  689. <td>Boolean</td>
  690. <td>false</td>
  691. <td>When a Graph2d is configured to be <code>clickToUse</code>, it will react to mouse and touch events only when active.
  692. When active, a blue shadow border is displayed around the Graph2d. The Graph2d is set active by clicking on it, and is changed to inactive again by clicking outside the Graph2d or by pressing the ESC key.</td>
  693. </tr>
  694. <tr>
  695. <td>end</td>
  696. <td>Date or Number or String</td>
  697. <td>none</td>
  698. <td>The initial end date for the axis of the timeline.
  699. If not provided, the latest date present in the items set is taken as
  700. end date.</td>
  701. </tr>
  702. <tr>
  703. <td>format</td>
  704. <td>Object</td>
  705. <td>none</td>
  706. <td>
  707. Apply custom date formatting of the labels on the time axis. The default value of <code>format</code> is:
  708. <pre class="prettyprint lang-js">{
  709. minorLabels: {
  710. millisecond:'SSS',
  711. second: 's',
  712. minute: 'HH:mm',
  713. hour: 'HH:mm',
  714. weekday: 'ddd D',
  715. day: 'D',
  716. month: 'MMM',
  717. year: 'YYYY'
  718. },
  719. majorLabels: {
  720. millisecond:'HH:mm:ss',
  721. second: 'D MMMM HH:mm',
  722. minute: 'ddd D MMMM',
  723. hour: 'ddd D MMMM',
  724. weekday: 'MMMM YYYY',
  725. day: 'MMMM YYYY',
  726. month: 'YYYY',
  727. year: ''
  728. }
  729. }</pre>
  730. For values which not provided in the customized <code>options.format</code>, the default values will be used.
  731. All available formatting syntax is described in the <a href="http://momentjs.com/docs/#/displaying/format/">docs of moment.js</a>.
  732. </td>
  733. </tr>
  734. <tr>
  735. <td>height</td>
  736. <td>Number or String</td>
  737. <td>none</td>
  738. <td>The height of the timeline in pixels or as a percentage.
  739. When height is undefined or null, the height of the timeline is automatically
  740. adjusted to fit the contents.
  741. It is possible to set a maximum height using option <code>maxHeight</code>
  742. to prevent the timeline from getting too high in case of automatically
  743. calculated height.
  744. </td>
  745. </tr>
  746. <tr>
  747. <td>hiddenDates</td>
  748. <td>Object</td>
  749. <td>none</td>
  750. <td>This option allows you to hide specific timespans from the time axis. The dates can be supplied as an object:
  751. <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.
  752. 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
  753. and set repeat to weekly.
  754. </td>
  755. </tr>
  756. <tr>
  757. <td>locale</td>
  758. <td>String</td>
  759. <td>none</td>
  760. <td>Select a locale for the Graph2d. See section <a href="timeline.html#Localization">Localization</a> for more information.</td>
  761. </tr>
  762. <tr>
  763. <td>locales</td>
  764. <td>Object</td>
  765. <td>none</td>
  766. <td>A map with i18n locales. See section <a href="timeline.html#Localization">Localization</a> for more information.</td>
  767. </tr>
  768. <tr>
  769. <td>max</td>
  770. <td>Date or Number or String</td>
  771. <td>none</td>
  772. <td>Set a maximum Date for the visible range.
  773. It will not be possible to move beyond this maximum.
  774. </td>
  775. </tr>
  776. <tr>
  777. <td>maxHeight</td>
  778. <td>Number or String</td>
  779. <td>none</td>
  780. <td>Specifies the maximum height for the Timeline. Can be a number in pixels or a string like "300px".</td>
  781. </tr>
  782. <tr>
  783. <td>min</td>
  784. <td>Date or Number or String</td>
  785. <td>none</td>
  786. <td>Set a minimum Date for the visible range.
  787. It will not be possible to move beyond this minimum.
  788. </td>
  789. </tr>
  790. <tr>
  791. <td>minHeight</td>
  792. <td>Number or String</td>
  793. <td>none</td>
  794. <td>Specifies the minimum height for the Timeline. Can be a number in pixels or a string like "300px".</td>
  795. </tr>
  796. <tr>
  797. <td>moveable</td>
  798. <td>boolean</td>
  799. <td><code>true</code></td>
  800. <td>
  801. Specifies whether the Timeline can be moved and zoomed by dragging the window.
  802. See also option <code>zoomable</code>.
  803. </td>
  804. </tr>
  805. <tr>
  806. <td>orientation</td>
  807. <td>String</td>
  808. <td>'bottom'</td>
  809. <td>Orientation of the timeline: 'top', 'bottom' (default), or 'both'. 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.</td>
  810. </tr>
  811. <tr>
  812. <td>showCurrentTime</td>
  813. <td>Boolean</td>
  814. <td>true</td>
  815. <td>Show a vertical bar at the current time.</td>
  816. </tr>
  817. <tr>
  818. <td>showCustomTime</td>
  819. <td>Boolean</td>
  820. <td>false</td>
  821. <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>
  822. </tr>
  823. <tr>
  824. <td>showMajorLabels</td>
  825. <td>Boolean</td>
  826. <td>true</td>
  827. <td>By default, the timeline shows both minor and major date labels on the
  828. time axis.
  829. For example the minor labels show minutes and the major labels show hours.
  830. When <code>showMajorLabels</code> is <code>false</code>, no major labels
  831. are shown.</td>
  832. </tr>
  833. <tr>
  834. <td>showMinorLabels</td>
  835. <td>Boolean</td>
  836. <td>true</td>
  837. <td>By default, the timeline shows both minor and major date labels on the
  838. time axis.
  839. For example the minor labels show minutes and the major labels show hours.
  840. When <code>showMinorLabels</code> is <code>false</code>, no minor labels
  841. are shown. When both <code>showMajorLabels</code> and
  842. <code>showMinorLabels</code> are false, no horizontal axis will be
  843. visible.</td>
  844. </tr>
  845. <tr>
  846. <td>showMajorLines</td>
  847. <td>Boolean</td>
  848. <td>true</td>
  849. <td>By default, the timeline shows both minor and major date lines on the
  850. time axis. You can use this option to hide the lines from the major dates.
  851. </tr>
  852. <tr>
  853. <td>showMinorLines</td>
  854. <td>Boolean</td>
  855. <td>true</td>
  856. <td>By default, the timeline shows both minor and major date lines on the
  857. time axis. You can use this option to hide the lines from the minor dates.
  858. </tr>
  859. <tr>
  860. <td>start</td>
  861. <td>Date or Number or String</td>
  862. <td>none</td>
  863. <td>The initial start date for the axis of the timeline.
  864. If not provided, the earliest date present in the events is taken as start date.</td>
  865. </tr>
  866. <tr class='toggle collapsible' onclick="toggleTable('optionTable','timeAxis', this);">
  867. <td><span parent="timeAxis" class="right-caret"></span> timeAxis</td>
  868. <td>Object</td>
  869. <td><code>Object</code></td>
  870. <td>Specify a fixed scale and step size for the time axis.</td>
  871. </tr>
  872. <tr parent="timeAxis" class="hidden">
  873. <td class="indent">timeAxis.scale</td>
  874. <td>String</td>
  875. <td>none</td>
  876. <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:
  877. <pre class="prettyprint lang-js options">var options = {
  878. timeAxis: {scale: 'minute', step: 5}
  879. }</pre>
  880. </td>
  881. </tr>
  882. <tr parent="timeAxis" class="hidden">
  883. <td class="indent">timeAxis.step</td>
  884. <td>number</td>
  885. <td><code>1</code></td>
  886. <td>
  887. Set a fixed step size for the time axis. Only applicable when used together with <code>timeAxis.scale</code>.
  888. Choose for example 1, 2, 5, or 10.</td>
  889. </tr>
  890. <tr>
  891. <td>width</td>
  892. <td>String</td>
  893. <td>'100%'</td>
  894. <td>The width of the timeline in pixels or as a percentage.</td>
  895. </tr>
  896. <tr>
  897. <td>zoomMax</td>
  898. <td>Number</td>
  899. <td>315360000000000</td>
  900. <td>Set a maximum zoom interval for the visible range in milliseconds.
  901. It will not be possible to zoom out further than this maximum.
  902. Default value equals about 10000 years.
  903. </td>
  904. </tr>
  905. <tr>
  906. <td>zoomMin</td>
  907. <td>Number</td>
  908. <td>10</td>
  909. <td>Set a minimum zoom interval for the visible range in milliseconds.
  910. It will not be possible to zoom in further than this minimum.
  911. </td>
  912. </tr>
  913. </table>
  914. <h2 id="Methods">Methods</h2>
  915. <p>
  916. The Graph2d supports the following methods.
  917. </p>
  918. <table class="methods">
  919. <tr>
  920. <th>Method</th>
  921. <th>Return Type</th>
  922. <th>Description</th>
  923. </tr>
  924. <tr>
  925. <td>clear([what])</td>
  926. <td>none</td>
  927. <td>
  928. Clear the Graph2d. An object can be passed specifying which sections to clear: items, groups,
  929. and/or options. By Default, items, groups and options are cleared, i.e. <code>what = {items: true, groups: true, options: true}</code>. Example usage:
  930. <pre class="prettyprint lang-js options">Graph2d.clear(); // clear items, groups, and options
  931. Graph2d.clear({options: true}); // clear options only
  932. </pre>
  933. </td>
  934. </tr>
  935. <tr>
  936. <td>destroy()</td>
  937. <td>none</td>
  938. <td>Destroy the Graph2d. The Graph2d is removed from memory. all DOM elements and event listeners are cleaned up.
  939. </td>
  940. </tr>
  941. <tr>
  942. <td>fit()</td>
  943. <td>none</td>
  944. <td>Adjust the visible window such that it fits all items.
  945. </td>
  946. </tr>
  947. <tr>
  948. <td>getCurrentTime()</td>
  949. <td>Date</td>
  950. <td>Get the current time. Only applicable when option <code>showCurrentTime</code> is true.
  951. </td>
  952. </tr>
  953. <tr>
  954. <td>getCustomTime()</td>
  955. <td>Date</td>
  956. <td>Retrieve the custom time. Only applicable when the option <code>showCustomTime</code> is true.
  957. </td>
  958. </tr>
  959. <tr id="getEventProperties">
  960. <td>getEventProperties(event)</td>
  961. <td>Object</td>
  962. <td>
  963. Returns an Object with relevant properties from an event:
  964. <ul>
  965. <li><code>pageX</code> (Number): absolute horizontal position of the click event.</li>
  966. <li><code>pageY</code> (Number): absolute vertical position of the click event.</li>
  967. <li><code>x</code> (Number): relative horizontal position of the click event.</li>
  968. <li><code>y</code> (Number): relative vertical position of the click event.</li>
  969. <li><code>time</code> (Date): Date of the clicked event.</li>
  970. <li><code>value</code> (Number[]): The data value of the click event. The array contains one value when there is one data axis visible, and two values when there are two visible data axes.</li>
  971. <li><code>what</code> (String or null): name of the clicked thing: <code>background</code>, <code>axis</code>, <code>dat-axis</code>, <code>custom-time</code>, or <code>current-time</code>, <code>legend</code>.</li>
  972. <li><code>event</code> (Object): the original click event.</li>
  973. </ul>
  974. </td>
  975. </tr>
  976. <tr>
  977. <td>getLegend(groupId, iconWidth, iconHeight)</td>
  978. <td>SVGelement, String, String</td>
  979. <td>Returns an object containing an SVG element with the icon of the group (size determined by iconWidth and iconHeight), the label of the group (content) and the yAxisOrientation of the group (left or right).
  980. </td>
  981. </tr>
  982. <tr>
  983. <td>getWindow()</td>
  984. <td>Object</td>
  985. <td>Get the current visible window. Returns an object with properties <code>start: Date</code> and <code>end: Date</code>.</td>
  986. </tr>
  987. <tr>
  988. <td>getItemRange()</td>
  989. <td>Object</td>
  990. <td>Get the range of all the items as an object containing <code>min: Date</code> and <code>max: Date</code>.</td>
  991. </tr>
  992. <tr>
  993. <td>isGroupVisible(groupId)</td>
  994. <td>Boolean</td>
  995. <td>This checks if the visible option of the supplied group (by ID) is true or false.
  996. </td>
  997. </tr>
  998. <tr>
  999. <td>moveTo(time [, options])</td>
  1000. <td>none</td>
  1001. <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:
  1002. <ul>
  1003. <li><code>animate: boolean or 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>
  1004. </ul>
  1005. </td>
  1006. </tr>
  1007. <tr>
  1008. <td>on(event, callback)</td>
  1009. <td>none</td>
  1010. <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>
  1011. </tr>
  1012. <tr>
  1013. <td>off(event, callback)</td>
  1014. <td>none</td>
  1015. <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>
  1016. </tr>
  1017. <tr>
  1018. <td>redraw()</td>
  1019. <td>none</td>
  1020. <td>Force a redraw of the Graph2d. Can be useful to manually redraw when option autoResize=false.
  1021. </td>
  1022. </tr>
  1023. <tr>
  1024. <td>setCurrentTime(time)</td>
  1025. <td>none</td>
  1026. <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.
  1027. <code>time</code> can be a Date object, numeric timestamp, or ISO date string.
  1028. Only applicable when option <code>showCurrentTime</code> is true.</td>
  1029. </tr>
  1030. <tr>
  1031. <td>setCustomTime(time)</td>
  1032. <td>none</td>
  1033. <td>Adjust the custom time bar. Only applicable when the option <code>showCustomTime</code> is true. <code>time</code> can be a Date object, numeric timestamp, or ISO date string.
  1034. </td>
  1035. </tr>
  1036. <tr>
  1037. <td>setGroups(groups)</td>
  1038. <td>none</td>
  1039. <td>Set a data set with groups for the Graph2d.
  1040. <code>groups</code> can be an Array with Objects,
  1041. a DataSet, or a DataView. For each of the groups, the items of the
  1042. Graph2d are filtered on the property <code>group</code>, which
  1043. must correspond with the id of the group.
  1044. </td>
  1045. </tr>
  1046. <tr>
  1047. <td>setItems(items)</td>
  1048. <td>none</td>
  1049. <td>Set a data set with items for the Graph2d.
  1050. <code>items</code> can be an Array with Objects,
  1051. a DataSet, or a DataView.
  1052. </td>
  1053. </tr>
  1054. <tr>
  1055. <td>setOptions(options)</td>
  1056. <td>none</td>
  1057. <td>Set or update options. It is possible to change any option of the Graph2d at any time. You can for example switch orientation on the fly.
  1058. </td>
  1059. </tr>
  1060. <tr>
  1061. <td>setWindow(start, end)</td>
  1062. <td>none</td>
  1063. <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.</td>
  1064. </tr>
  1065. </table>
  1066. <h2 id="Events">Events</h2>
  1067. <p>
  1068. Graph2d fires events when changing the visible window by dragging, when
  1069. selecting items, and when dragging the custom time bar.
  1070. </p>
  1071. <p>
  1072. Here an example on how to listen for a <code>rangeChanged</code> event. A listener can be removed via the function <code>off</code>:
  1073. </p>
  1074. <pre class="prettyprint lang-js">
  1075. function onChange (properties) {
  1076. alert('changed!');
  1077. }
  1078. // add event listener
  1079. Graph2d.on('rangechanged', onChange);
  1080. // do stuff...
  1081. // remove event listener
  1082. Graph2d.off('rangechanged', onChange);
  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>Graph2d.getEventProperties(event)</code></a>.
  1097. </td>
  1098. <td>Fired when clicked inside the Graph2d.
  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>Graph2d.getEventProperties(event)</code></a>.
  1105. </td>
  1106. <td>Fired when right-clicked inside the Graph2d. 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 options">graph2d.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>Graph2d.getEventProperties(event)</code></a>.
  1118. </td>
  1119. <td>Fired when double clicked inside the Graph2d.
  1120. </td>
  1121. </tr>
  1122. <tr>
  1123. <td>finishedRedraw</td>
  1124. <td>
  1125. none.
  1126. </td>
  1127. <td>Fired after a redraw is complete. When moving the Graph2d around, this could be fired frequently.
  1128. </td>
  1129. </tr>
  1130. <tr>
  1131. <td>rangechange</td>
  1132. <td>
  1133. <ul>
  1134. <li><code>start</code> (Number): timestamp of the current start of the window.</li>
  1135. <li><code>end</code> (Number): timestamp of the current end of the window.</li>
  1136. </ul>
  1137. </td>
  1138. <td>Fired repeatedly when the user is dragging the Graph2d window.
  1139. </td>
  1140. </tr>
  1141. <tr>
  1142. <td>rangechanged</td>
  1143. <td>
  1144. <ul>
  1145. <li><code>start</code> (Number): timestamp of the current start of the window.</li>
  1146. <li><code>end</code> (Number): timestamp of the current end of the window.</li>
  1147. </ul>
  1148. </td>
  1149. <td>Fired once after the user has dragged the Graph2d window.
  1150. </td>
  1151. </tr>
  1152. <tr>
  1153. <td>timechange</td>
  1154. <td>
  1155. <ul>
  1156. <li><code>time</code> (Date): the current time.</li>
  1157. </ul>
  1158. </td>
  1159. <td>Fired repeatedly when the user is dragging the custom time bar.
  1160. Only available when the custom time bar is enabled.
  1161. </td>
  1162. </tr>
  1163. <tr>
  1164. <td>timechanged</td>
  1165. <td>
  1166. <ul>
  1167. <li><code>time</code> (Date): the current time.</li>
  1168. </ul>
  1169. </td>
  1170. <td>Fired once after the user has dragged the custom time bar.
  1171. Only available when the custom time bar is enabled.
  1172. </td>
  1173. </tr>
  1174. </table>
  1175. <h2 id="Localization">Localization</h2>
  1176. <p>
  1177. Graph2d can be localized. For localization, Graph2d 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.
  1178. </p>
  1179. <p>
  1180. To set a locale for the Graph2d, specify the option <code>locale</code>:
  1181. </p>
  1182. <pre class="prettyprint lang-js">var options = {
  1183. locale: 'nl'
  1184. };
  1185. </pre>
  1186. <h3>Create a new locale</h3>
  1187. To load a locale into the Graph2d not supported by default, one can add a new locale to the option <code>locales</code>:
  1188. <pre class="prettyprint lang-js">var options = {
  1189. locales: {
  1190. // create a new locale
  1191. mylocale: {
  1192. current: 'current',
  1193. time: 'time',
  1194. }
  1195. },
  1196. // use the new locale
  1197. locale: 'mylocale'
  1198. };
  1199. </pre>
  1200. <h3 id="available-locales">Available locales</h3>
  1201. Graph2d comes with support for the following locales:
  1202. <table>
  1203. <tr><td>Language</td><td>Code</td></tr>
  1204. <tr>
  1205. <td>English</td>
  1206. <td>
  1207. <code>en</code><br>
  1208. <code>en_EN</code><br>
  1209. <code>en_US</code>
  1210. </td>
  1211. </tr>
  1212. <tr>
  1213. <td>Dutch</td>
  1214. <td>
  1215. <code>nl</code><br>
  1216. <code>nl_NL</code><br>
  1217. <code>nl_BE</code>
  1218. </td>
  1219. </tr>
  1220. </table>
  1221. <h2 id="Styles">Styles</h2>
  1222. <p>
  1223. All parts of the Graph2d have a class name and a default css style just like the Graph2d.
  1224. The styles can be overwritten, which enables full customization of the layout
  1225. of the Graph2d.
  1226. </p>
  1227. <p>
  1228. Additionally, Graph2d has 10 preset styles for graphs, which are cycled through when loading groups. These styles can be overwritten
  1229. as well, along with defining your own classes to style the graphs! <a href="../examples/graph2d/04_rightAxis.html">Example 4</a> and
  1230. <a href="../examples/graph2d/05_bothAxis.html">example 5</a> show the usage of custom styles.
  1231. </p>
  1232. </div>
  1233. <!-- Bootstrap core JavaScript
  1234. ================================================== -->
  1235. <!-- Placed at the end of the document so the pages load faster -->
  1236. <script src="../js/jquery.min.js"></script>
  1237. <script src="../js/bootstrap.min.js"></script>
  1238. <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
  1239. <script src="../js/ie10-viewport-bug-workaround.js"></script>