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.

1367 lines
55 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/newdocs.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="moduleTable">
  226. <tr class="header">
  227. <td>Name</td>
  228. <td>Type</td>
  229. <td>Required</td>
  230. <td>Description</td>
  231. </tr>
  232. <tr>
  233. <td>x</td>
  234. <td class="mid">Number</td>
  235. <td>yes</td>
  236. <td>Location on the x-axis.</td>
  237. </tr>
  238. <tr>
  239. <td>y</td>
  240. <td class="mid">Number</td>
  241. <td>yes</td>
  242. <td>Location on the y-axis.</td>
  243. </tr>
  244. </tr>
  245. <tr>
  246. <td>group</td>
  247. <td class="mid">Number or string</td>
  248. <td>no</td>
  249. <td>The ID of the group this point belongs to.</td>
  250. </tr>
  251. <tr>
  252. <td>label</td>
  253. <td class="mid">Object</td>
  254. <td>no</td>
  255. <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>
  256. </tr>
  257. </table>
  258. <h3 id="groups">Groups</h3>
  259. <p>
  260. Like the items, groups are regular JavaScript Arrays and Objects.
  261. Using groups, items can be grouped together.
  262. Items are filtered per group, and displayed as individual graphs. Groups can contain the properties <code>id</code>,
  263. <code>content</code>, <code>className</code> (optional) and <code>options</code> (optional).
  264. </p>
  265. <p>
  266. Groups can be applied to a timeline using the method <code>setGroups</code>.
  267. A table with groups can be created like:
  268. </p>
  269. <pre class="prettyprint lang-js options">
  270. var groups = new vis.DataSet();
  271. groups.add({
  272. id: 1,
  273. content: 'Group 1',
  274. // Optional: a field 'visible'
  275. // Optional: a field 'className'
  276. // Optional: options
  277. })
  278. groups.add({
  279. // more groups...
  280. });
  281. </pre>
  282. <p>
  283. Groups can have the following properties:
  284. </p>
  285. <table class="moduleTable">
  286. <tr class="header">
  287. <td>Name</td>
  288. <td>Type</td>
  289. <td>Required</td>
  290. <td>Description</td>
  291. </tr>
  292. <tr>
  293. <td>id</td>
  294. <td class="mid">String or Number</td>
  295. <td>yes</td>
  296. <td>An id for the group. The group will display all items having a
  297. property <code>group</code> which matches the <code>id</code>
  298. of the group.</td>
  299. </tr>
  300. <tr>
  301. <td>content</td>
  302. <td class="mid">String</td>
  303. <td>yes</td>
  304. <td>The contents of the group. This can be plain text or html code.</td>
  305. </tr>
  306. <tr>
  307. <td>className</td>
  308. <td class="mid">String</td>
  309. <td>no</td>
  310. <td>This field is optional. A className can be used to give groups
  311. an individual css style.
  312. </td>
  313. </tr>
  314. <tr>
  315. <td>style</td>
  316. <td class="mid">String</td>
  317. <td>no</td>
  318. <td>This field is optional. A style can be used to give groups
  319. an individual css style, and any style tags specified in style will
  320. override the definition in the className style defined in css.
  321. </td>
  322. </tr>
  323. <tr>
  324. <td>options</td>
  325. <td class="mid">Object</td>
  326. <td>no</td>
  327. <td>This field is optional. The options can be used to give a group a specific draw style.
  328. Any options that are colored green in the Configuration Options can be used as options here.
  329. </tr>
  330. <tr>
  331. <td>visible</td>
  332. <td class="mid">Boolean</td>
  333. <td class="mid">true</td>
  334. <td>This field is optional. If false, this group will not be drawn.
  335. </tr>
  336. </table>
  337. <h2 id="Configuration_Options">Configuration Options</h2>
  338. <h3 id="graph2dOptions">Graph2d Options</h3>
  339. Options can be used to customize the Graph2d to your purposes. These options can be passed to the Graph2d object either in
  340. the constructor, or by the <code>setOptions</code> function.
  341. <pre class="prettyprint lang-js options">
  342. var options = {
  343. width: '100%',
  344. height: '400px',
  345. style: 'surface'
  346. };
  347. </pre>
  348. The options colored in green can also be used as options for the groups. All options are optional.
  349. <table class="moduleTable" id="g2dOptions">
  350. <tr class="header">
  351. <td>Name</td>
  352. <td>Type</td>
  353. <td>Default</td>
  354. <td>Description</td>
  355. </tr>
  356. <tr>
  357. <td>defaultGroup</td>
  358. <td class="mid">String</td>
  359. <td class="mid">'default'</td>
  360. <td>This is the label for the default, ungrouped items when shown in a legend.</td>
  361. </tr>
  362. <tr class='toggle collapsible' onclick="toggleTable('g2dOptions','barChart', this);">
  363. <td class="greenField"><span parent="barChart" class="right-caret"></span> barChart</td>
  364. <td class="mid">Object</td>
  365. <td class="mid"></td>
  366. <td>Define the properties of the barchart style.</td>
  367. </tr>
  368. <tr parent="barChart" class="hidden">
  369. <td class="greenField indent">barChart.align</td>
  370. <td class="mid">String</td>
  371. <td class="mid">'center'</td>
  372. <td>The alignment of the bars with regards to the coordinate. The options are 'left', 'right' or 'center'.</td>
  373. </tr>
  374. <tr parent="barChart" class="hidden">
  375. <td class="greenField indent">barChart.sideBySide</td>
  376. <td class="mid">Boolean</td>
  377. <td class="mid">false</td>
  378. <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.
  379. See <a href="../examples/graph2d/10_barsSideBySide.html">example 10</a> for more information.
  380. When using groups, see <a href="../examples/graph2d/11_barsSideBySideGroups.html">example 11</a>.
  381. </td>
  382. </tr>
  383. <tr parent="barChart" class="hidden">
  384. <td class="greenField indent">barChart.width</td>
  385. <td class="mid">Number</td>
  386. <td class="mid">50</td>
  387. <td>The width of the bars.</td>
  388. </tr>
  389. <tr class='toggle collapsible' onclick="toggleTable('g2dOptions','dataAxis', this);">
  390. <td><span parent="dataAxis" class="right-caret"></span> dataAxis</td>
  391. <td class="mid">Object</td>
  392. <td class="mid"></td>
  393. <td>Define the properties of the left and right dataAxis.</td>
  394. </tr>
  395. <tr parent="dataAxis" class="hidden">
  396. <td class="indent">dataAxis.alignZeros</td>
  397. <td class="mid">Boolean</td>
  398. <td class="mid">true</td>
  399. <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
  400. height, you can turn this option on.</td>
  401. </tr>
  402. <tr parent="dataAxis" class="hidden">
  403. <td class="indent">dataAxis.icons</td>
  404. <td class="mid">Boolean</td>
  405. <td class="mid">false</td>
  406. <td>Toggle the drawing of automatically generated icons the Y axis.</td>
  407. </tr>
  408. <tr parent="dataAxis" class="hidden">
  409. <td class="indent2">dataAxis.left.format</td>
  410. <td class="mid">Function</td>
  411. <td class="mid"></td>
  412. <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:
  413. <pre class="code">
  414. function (value) {
  415. return value;
  416. }
  417. </pre>
  418. which does nothing to it.</td>
  419. </tr>
  420. <tr parent="dataAxis" class="hidden">
  421. <td class="indent2">dataAxis.left.range.min</td>
  422. <td class="mid">Number</td>
  423. <td class="mid">undefined</td>
  424. <td>Set the minimum value of the left y-Axis.</td>
  425. </tr>
  426. <tr parent="dataAxis" class="hidden">
  427. <td class="indent2">dataAxis.left.range.max</td>
  428. <td class="mid">Number</td>
  429. <td class="mid">undefined</td>
  430. <td>Set the maximum value of the left y-Axis.</td>
  431. </tr>
  432. <tr parent="dataAxis" class="hidden">
  433. <td class="indent2">dataAxis.left.title.style</td>
  434. <td class="mid">String</td>
  435. <td class="mid">undefined</td>
  436. <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>
  437. </tr>
  438. <tr parent="dataAxis" class="hidden">
  439. <td class="indent2">dataAxis.left.title.text</td>
  440. <td class="mid">String</td>
  441. <td class="mid">undefined</td>
  442. <td>Set the title for the left axis.</td>
  443. </tr>
  444. <tr parent="dataAxis" class="hidden">
  445. <td class="indent2">dataAxis.right.format</td>
  446. <td class="mid">Function</td>
  447. <td class="mid"></td>
  448. <td>Same explaination as the left side.</td>
  449. </tr>
  450. <tr parent="dataAxis" class="hidden">
  451. <td class="indent2">dataAxis.right.range.min</td>
  452. <td class="mid">Number</td>
  453. <td class="mid">undefined</td>
  454. <td>Set the minimum value of the right y-Axis.</td>
  455. </tr>
  456. <tr parent="dataAxis" class="hidden">
  457. <td class="indent2">dataAxis.right.range.max</td>
  458. <td class="mid">Number</td>
  459. <td class="mid">undefined</td>
  460. <td>Set the maximum value of the right y-Axis.</td>
  461. </tr>
  462. <tr parent="dataAxis" class="hidden">
  463. <td class="indent2">dataAxis.right.title.style</td>
  464. <td class="mid">String</td>
  465. <td class="mid">undefined</td>
  466. <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>
  467. </tr>
  468. <tr parent="dataAxis" class="hidden">
  469. <td class="indent2">dataAxis.right.title.text</td>
  470. <td class="mid">String</td>
  471. <td class="mid">undefined</td>
  472. <td>Set the title for the right axis.</td>
  473. </tr>
  474. <tr parent="dataAxis" class="hidden">
  475. <td class="indent">dataAxis.showMinorLabels</td>
  476. <td class="mid">Boolean</td>
  477. <td class="mid">true</td>
  478. <td>Toggle the drawing of the minor labels on the Y axis.</td>
  479. </tr>
  480. <tr parent="dataAxis" class="hidden">
  481. <td class="indent">dataAxis.showMajorLabels</td>
  482. <td class="mid">Boolean</td>
  483. <td class="mid">true</td>
  484. <td>Toggle the drawing of the major labels on the Y axis.</td>
  485. </tr>
  486. <tr parent="dataAxis" class="hidden">
  487. <td class="indent">dataAxis.visible</td>
  488. <td class="mid">Boolean</td>
  489. <td class="mid">true</td>
  490. <td>Show or hide the data axis.</td>
  491. </tr>
  492. <tr parent="dataAxis" class="hidden">
  493. <td class="indent">dataAxis.width</td>
  494. <td class="mid">Number or String</td>
  495. <td class="mid">'40px'</td>
  496. <td>Set the (minimal) width of the yAxis. The axis will resize to accomodate the labels of the Y values.</td>
  497. </tr>
  498. <tr class='toggle collapsible' onclick="toggleTable('g2dOptions','drawPoints', this);">
  499. <td class="greenField"><span parent="drawPoints" class="right-caret"></span> drawPoints</td>
  500. <td class="mid">Boolean or Object</td>
  501. <td class="mid">true</td>
  502. <td>Toggle the drawing of the datapoints with the default settings.</td>
  503. </tr>
  504. <tr parent="drawPoints" class="hidden">
  505. <td class="greenField indent">drawPoints.enabled</td>
  506. <td class="mid">Boolean</td>
  507. <td class="mid">true</td>
  508. <td>Toggle the drawing of the datapoints.</td>
  509. </tr>
  510. <tr parent="drawPoints" class="hidden">
  511. <td class="greenField indent">drawPoints.size</td>
  512. <td class="mid">Number</td>
  513. <td class="mid">6</td>
  514. <td>Determine the size at which the data points are drawn.</td>
  515. </tr>
  516. <tr parent="drawPoints" class="hidden">
  517. <td class="greenField indent">drawPoints.style</td>
  518. <td class="mid">String</td>
  519. <td class="mid">'square'</td>
  520. <td>Determine the shape of the data points. The options are 'square' or 'circle'.</td>
  521. </tr>
  522. <tr>
  523. <td>graphHeight</td>
  524. <td class="mid">Number or String</td>
  525. <td class="mid">'400px'</td>
  526. <td>This is the height of the graph SVG canvas.
  527. If it is larger than the height of the outer frame, you can drag up and down
  528. the vertical direction as well as the usual horizontal direction.</td>
  529. </tr>
  530. <tr>
  531. <td>groups.visibility</td>
  532. <td class="mid">Object</td>
  533. <td class="mid"></td>
  534. <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
  535. this is not communicated across instances of graph2d. Take a look at <a href="../examples/graph2d/14_toggleGroups.html">Example 14</a>
  536. for more explanation.
  537. </td>
  538. </tr>
  539. <tr class='toggle collapsible' onclick="toggleTable('g2dOptions','interpolation', this);">
  540. <td class="greenField"><span parent="interpolation" class="right-caret"></span> interpolation</td>
  541. <td class="mid">Boolean or Object</td>
  542. <td class="mid">true</td>
  543. <td>Toggle the interpolation with the default settings. For more customization use the JSON format.</td>
  544. </tr>
  545. <tr parent="interpolation" class="hidden">
  546. <td class="greenField indent">interpolation.enabled</td>
  547. <td class="mid">Boolean</td>
  548. <td class="mid">true</td>
  549. <td>Toggle the interpolation.</td>
  550. </tr>
  551. <tr parent="interpolation" class="hidden">
  552. <td class="greenField indent">interpolation.parametrization</td>
  553. <td class="mid">String</td>
  554. <td class="mid">'centripetal'</td>
  555. <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.
  556. If interpolation is disabled, linear interpolation is used.</td>
  557. </tr>
  558. <tr class='toggle collapsible' onclick="toggleTable('g2dOptions','legend', this);">
  559. <td><span parent="legend" class="right-caret"></span> legend</td>
  560. <td class="mid">Boolean or Object</td>
  561. <td class="mid">false</td>
  562. <td>Toggle the legend with the default settings.</td>
  563. </tr>
  564. <tr parent="legend" class="hidden">
  565. <td class="indent">legend.enabled</td>
  566. <td class="mid">Boolean</td>
  567. <td class="mid">false</td>
  568. <td>Toggle the legend.</td>
  569. </tr>
  570. <tr parent="legend" class="hidden">
  571. <td class="indent">legend.icons</td>
  572. <td class="mid">Boolean</td>
  573. <td class="mid">true</td>
  574. <td>Show automatically generated icons on the legend.</td>
  575. </tr>
  576. <tr parent="legend" class="hidden">
  577. <td class="indent2">legend.left.visible</td>
  578. <td class="mid">Boolean</td>
  579. <td class="mid">true</td>
  580. <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>
  581. </tr>
  582. <tr parent="legend" class="hidden">
  583. <td class="indent2">legend.left.position</td>
  584. <td class="mid">String</td>
  585. <td class="mid">'top-left'</td>
  586. <td>Determine the position of the legend coupled to the left axis. Options are 'top-left', 'top-right', 'bottom-left' or 'bottom-right'.</td>
  587. </tr>
  588. <tr parent="legend" class="hidden">
  589. <td class="indent2">legend.right.visible</td>
  590. <td class="mid">Boolean</td>
  591. <td class="mid">true</td>
  592. <td>This toggles the visibility of the legend that is coupled with the right axis.</td>
  593. </tr>
  594. <tr parent="legend" class="hidden">
  595. <td class="indent2">legend.right.position</td>
  596. <td class="mid">String</td>
  597. <td class="mid">'top-right'</td>
  598. <td>Determine the position of the legend coupled to the right axis. Options are 'top-left', 'top-right', 'bottom-left' or 'bottom-right'.</td>
  599. </tr>
  600. <tr>
  601. <td class="greenField">sampling</td>
  602. <td class="mid">Boolean</td>
  603. <td class="mid">true</td>
  604. <td>If sampling is enabled, Graph2d will automatically determine the amount of points per pixel.
  605. If there are more than 1 point per pixel, not all points will be drawn. Disabling sampling will cause a decrease in performance.</td>
  606. </tr>
  607. <tr>
  608. <td class="greenField">sort</td>
  609. <td class="mid">Boolean</td>
  610. <td class="mid">true</td>
  611. <td>This determines if the items are sorted automatically.
  612. They are sorted by the x value. If sort is enabled, more optimizations are possible, increasing the performance.</td>
  613. </tr>
  614. <tr>
  615. <td class="greenField">stack</td>
  616. <td class="mid">Boolean</td>
  617. <td class="mid">true</td>
  618. <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>
  619. </tr>
  620. <tr class='toggle collapsible' onclick="toggleTable('g2dOptions','shaded', this);">
  621. <td class="greenField"><span parent="shaded" class="right-caret"></span> shaded</td>
  622. <td class="mid">Boolean or Object</td>
  623. <td class="mid">false</td>
  624. <td>Toggle a shaded area with the default settings.</td>
  625. </tr>
  626. <tr parent="shaded" class="hidden">
  627. <td class="greenField indent">shaded.enabled</td>
  628. <td class="mid">Boolean</td>
  629. <td class="mid">false</td>
  630. <td>This toggles the shading.</td>
  631. </tr>
  632. <tr parent="shaded" class="hidden">
  633. <td class="greenField indent">shaded.orientation</td>
  634. <td class="mid">String</td>
  635. <td class="mid">'bottom'</td>
  636. <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>
  637. </tr>
  638. <tr parent="shaded" class="hidden">
  639. <td class="greenField indent">shaded.style</td>
  640. <td class="mid">String</td>
  641. <td class="mid">undefined</td>
  642. <td>Set the style for the shading. This is a css string and it will override the attributes set in the class.</td>
  643. </tr>
  644. <tr parent="shaded" class="hidden">
  645. <td class="greenField indent">style</td>
  646. <td class="mid">String</td>
  647. <td class="mid">'line'</td>
  648. <td>This allows the user to define if this should be a linegraph, barchart or pointcloud. The options are: 'line', 'bar', 'points'.</td>
  649. </tr>
  650. <tr>
  651. <td class="greenField">yAxisOrientation</td>
  652. <td class="mid">String</td>
  653. <td class="mid">'left'</td>
  654. <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
  655. with an axis, it will not be shown.</td>
  656. </tr>
  657. </table>
  658. <h3 id="timelineOptions">Timeline Options</h3>
  659. <p>
  660. Graph2d is built upon the framework of the timeline. These options from the timeline can be used with graph2D.
  661. All options are optional.
  662. </p>
  663. <table class="moduleTable" id="optionTable">
  664. <tr class="header">
  665. <td>Name</td>
  666. <td>Type</td>
  667. <td>Default</td>
  668. <td>Description</td>
  669. </tr>
  670. <tr>
  671. <td>autoResize</td>
  672. <td class="mid">Boolean</td>
  673. <td class="mid">true</td>
  674. <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>
  675. </tr>
  676. <tr>
  677. <td>clickToUse</td>
  678. <td class="mid">Boolean</td>
  679. <td class="mid">false</td>
  680. <td>When a Graph2d is configured to be <code>clickToUse</code>, it will react to mouse and touch events only when active.
  681. 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>
  682. </tr>
  683. <tr>
  684. <td>end</td>
  685. <td class="mid">Date or Number or String</td>
  686. <td class="mid">none</td>
  687. <td>The initial end date for the axis of the timeline.
  688. If not provided, the latest date present in the items set is taken as
  689. end date.</td>
  690. </tr>
  691. <tr>
  692. <td>format</td>
  693. <td class="mid">Object</td>
  694. <td class="mid">none</td>
  695. <td>
  696. Apply custom date formatting of the labels on the time axis. The default value of <code>format</code> is:
  697. <pre class="prettyprint lang-js">{
  698. minorLabels: {
  699. millisecond:'SSS',
  700. second: 's',
  701. minute: 'HH:mm',
  702. hour: 'HH:mm',
  703. weekday: 'ddd D',
  704. day: 'D',
  705. month: 'MMM',
  706. year: 'YYYY'
  707. },
  708. majorLabels: {
  709. millisecond:'HH:mm:ss',
  710. second: 'D MMMM HH:mm',
  711. minute: 'ddd D MMMM',
  712. hour: 'ddd D MMMM',
  713. weekday: 'MMMM YYYY',
  714. day: 'MMMM YYYY',
  715. month: 'YYYY',
  716. year: ''
  717. }
  718. }</pre>
  719. For values which not provided in the customized <code>options.format</code>, the default values will be used.
  720. All available formatting syntax is described in the <a href="http://momentjs.com/docs/#/displaying/format/">docs of moment.js</a>.
  721. </td>
  722. </tr>
  723. <tr>
  724. <td>height</td>
  725. <td class="mid">Number or String</td>
  726. <td class="mid">none</td>
  727. <td>The height of the timeline in pixels or as a percentage.
  728. When height is undefined or null, the height of the timeline is automatically
  729. adjusted to fit the contents.
  730. It is possible to set a maximum height using option <code>maxHeight</code>
  731. to prevent the timeline from getting too high in case of automatically
  732. calculated height.
  733. </td>
  734. </tr>
  735. <tr>
  736. <td>hiddenDates</td>
  737. <td class="mid">Object</td>
  738. <td class="mid">none</td>
  739. <td>This option allows you to hide specific timespans from the time axis. The dates can be supplied as an object:
  740. <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.
  741. 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
  742. and set repeat to weekly.
  743. </td>
  744. </tr>
  745. <tr>
  746. <td>locale</td>
  747. <td class="mid">String</td>
  748. <td class="mid">none</td>
  749. <td>Select a locale for the Graph2d. See section <a href="timeline.html#Localization">Localization</a> for more information.</td>
  750. </tr>
  751. <tr>
  752. <td>locales</td>
  753. <td class="mid">Object</td>
  754. <td class="mid">none</td>
  755. <td>A map with i18n locales. See section <a href="timeline.html#Localization">Localization</a> for more information.</td>
  756. </tr>
  757. <tr>
  758. <td>max</td>
  759. <td class="mid">Date or Number or String</td>
  760. <td class="mid">none</td>
  761. <td>Set a maximum Date for the visible range.
  762. It will not be possible to move beyond this maximum.
  763. </td>
  764. </tr>
  765. <tr>
  766. <td>maxHeight</td>
  767. <td class="mid">Number or String</td>
  768. <td class="mid">none</td>
  769. <td>Specifies the maximum height for the Timeline. Can be a number in pixels or a string like "300px".</td>
  770. </tr>
  771. <tr>
  772. <td>min</td>
  773. <td class="mid">Date or Number or String</td>
  774. <td class="mid">none</td>
  775. <td>Set a minimum Date for the visible range.
  776. It will not be possible to move beyond this minimum.
  777. </td>
  778. </tr>
  779. <tr>
  780. <td>minHeight</td>
  781. <td class="mid">Number or String</td>
  782. <td class="mid">none</td>
  783. <td>Specifies the minimum height for the Timeline. Can be a number in pixels or a string like "300px".</td>
  784. </tr>
  785. <tr>
  786. <td>moveable</td>
  787. <td class="mid">boolean</td>
  788. <td class="mid"><code>true</code></td>
  789. <td>
  790. Specifies whether the Timeline can be moved and zoomed by dragging the window.
  791. See also option <code>zoomable</code>.
  792. </td>
  793. </tr>
  794. <tr>
  795. <td>orientation</td>
  796. <td class="mid">String</td>
  797. <td class="mid">'bottom'</td>
  798. <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>
  799. </tr>
  800. <tr>
  801. <td>showCurrentTime</td>
  802. <td class="mid">Boolean</td>
  803. <td class="mid">true</td>
  804. <td>Show a vertical bar at the current time.</td>
  805. </tr>
  806. <tr>
  807. <td>showCustomTime</td>
  808. <td class="mid">Boolean</td>
  809. <td class="mid">false</td>
  810. <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>
  811. </tr>
  812. <tr>
  813. <td>showMajorLabels</td>
  814. <td class="mid">Boolean</td>
  815. <td class="mid">true</td>
  816. <td>By default, the timeline shows both minor and major date labels on the
  817. time axis.
  818. For example the minor labels show minutes and the major labels show hours.
  819. When <code>showMajorLabels</code> is <code>false</code>, no major labels
  820. are shown.</td>
  821. </tr>
  822. <tr>
  823. <td>showMinorLabels</td>
  824. <td class="mid">Boolean</td>
  825. <td class="mid">true</td>
  826. <td>By default, the timeline shows both minor and major date labels on the
  827. time axis.
  828. For example the minor labels show minutes and the major labels show hours.
  829. When <code>showMinorLabels</code> is <code>false</code>, no minor labels
  830. are shown. When both <code>showMajorLabels</code> and
  831. <code>showMinorLabels</code> are false, no horizontal axis will be
  832. visible.</td>
  833. </tr>
  834. <tr>
  835. <td>showMajorLines</td>
  836. <td class="mid">Boolean</td>
  837. <td class="mid">true</td>
  838. <td>By default, the timeline shows both minor and major date lines on the
  839. time axis. You can use this option to hide the lines from the major dates.
  840. </tr>
  841. <tr>
  842. <td>showMinorLines</td>
  843. <td class="mid">Boolean</td>
  844. <td class="mid">true</td>
  845. <td>By default, the timeline shows both minor and major date lines on the
  846. time axis. You can use this option to hide the lines from the minor dates.
  847. </tr>
  848. <tr>
  849. <td>start</td>
  850. <td class="mid">Date or Number or String</td>
  851. <td class="mid">none</td>
  852. <td>The initial start date for the axis of the timeline.
  853. If not provided, the earliest date present in the events is taken as start date.</td>
  854. </tr>
  855. <tr class='toggle collapsible' onclick="toggleTable('optionTable','timeAxis', this);">
  856. <td><span parent="timeAxis" class="right-caret"></span> timeAxis</td>
  857. <td class="mid">Object</td>
  858. <td class="mid"><code>Object</code></td>
  859. <td>Specify a fixed scale and step size for the time axis.</td>
  860. </tr>
  861. <tr parent="timeAxis" class="hidden">
  862. <td class="indent">timeAxis.scale</td>
  863. <td class="mid">String</td>
  864. <td class="mid">none</td>
  865. <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:
  866. <pre class="prettyprint lang-js options">var options = {
  867. timeAxis: {scale: 'minute', step: 5}
  868. }</pre>
  869. </td>
  870. </tr>
  871. <tr parent="timeAxis" class="hidden">
  872. <td class="indent">timeAxis.step</td>
  873. <td class="mid">number</td>
  874. <td class="mid"><code>1</code></td>
  875. <td>
  876. Set a fixed step size for the time axis. Only applicable when used together with <code>timeAxis.scale</code>.
  877. Choose for example 1, 2, 5, or 10.</td>
  878. </tr>
  879. <tr>
  880. <td>width</td>
  881. <td class="mid">String</td>
  882. <td class="mid">'100%'</td>
  883. <td>The width of the timeline in pixels or as a percentage.</td>
  884. </tr>
  885. <tr>
  886. <td>zoomMax</td>
  887. <td class="mid">Number</td>
  888. <td class="mid">315360000000000</td>
  889. <td>Set a maximum zoom interval for the visible range in milliseconds.
  890. It will not be possible to zoom out further than this maximum.
  891. Default value equals about 10000 years.
  892. </td>
  893. </tr>
  894. <tr>
  895. <td>zoomMin</td>
  896. <td class="mid">Number</td>
  897. <td class="mid">10</td>
  898. <td>Set a minimum zoom interval for the visible range in milliseconds.
  899. It will not be possible to zoom in further than this minimum.
  900. </td>
  901. </tr>
  902. </table>
  903. <h2 id="Methods">Methods</h2>
  904. <p>
  905. The Graph2d supports the following methods.
  906. </p>
  907. <table class="moduleTable">
  908. <tr class="header">
  909. <td>Method</td>
  910. <td>Return Type</td>
  911. <td>Description</td>
  912. </tr>
  913. <tr>
  914. <td>clear([what])</td>
  915. <td class="mid">none</td>
  916. <td>
  917. Clear the Graph2d. An object can be passed specifying which sections to clear: items, groups,
  918. and/or options. By Default, items, groups and options are cleared, i.e. <code>what = {items: true, groups: true, options: true}</code>. Example usage:
  919. <pre class="prettyprint lang-js options">Graph2d.clear(); // clear items, groups, and options
  920. Graph2d.clear({options: true}); // clear options only
  921. </pre>
  922. </td>
  923. </tr>
  924. <tr>
  925. <td>destroy()</td>
  926. <td class="mid">none</td>
  927. <td>Destroy the Graph2d. The Graph2d is removed from memory. all DOM elements and event listeners are cleaned up.
  928. </td>
  929. </tr>
  930. <tr>
  931. <td>fit()</td>
  932. <td class="mid">none</td>
  933. <td>Adjust the visible window such that it fits all items.
  934. </td>
  935. </tr>
  936. <tr>
  937. <td>getCurrentTime()</td>
  938. <td class="mid">Date</td>
  939. <td>Get the current time. Only applicable when option <code>showCurrentTime</code> is true.
  940. </td>
  941. </tr>
  942. <tr>
  943. <td>getCustomTime()</td>
  944. <td class="mid">Date</td>
  945. <td>Retrieve the custom time. Only applicable when the option <code>showCustomTime</code> is true.
  946. </td>
  947. </tr>
  948. <tr id="getEventProperties">
  949. <td>getEventProperties(event)</td>
  950. <td class="mid">Object</td>
  951. <td>
  952. Returns an Object with relevant properties from an event:
  953. <ul>
  954. <li><code>pageX</code> (Number): absolute horizontal position of the click event.</li>
  955. <li><code>pageY</code> (Number): absolute vertical position of the click event.</li>
  956. <li><code>x</code> (Number): relative horizontal position of the click event.</li>
  957. <li><code>y</code> (Number): relative vertical position of the click event.</li>
  958. <li><code>time</code> (Date): Date of the clicked event.</li>
  959. <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>
  960. <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>
  961. <li><code>event</code> (Object): the original click event.</li>
  962. </ul>
  963. </td>
  964. </tr>
  965. <tr>
  966. <td>getLegend(groupId, iconWidth, iconHeight)</td>
  967. <td class="mid">SVGelement, String, String</td>
  968. <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).
  969. </td>
  970. </tr>
  971. <tr>
  972. <td>getWindow()</td>
  973. <td class="mid">Object</td>
  974. <td>Get the current visible window. Returns an object with properties <code>start: Date</code> and <code>end: Date</code>.</td>
  975. </tr>
  976. <tr>
  977. <td>getItemRange()</td>
  978. <td class="mid">Object</td>
  979. <td>Get the range of all the items as an object containing <code>min: Date</code> and <code>max: Date</code>.</td>
  980. </tr>
  981. <tr>
  982. <td>isGroupVisible(groupId)</td>
  983. <td class="mid">Boolean</td>
  984. <td>This checks if the visible option of the supplied group (by ID) is true or false.
  985. </td>
  986. </tr>
  987. <tr>
  988. <td>moveTo(time [, options])</td>
  989. <td class="mid">none</td>
  990. <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:
  991. <ul>
  992. <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>
  993. </ul>
  994. </td>
  995. </tr>
  996. <tr>
  997. <td>on(event, callback)</td>
  998. <td class="mid">none</td>
  999. <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>
  1000. </tr>
  1001. <tr>
  1002. <td>off(event, callback)</td>
  1003. <td class="mid">none</td>
  1004. <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>
  1005. </tr>
  1006. <tr>
  1007. <td>redraw()</td>
  1008. <td class="mid">none</td>
  1009. <td>Force a redraw of the Graph2d. Can be useful to manually redraw when option autoResize=false.
  1010. </td>
  1011. </tr>
  1012. <tr>
  1013. <td>setCurrentTime(time)</td>
  1014. <td class="mid">none</td>
  1015. <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.
  1016. <code>time</code> can be a Date object, numeric timestamp, or ISO date string.
  1017. Only applicable when option <code>showCurrentTime</code> is true.</td>
  1018. </tr>
  1019. <tr>
  1020. <td>setCustomTime(time)</td>
  1021. <td class="mid">none</td>
  1022. <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.
  1023. </td>
  1024. </tr>
  1025. <tr>
  1026. <td>setGroups(groups)</td>
  1027. <td class="mid">none</td>
  1028. <td>Set a data set with groups for the Graph2d.
  1029. <code>groups</code> can be an Array with Objects,
  1030. a DataSet, or a DataView. For each of the groups, the items of the
  1031. Graph2d are filtered on the property <code>group</code>, which
  1032. must correspond with the id of the group.
  1033. </td>
  1034. </tr>
  1035. <tr>
  1036. <td>setItems(items)</td>
  1037. <td class="mid">none</td>
  1038. <td>Set a data set with items for the Graph2d.
  1039. <code>items</code> can be an Array with Objects,
  1040. a DataSet, or a DataView.
  1041. </td>
  1042. </tr>
  1043. <tr>
  1044. <td>setOptions(options)</td>
  1045. <td class="mid">none</td>
  1046. <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.
  1047. </td>
  1048. </tr>
  1049. <tr>
  1050. <td>setWindow(start, end)</td>
  1051. <td class="mid">none</td>
  1052. <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>
  1053. </tr>
  1054. </table>
  1055. <h2 id="Events">Events</h2>
  1056. <p>
  1057. Graph2d fires events when changing the visible window by dragging, when
  1058. selecting items, and when dragging the custom time bar.
  1059. </p>
  1060. <p>
  1061. Here an example on how to listen for a <code>rangeChanged</code> event. A listener can be removed via the function <code>off</code>:
  1062. </p>
  1063. <pre class="prettyprint lang-js">
  1064. function onChange (properties) {
  1065. alert('changed!');
  1066. }
  1067. // add event listener
  1068. Graph2d.on('rangechanged', onChange);
  1069. // do stuff...
  1070. // remove event listener
  1071. Graph2d.off('rangechanged', onChange);
  1072. </pre>
  1073. <p>
  1074. The following events are available.
  1075. </p>
  1076. <table class="moduleTable">
  1077. <tr class="header">
  1078. <td>name</td>
  1079. <td>Description</td>
  1080. <td>Properties</td>
  1081. </tr>
  1082. <tr>
  1083. <td>click</td>
  1084. <td>Fired when clicked inside the Graph2d.
  1085. </td>
  1086. <td>
  1087. Passes a properties object as returned by the method <a href="#getEventProperties"><code>Graph2d.getEventProperties(event)</code></a>.
  1088. </td>
  1089. </tr>
  1090. <tr>
  1091. <td>contextmenu</td>
  1092. <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:
  1093. <pre class="prettyprint lang-js options">graph2d.on('contextmenu', function (props) {
  1094. alert('Right click!');
  1095. props.event.preventDefault();
  1096. });
  1097. </pre>
  1098. </td>
  1099. <td>
  1100. Passes a properties object as returned by the method <a href="#getEventProperties"><code>Graph2d.getEventProperties(event)</code></a>.
  1101. </td>
  1102. </tr>
  1103. <tr>
  1104. <td>doubleClick</td>
  1105. <td>Fired when double clicked inside the Graph2d.
  1106. </td>
  1107. <td>
  1108. Passes a properties object as returned by the method <a href="#getEventProperties"><code>Graph2d.getEventProperties(event)</code></a>.
  1109. </td>
  1110. </tr>
  1111. <tr>
  1112. <td>finishedRedraw</td>
  1113. <td>Fired after a redraw is complete. When moving the Graph2d around, this could be fired frequently.
  1114. </td>
  1115. <td>
  1116. none.
  1117. </td>
  1118. </tr>
  1119. <tr>
  1120. <td>rangechange</td>
  1121. <td>Fired repeatedly when the user is dragging the Graph2d window.
  1122. </td>
  1123. <td>
  1124. <ul>
  1125. <li><code>start</code> (Number): timestamp of the current start of the window.</li>
  1126. <li><code>end</code> (Number): timestamp of the current end of the window.</li>
  1127. </ul>
  1128. </td>
  1129. </tr>
  1130. <tr>
  1131. <td>rangechanged</td>
  1132. <td>Fired once after the user has dragged the Graph2d window.
  1133. </td>
  1134. <td>
  1135. <ul>
  1136. <li><code>start</code> (Number): timestamp of the current start of the window.</li>
  1137. <li><code>end</code> (Number): timestamp of the current end of the window.</li>
  1138. </ul>
  1139. </td>
  1140. </tr>
  1141. <tr>
  1142. <td>timechange</td>
  1143. <td>Fired repeatedly when the user is dragging the custom time bar.
  1144. Only available when the custom time bar is enabled.
  1145. </td>
  1146. <td>
  1147. <ul>
  1148. <li><code>time</code> (Date): the current time.</li>
  1149. </ul>
  1150. </td>
  1151. </tr>
  1152. <tr>
  1153. <td>timechanged</td>
  1154. <td>Fired once after the user has dragged the custom time bar.
  1155. Only available when the custom time bar is enabled.
  1156. </td>
  1157. <td>
  1158. <ul>
  1159. <li><code>time</code> (Date): the current time.</li>
  1160. </ul>
  1161. </td>
  1162. </tr>
  1163. </table>
  1164. <h2 id="Localization">Localization</h2>
  1165. <p>
  1166. 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.
  1167. </p>
  1168. <p>
  1169. To set a locale for the Graph2d, specify the option <code>locale</code>:
  1170. </p>
  1171. <pre class="prettyprint lang-js">var options = {
  1172. locale: 'nl'
  1173. };
  1174. </pre>
  1175. <h3>Create a new locale</h3>
  1176. To load a locale into the Graph2d not supported by default, one can add a new locale to the option <code>locales</code>:
  1177. <pre class="prettyprint lang-js">var options = {
  1178. locales: {
  1179. // create a new locale
  1180. mylocale: {
  1181. current: 'current',
  1182. time: 'time',
  1183. }
  1184. },
  1185. // use the new locale
  1186. locale: 'mylocale'
  1187. };
  1188. </pre>
  1189. <h3 id="available-locales">Available locales</h3>
  1190. Graph2d comes with support for the following locales:
  1191. <table>
  1192. <tr><td>Language</td><td>Code</td></tr>
  1193. <tr>
  1194. <td>English</td>
  1195. <td>
  1196. <code>en</code><br>
  1197. <code>en_EN</code><br>
  1198. <code>en_US</code>
  1199. </td>
  1200. </tr>
  1201. <tr>
  1202. <td>Dutch</td>
  1203. <td>
  1204. <code>nl</code><br>
  1205. <code>nl_NL</code><br>
  1206. <code>nl_BE</code>
  1207. </td>
  1208. </tr>
  1209. </table>
  1210. <h2 id="Styles">Styles</h2>
  1211. <p>
  1212. All parts of the Graph2d have a class name and a default css style just like the Graph2d.
  1213. The styles can be overwritten, which enables full customization of the layout
  1214. of the Graph2d.
  1215. </p>
  1216. <p>
  1217. Additionally, Graph2d has 10 preset styles for graphs, which are cycled through when loading groups. These styles can be overwritten
  1218. as well, along with defining your own classes to style the graphs! <a href="../examples/graph2d/04_rightAxis.html">Example 4</a> and
  1219. <a href="../examples/graph2d/05_bothAxis.html">example 5</a> show the usage of custom styles.
  1220. </p>
  1221. <br>
  1222. <br>
  1223. <br>
  1224. <br>
  1225. <br>
  1226. <br>
  1227. <br>
  1228. <br>
  1229. <br>
  1230. <br>
  1231. </div>
  1232. <!-- Bootstrap core JavaScript
  1233. ================================================== -->
  1234. <!-- Placed at the end of the document so the pages load faster -->
  1235. <script src="../js/jquery.min.js"></script>
  1236. <script src="../js/bootstrap.min.js"></script>
  1237. <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
  1238. <script src="../js/ie10-viewport-bug-workaround.js"></script>