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.

922 lines
28 KiB

  1. <?js
  2. var self = this;
  3. ?>
  4. <!DOCTYPE html>
  5. <html lang="en"><head>
  6. <meta charset="utf-8">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  8. <meta name="viewport" content="width=device-width, initial-scale=1">
  9. <meta name="description" content="">
  10. <meta name="author" content="">
  11. <link rel="icon" HREF="favicon.ico">
  12. <title>graph3d - vis.js - A dynamic, browser based visualization library.</title>
  13. <!-- Bootstrap core CSS -->
  14. <link href="../css/bootstrap.css" rel="stylesheet">
  15. <!-- Tipue vendor css -->
  16. <link href="../css/tipuesearch.css" rel="stylesheet">
  17. <link href="../css/style.css" rel="stylesheet">
  18. <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  19. <!--[if lt IE 9]>
  20. <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  21. <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  22. <![endif]-->
  23. <link href="../css/prettify.css" type="text/css" rel="stylesheet"/>
  24. <script type="text/javascript" src="../js/googleAnalytics.js"></script>
  25. <script type="text/javascript" src="../js/prettify/prettify.js"></script>
  26. <script src="../js/smooth-scroll.min.js"></script>
  27. <script language="JavaScript">
  28. smoothScroll.init();
  29. </script>
  30. <script type="text/javascript" src="../js/toggleTable.js"></script>
  31. </head>
  32. <body onload="prettyPrint();">
  33. <?js= self.partial('tmpl/navbar.tmpl') ?>
  34. <div class="container full">
  35. <h1>Graph3d</h1>
  36. <h2 id="Overview">Overview</h2>
  37. <p>
  38. Graph3d is an interactive visualization chart to draw data in a three dimensional
  39. graph. You can freely move and zoom in the graph by dragging and scrolling in the
  40. window. Graph3d also supports animation of a graph.
  41. </p>
  42. <p>
  43. Graph3d uses <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Canvas">HTML canvas</a>
  44. to render graphs, and can render up to a few thousands of data points smoothly.
  45. </p>
  46. <h2 id="Contents">Contents</h2>
  47. <ul>
  48. <li><a href="#Overview">Overview</a></li>
  49. <li><a href="#Loading">Loading</a></li>
  50. <li><a href="#Data_Format">Data Format</a></li>
  51. <li><a href="#Configuration_Options">Configuration Options</a></li>
  52. <li><a href="#Methods">Methods</a></li>
  53. <li><a href="#Events">Events</a></li>
  54. <li><a href="#Data_Policy">Data Policy</a></li>
  55. </ul>
  56. <h2 id="Example">Example</h2>
  57. <p>
  58. The following code shows how to create a Graph3d and provide it with data.
  59. More examples can be found in the <a href="../examples">examples</a> directory.
  60. </p>
  61. <pre class="prettyprint lang-html">
  62. &lt;!DOCTYPE HTML&gt;
  63. &lt;html&gt;
  64. &lt;head&gt;
  65. &lt;title&gt;Graph 3D demo&lt;/title&gt;
  66. &lt;style&gt;
  67. body {font: 10pt arial;}
  68. &lt;/style&gt;
  69. &lt;script type="text/javascript" src="../../dist/vis.js"&gt;&lt;/script&gt;
  70. &lt;script type="text/javascript"&gt;
  71. var data = null;
  72. var graph = null;
  73. function custom(x, y) {
  74. return (Math.sin(x/50) * Math.cos(y/50) * 50 + 50);
  75. }
  76. // Called when the Visualization API is loaded.
  77. function drawVisualization() {
  78. // Create and populate a data table.
  79. var data = new vis.DataSet();
  80. // create some nice looking data with sin/cos
  81. var steps = 50; // number of datapoints will be steps*steps
  82. var axisMax = 314;
  83. var axisStep = axisMax / steps;
  84. for (var x = 0; x &lt; axisMax; x+=axisStep) {
  85. for (var y = 0; y &lt; axisMax; y+=axisStep) {
  86. var value = custom(x, y);
  87. data.add({
  88. x: x,
  89. y: y,
  90. z: value,
  91. style: value
  92. });
  93. }
  94. }
  95. // specify options
  96. var options = {
  97. width: '600px',
  98. height: '600px',
  99. style: 'surface',
  100. showPerspective: true,
  101. showGrid: true,
  102. showShadow: false,
  103. keepAspectRatio: true,
  104. verticalRatio: 0.5
  105. };
  106. // create a graph3d
  107. var container = document.getElementById('mygraph');
  108. graph3d = new vis.Graph3d(container, data, options);
  109. }
  110. &lt;/script&gt;
  111. &lt;/head&gt;
  112. &lt;body onload="drawVisualization();"&gt;
  113. &lt;div id="mygraph"&gt;&lt;/div&gt;
  114. &lt;/body&gt;
  115. &lt;/html&gt;
  116. </pre>
  117. <h2 id="Loading">Loading</h2>
  118. <p>
  119. The class name of the Graph3d is <code>vis.Graph3d</code>.
  120. When constructing a Graph3d, an HTML DOM container must be provided to attach
  121. the graph to. Optionally, data and options can be provided.
  122. Data is a vis <code>DataSet</code> or an <code>Array</code>, described in
  123. section <a href="#Data_Format">Data Format</a>.
  124. Options is a name-value map in the JSON format. The available options
  125. are described in section <a href="#Configuration_Options">Configuration Options</a>.
  126. </p>
  127. <pre class="prettyprint lang-js">var graph = new vis.Graph3d(container [, data] [, options]);</pre>
  128. <p>
  129. Data and options can be set or changed later on using the functions
  130. <code>Graph3d.setData(data)</code> and <code>Graph3d.setOptions(options)</code>.
  131. </p>
  132. <h2 id="Data_Format">Data Format</h2>
  133. <p>
  134. Graph3d can load data from an <code>Array</code>, a <code>DataSet</code> (offering 2 way data binding), or a <code>DataView</code> (offering 1 way data binding).
  135. JSON objects are added to this DataSet by using the <code>add()</code> function.
  136. Data points must have properties <code>x</code>, <code>y</code>, and <code>z</code>,
  137. and can optionally have a property <code>style</code> and <code>filter</code>.
  138. <h3>Definition</h3>
  139. <p>
  140. The DataSet JSON objects are defined as:
  141. </p>
  142. <table class="properties">
  143. <tr>
  144. <th>Name</th>
  145. <th>Type</th>
  146. <th>Required</th>
  147. <th>Description</th>
  148. </tr>
  149. <tr>
  150. <td>x</td>
  151. <td>number</td>
  152. <td>yes</td>
  153. <td>Location on the x-axis.</td>
  154. </tr>
  155. <tr>
  156. <td>y</td>
  157. <td>number</td>
  158. <td>yes</td>
  159. <td>Location on the y-axis.</td>
  160. </tr>
  161. <tr>
  162. <td>z</td>
  163. <td>number</td>
  164. <td>yes</td>
  165. <td>Location on the z-axis.</td>
  166. </tr>
  167. <tr>
  168. <td>style</td>
  169. <td>number</td>
  170. <td>no</td>
  171. <td>The data value, required for graph styles <code>dot-color</code> and
  172. <code>dot-size</code>.
  173. </td>
  174. </tr>
  175. <tr>
  176. <td>filter</td>
  177. <td>*</td>
  178. <td>no</td>
  179. <td>Filter values used for the animation.
  180. This column may have any type, such as a number, string, or Date.</td>
  181. </tr>
  182. </table>
  183. <h2 id="Configuration_Options">Configuration Options</h2>
  184. <p>
  185. Options can be used to customize the graph. Options are defined as a JSON object.
  186. All options are optional.
  187. </p>
  188. <pre class="prettyprint lang-js">
  189. var options = {
  190. width: '100%',
  191. height: '400px',
  192. style: 'surface'
  193. };
  194. </pre>
  195. <p>
  196. The following options are available.
  197. </p>
  198. <table class="options" id="optionTable">
  199. <tr>
  200. <th>Name</th>
  201. <th>Type</th>
  202. <th>Default</th>
  203. <th>Description</th>
  204. </tr>
  205. <tr>
  206. <td>animationInterval</td>
  207. <td>number</td>
  208. <td>1000</td>
  209. <td>The animation interval in milliseconds. This determines how fast
  210. the animation runs.</td>
  211. </tr>
  212. <tr>
  213. <td>animationPreload</td>
  214. <td>boolean</td>
  215. <td>false</td>
  216. <td>If false, the animation frames are loaded as soon as they are requested.
  217. if <code>animationPreload</code> is true, the graph will automatically load
  218. all frames in the background, resulting in a smoother animation as soon as
  219. all frames are loaded. The load progress is shown on screen.</td>
  220. </tr>
  221. <tr>
  222. <td>animationAutoStart</td>
  223. <td>boolean</td>
  224. <td>false</td>
  225. <td>If true, the animation starts playing automatically after the graph
  226. is created.</td>
  227. </tr>
  228. <tr>
  229. <td>axisColor</td>
  230. <td>string</td>
  231. <td>'#4D4D4D'</td>
  232. <td>The color of the axis lines and the text along the axis.</td>
  233. </tr>
  234. <tr class='toggle collapsible' onclick="toggleTable('optionTable','backgroundColor', this);">
  235. <td><span parent="backgroundColor" class="right-caret"></span> backgroundColor</td>
  236. <td>string or Object</td>
  237. <td>Object</td>
  238. <td>The background color for the main area of the chart.
  239. Can be either a simple HTML color string, for example: 'red' or '#00cc00',
  240. or an object with the following properties.</td>
  241. </tr>
  242. <tr parent="backgroundColor" class="hidden">
  243. <td class="indent">backgroundColor.fill</td>
  244. <td>string</td>
  245. <td>'white'</td>
  246. <td>The chart fill color, as an HTML color string.</td>
  247. </tr>
  248. <tr parent="backgroundColor" class="hidden">
  249. <td class="indent">backgroundColor.stroke</td>
  250. <td>string</td>
  251. <td>'gray'</td>
  252. <td>The color of the chart border, as an HTML color string.</td>
  253. </tr>
  254. <tr>
  255. <tr parent="backgroundColor" class="hidden">
  256. <td class="indent">backgroundColor.strokeWidth</td>
  257. <td>number</td>
  258. <td>1</td>
  259. <td>The border width, in pixels.</td>
  260. </tr>
  261. <tr class='toggle collapsible' onclick="toggleTable('optionTable','cameraPosition', this);">
  262. <td><span parent="cameraPosition" class="right-caret"></span> cameraPosition</td>
  263. <td>Object</td>
  264. <td>Object</td>
  265. <td>Set the initial rotation and position of the camera.
  266. All parameters are optional.
  267. </tr>
  268. <tr parent="cameraPosition" class="hidden">
  269. <td class="indent">cameraPosition.horizontal</td>
  270. <td>number</td>
  271. <td>1.0</td>
  272. <td>Value in radians. It can have any
  273. value, but is normally in the range of 0 and 2*Pi.</td>
  274. </tr>
  275. <tr parent="cameraPosition" class="hidden">
  276. <td class="indent">cameraPosition.vertical</td>
  277. <td>number</td>
  278. <td>0.5</td>
  279. <td>Value in radians between 0 and 0.5*Pi.</td>
  280. </tr>
  281. <tr parent="cameraPosition" class="hidden">
  282. <td class="indent">cameraPosition.distance</td>
  283. <td>number</td>
  284. <td>1.7</td>
  285. <td>The (normalized) distance from the
  286. camera to the center of the graph, in the range of 0.71 to 5.0. A
  287. larger distance puts the graph further away, making it smaller.</p>
  288. </tr>
  289. <tr class='toggle collapsible' onclick="toggleTable('optionTable','dataColor', this);">
  290. <td><span parent="dataColor" class="right-caret"></span> dataColor</td>
  291. <td>string or object</td>
  292. <td>Object</td>
  293. <td>When <code>dataColor</code> is a string, it will set the color for both border and fill color of dots and bars. Applicable for styles <code>dot-size</code>, <code>bar-size</code>, and <code>line</code>. When an object, it can contain the properties descibed below.</td>
  294. </tr>
  295. <tr parent="dataColor" class="hidden">
  296. <td class="indent">dataColor.fill</td>
  297. <td>string</td>
  298. <td>'#7DC1FF'</td>
  299. <td>The fill color of the dots or bars. Applicable when using styles <code>dot-size</code>, <code>bar-size</code>, or <code>line</code>.</td>
  300. </tr>
  301. <tr parent="dataColor" class="hidden">
  302. <td class="indent">dataColor.stroke</td>
  303. <td>string</td>
  304. <td>'#3267D2'</td>
  305. <td>The border color of the dots or bars. Applicable when using styles <code>dot-size</code> or <code>bar-size</code>.</td>
  306. </tr>
  307. <tr parent="dataColor" class="hidden">
  308. <td class="indent">dataColor.strokeWidth</td>
  309. <td>number</td>
  310. <td>1</td>
  311. <td>The line width of dots, bars and lines. Applicable for all styles.</td>
  312. </tr>
  313. <tr>
  314. <td>dotSizeRatio</td>
  315. <td>number</td>
  316. <td>0.02</td>
  317. <td>Ratio of the size of the dots with respect to the width of the graph.</td>
  318. </tr>
  319. <tr>
  320. <td>dotSizeMinFraction</td>
  321. <td>number</td>
  322. <td>0.5</td>
  323. <td>Size of minimum-value dot as a fraction of dotSizeRatio.
  324. Applicable when using style <code>dot-size</code>.</td>
  325. </td>
  326. </tr>
  327. <tr>
  328. <td>dotSizeMaxFraction</td>
  329. <td>number</td>
  330. <td>2.5</td>
  331. <td>Size of maximum-value dot as a fraction of dotSizeRatio.
  332. Applicable when using style <code>dot-size</code>.</td>
  333. </td>
  334. </tr>
  335. <tr>
  336. <td>gridColor</td>
  337. <td>string</td>
  338. <td>'#D3D3D3'</td>
  339. <td>The color of the grid lines.</td>
  340. </tr>
  341. <tr>
  342. <td>height</td>
  343. <td>string</td>
  344. <td>'400px'</td>
  345. <td>The height of the graph in pixels or as a percentage.</td>
  346. </tr>
  347. <tr>
  348. <td>keepAspectRatio</td>
  349. <td>boolean</td>
  350. <td>true</td>
  351. <td>If <code>keepAspectRatio</code> is true, the x-axis and the y-axis
  352. keep their aspect ratio. If false, the axes are scaled such that they
  353. both have the same, maximum with.</td>
  354. </tr>
  355. <tr>
  356. <td>onclick</td>
  357. <td>function</td>
  358. <td>none</td>
  359. <td>Event handler for a click event with signature <code>function onclick(point)</code>.<br>
  360. Parameter <code>point</code> contains data for the nearest graph element relative to the click in
  361. the line of sight. It is an object with the fields:
  362. <ul>
  363. <li><code>id </code> - id of nearest node to the click</li>
  364. <li><code>x </code> - x-coordinate in graph units</li>
  365. <li><code>y </code> - y-coordinate in graph units</li>
  366. <li><code>z </code> - z-coordinate in graph units</li>
  367. <li><code>style</code> - if present, the data value for this point</li>
  368. </ul>
  369. </td>
  370. </tr>
  371. <tr>
  372. <td>showAnimationControls</td>
  373. <td>boolean</td>
  374. <td>true</td>
  375. <td>If true, animation controls are created at the bottom of the Graph.
  376. The animation controls consists of buttons previous, start/stop, next,
  377. and a slider showing the current frame.
  378. Only applicable when the provided data contains an animation.</td>
  379. </tr>
  380. <tr>
  381. <td>showGrid</td>
  382. <td>boolean</td>
  383. <td>true</td>
  384. <td>If true, grid lines are drawn in the x-y surface (the bottom of the 3d
  385. graph).</td>
  386. </tr>
  387. <tr>
  388. <td>showXAxis</td>
  389. <td>boolean</td>
  390. <td>true</td>
  391. <td>If true, X axis and X axis labels are drawn.</td>
  392. </tr>
  393. <tr>
  394. <td>showYAxis</td>
  395. <td>boolean</td>
  396. <td>true</td>
  397. <td>If true, Y axis and Y axis labels are drawn.</td>
  398. </tr>
  399. <tr>
  400. <td>showZAxis</td>
  401. <td>boolean</td>
  402. <td>true</td>
  403. <td>If true, Z axis and Z axis labels are drawn.</td>
  404. </tr>
  405. <tr>
  406. <td>showPerspective</td>
  407. <td>boolean</td>
  408. <td>true</td>
  409. <td>If true, the graph is drawn in perspective: points and lines which
  410. are further away are drawn smaller.
  411. Note that the graph currently does not support a gray colored bottom side
  412. when drawn in perspective.
  413. </td>
  414. </tr>
  415. <tr>
  416. <td>showLegend</td>
  417. <td>boolean</td>
  418. <td>none</td>
  419. <td>If true, a legend is drawn for the graph (if the graph type supports it).
  420. By default a legend is drawn for dot and dot-color style graphs.
  421. </td>
  422. </tr>
  423. <tr>
  424. <td>showShadow</td>
  425. <td>boolean</td>
  426. <td>false</td>
  427. <td>Show shadow on the graph.</td>
  428. </tr>
  429. <tr>
  430. <td>style</td>
  431. <td>string</td>
  432. <td>'dot'</td>
  433. <td>The style of the 3d graph. Available styles:
  434. <code>bar</code>,
  435. <code>bar-color</code>,
  436. <code>bar-size</code>,
  437. <code>dot</code>,
  438. <code>dot-line</code>,
  439. <code>dot-color</code>,
  440. <code>dot-size</code>,
  441. <code>line</code>,
  442. <code>grid</code>,
  443. or <code>surface</code></td>
  444. </tr>
  445. <tr>
  446. <td>tooltip</td>
  447. <td>boolean | function</td>
  448. <td>false</td>
  449. <td>Show a tooltip showing the values of the hovered data point.
  450. The contents of the tooltip can be customized by providing a callback
  451. function as <code>tooltip</code>. In this case the function is called
  452. with an object containing parameters <code>x</code>,
  453. <code>y</code>, <code>z</code>, and <code>data</code>
  454. (the source JS object for the point) as an argument,
  455. and must return a string which may contain HTML.
  456. </td>
  457. </tr>
  458. <tr class='toggle collapsible' onclick="toggleTable('optionTable','tooltipStyle', this);">
  459. <td><span parent="tooltipStyle" class="right-caret"></span> tooltipStyle</td>
  460. <td>Object</td>
  461. <td>Object</td>
  462. </td>
  463. <td>Tooltip style properties.
  464. Provided properties will be merged with the default object.
  465. </td>
  466. </tr>
  467. <!-- Can't define separate entries for content, line and dot objects here,
  468. because toggleTable() can't handle multiple levels of collapsibles -->
  469. <tr parent="tooltipStyle" class="hidden">
  470. <td class="indent">tooltipStyle.content.padding</td>
  471. <td>string</td>
  472. <td>'10px'</td>
  473. <td></td>
  474. </tr>
  475. <tr parent="tooltipStyle" class="hidden">
  476. <td class="indent">tooltipStyle.content.border</td>
  477. <td>string</td>
  478. <td>'1px solid #4d4d4d'</td>
  479. <td></td>
  480. </tr>
  481. <tr parent="tooltipStyle" class="hidden">
  482. <td class="indent">tooltipStyle.content.color</td>
  483. <td>string</td>
  484. <td>'#1a1a1a'</td>
  485. <td></td>
  486. </tr>
  487. <tr parent="tooltipStyle" class="hidden">
  488. <td class="indent">tooltipStyle.content.background</td>
  489. <td>string</td>
  490. <td>'rgba(255,255,255,0.7)'</td>
  491. <td></td>
  492. </tr>
  493. <tr parent="tooltipStyle" class="hidden">
  494. <td class="indent">tooltipStyle.content.borderRadius</td>
  495. <td>string</td>
  496. <td>'2px'</td>
  497. <td></td>
  498. </tr>
  499. <tr parent="tooltipStyle" class="hidden">
  500. <td class="indent">tooltipStyle.content.boxShadow</td>
  501. <td>string</td>
  502. <td>'5px 5px 10px rgba(128,128,128,0.5)'</td>
  503. <td></td>
  504. </tr>
  505. <tr parent="tooltipStyle" class="hidden">
  506. <td class="indent">tooltipStyle.line.height</td>
  507. <td>string</td>
  508. <td>'40px'</td>
  509. <td></td>
  510. </tr>
  511. <tr parent="tooltipStyle" class="hidden">
  512. <td class="indent">tooltipStyle.line.width</td>
  513. <td>string</td>
  514. <td>'0'</td>
  515. <td></td>
  516. </tr>
  517. <tr parent="tooltipStyle" class="hidden">
  518. <td class="indent">tooltipStyle.line.borderLeft</td>
  519. <td>string</td>
  520. <td>'1px solid #4d4d4d'</td>
  521. <td></td>
  522. </tr>
  523. <tr parent="tooltipStyle" class="hidden">
  524. <td class="indent">tooltipStyle.dot.height</td>
  525. <td>string</td>
  526. <td>'0'</td>
  527. <td></td>
  528. </tr>
  529. <tr parent="tooltipStyle" class="hidden">
  530. <td class="indent">tooltipStyle.dot.width</td>
  531. <td>string</td>
  532. <td>'0'</td>
  533. <td></td>
  534. </tr>
  535. <tr parent="tooltipStyle" class="hidden">
  536. <td class="indent">tooltipStyle.dot.border</td>
  537. <td>string</td>
  538. <td>'5px solid #4d4d4d'</td>
  539. <td></td>
  540. </tr>
  541. <tr parent="tooltipStyle" class="hidden">
  542. <td class="indent">tooltipStyle.dot.borderRadius</td>
  543. <td>string</td>
  544. <td>'5px'</td>
  545. <td></td>
  546. </tr>
  547. <tr>
  548. <td>valueMax</td>
  549. <td>number</td>
  550. <td>none</td>
  551. <td>The maximum value for the value-axis. Only available in combination
  552. with the styles <code>dot-color</code> and <code>dot-size</code>.</td>
  553. </tr>
  554. <tr>
  555. <td>valueMin</td>
  556. <td>number</td>
  557. <td>none</td>
  558. <td>The minimum value for the value-axis. Only available in combination
  559. with the styles <code>dot-color</code> and <code>dot-size</code>.</td>
  560. </tr>
  561. <tr>
  562. <td>verticalRatio</td>
  563. <td>number</td>
  564. <td>0.5</td>
  565. <td>A value between 0.1 and 1.0. This scales the vertical size of the graph
  566. When keepAspectRatio is set to false, and verticalRatio is set to 1.0,
  567. the graph will be a cube.</td>
  568. </tr>
  569. <tr>
  570. <td>width</td>
  571. <td>string</td>
  572. <td>'400px'</td>
  573. <td>The width of the graph in pixels or as a percentage.</td>
  574. </tr>
  575. <tr>
  576. <td>xBarWidth</td>
  577. <td>number</td>
  578. <td>none</td>
  579. <td>The width of bars in x direction. By default, the width is equal to the smallest distance
  580. between the data points.
  581. Only applicable for styles <code>'bar'</code> and <code>'bar-color'</code>.</td>
  582. </tr>
  583. <tr>
  584. <td>xCenter</td>
  585. <td>string</td>
  586. <td>'55%'</td>
  587. <td>The horizontal center position of the graph, as a percentage or in
  588. pixels.</td>
  589. </tr>
  590. <tr>
  591. <td>xMax</td>
  592. <td>number</td>
  593. <td>from data</td>
  594. <td>The maximum value for the x-axis.
  595. If not set, the largest value for x in the data set is used.
  596. </td>
  597. </tr>
  598. <tr>
  599. <td>xMin</td>
  600. <td>number</td>
  601. <td>from data</td>
  602. <td>The minimum value for the x-axis.
  603. If not set, the smallest value for x in the data set is used.
  604. </td>
  605. </tr>
  606. <tr>
  607. <td>xStep</td>
  608. <td>number</td>
  609. <td>none</td>
  610. <td>Step size for the grid on the x-axis.</td>
  611. </tr>
  612. <tr>
  613. <td>xValueLabel</td>
  614. <td>function</td>
  615. <td>none</td>
  616. <td>A function for custom formatting of the labels along the x-axis,
  617. for example <code>function (x) {return (x * 100) + '%'}</code>.
  618. </td>
  619. </tr>
  620. <tr>
  621. <td>yBarWidth</td>
  622. <td>number</td>
  623. <td>none</td>
  624. <td>The width of bars in y direction. By default, the width is equal to the smallest distance
  625. between the data points.
  626. Only applicable for styles <code>'bar'</code> and <code>'bar-color'</code>.</td>
  627. </tr>
  628. <tr>
  629. <td>yCenter</td>
  630. <td>string</td>
  631. <td>'45%'</td>
  632. <td>The vertical center position of the graph, as a percentage or in
  633. pixels.</td>
  634. </tr>
  635. <tr>
  636. <td>yMax</td>
  637. <td>number</td>
  638. <td>from data</td>
  639. <td>The maximum value for the y-axis.
  640. If not set, the largest value for y in the data set is used.
  641. </td>
  642. </tr>
  643. <tr>
  644. <td>yMin</td>
  645. <td>number</td>
  646. <td>from data</td>
  647. <td>The minimum value for the y-axis.
  648. If not set, the smallest value for y in the data set is used.
  649. </td>
  650. </tr>
  651. <tr>
  652. <td>yStep</td>
  653. <td>number</td>
  654. <td>none</td>
  655. <td>Step size for the grid on the y-axis.</td>
  656. </tr>
  657. <tr>
  658. <td>yValueLabel</td>
  659. <td>function</td>
  660. <td>none</td>
  661. <td>A function for custom formatting of the labels along the y-axis,
  662. for example <code>function (y) {return (y * 100) + '%'}</code>.
  663. </td>
  664. </tr>
  665. <tr>
  666. <td>zMax</td>
  667. <td>number</td>
  668. <td>from data</td>
  669. <td>The maximum value for the z-axis.
  670. If not set, the largest value for z in the data set is used.
  671. </td>
  672. </tr>
  673. <tr>
  674. <td>zMin</td>
  675. <td>number</td>
  676. <td>from data</td>
  677. <td>The minimum value for the z-axis.
  678. If not set, the smallest value for z in the data set is used.
  679. </td>
  680. </tr>
  681. <tr>
  682. <td>zStep</td>
  683. <td>number</td>
  684. <td>none</td>
  685. <td>Step size for the grid on the z-axis.</td>
  686. </tr>
  687. <tr>
  688. <td>zValueLabel</td>
  689. <td>function</td>
  690. <td>none</td>
  691. <td>A function for custom formatting of the labels along the z-axis,
  692. for example <code>function (z) {return (z * 100) + '%'}</code>.
  693. </td>
  694. </tr>
  695. <tr>
  696. <td>xLabel</td>
  697. <td>String</td>
  698. <td>x</td>
  699. <td>Label on the X axis.</td>
  700. </tr>
  701. <tr>
  702. <td>yLabel</td>
  703. <td>String</td>
  704. <td>y</td>
  705. <td>Label on the Y axis.</td>
  706. </tr>
  707. <tr>
  708. <td>zLabel</td>
  709. <td>String</td>
  710. <td>z</td>
  711. <td>Label on the Z axis.</td>
  712. </tr>
  713. <tr>
  714. <td>filterLabel</td>
  715. <td>String</td>
  716. <td>time</td>
  717. <td>Label for the filter column.</td>
  718. </tr>
  719. <tr>
  720. <td>legendLabel</td>
  721. <td>String</td>
  722. <td>value</td>
  723. <td>Label for the style description.</td>
  724. </tr>
  725. </table>
  726. <h2 id="Methods">Methods</h2>
  727. <p>
  728. Graph3d supports the following methods.
  729. </p>
  730. <table class="methods">
  731. <tr>
  732. <th>Method</th>
  733. <th>Return Type</th>
  734. <th>Description</th>
  735. </tr>
  736. <tr>
  737. <td>animationStart()</td>
  738. <td>none</td>
  739. <td>Start playing the animation.
  740. Only applicable when animation data is available.</td>
  741. </tr>
  742. <tr>
  743. <td>animationStop()</td>
  744. <td>none</td>
  745. <td>Stop playing the animation.
  746. Only applicable when animation data is available.</td>
  747. </tr>
  748. <tr>
  749. <td>getCameraPosition()</td>
  750. <td>An object with parameters <code>horizontal</code>,
  751. <code>vertical</code> and <code>distance</code></td>
  752. <td>Returns an object with parameters <code>horizontal</code>,
  753. <code>vertical</code> and <code>distance</code>,
  754. which each one of them is a number, representing the rotation and position
  755. of the camera.</td>
  756. </tr>
  757. <tr>
  758. <td>redraw()</td>
  759. <td>none</td>
  760. <td>Redraw the graph. Useful after the camera position is changed externally,
  761. when data is changed, or when the layout of the webpage changed.</td>
  762. </tr>
  763. <tr>
  764. <td>setData(data)</td>
  765. <td>none</td>
  766. <td>Replace the data in the Graph3d.</td>
  767. </tr>
  768. <tr>
  769. <td>setOptions(options)</td>
  770. <td>none</td>
  771. <td>Update options of Graph3d.
  772. The provided options will be merged with current options.</td>
  773. </tr>
  774. <tr>
  775. <td>setSize(width, height)</td>
  776. <td>none</td>
  777. <td>Parameters <code>width</code> and <code>height</code> are strings,
  778. containing a new size for the graph. Size can be provided in pixels
  779. or in percentages.</td>
  780. </tr>
  781. <tr>
  782. <td>setCameraPosition (pos)</td>
  783. <td>{horizontal:&nbsp;1.0, vertical:&nbsp;0.5, distance:&nbsp;1.7}</td>
  784. <td>Set the rotation and position of the camera. Parameter <code>pos</code>
  785. is an object which contains three parameters: <code>horizontal</code>,
  786. <code>vertical</code>, and <code>distance</code>.
  787. Parameter <code>horizontal</code> is a value in radians and can have any
  788. value (but normally in the range of 0 and 2*Pi).
  789. Parameter <code>vertical</code> is a value in radians between 0 and 0.5*Pi.
  790. Parameter <code>distance</code> is the (normalized) distance from the
  791. camera to the center of the graph, in the range of 0.71 to 5.0. A
  792. larger distance puts the graph further away, making it smaller.
  793. All parameters are optional.
  794. </td>
  795. </tr>
  796. </table>
  797. <h2 id="Events">Events</h2>
  798. <p>
  799. Graph3d fires events after the camera position has been changed.
  800. The event can be catched by creating a listener.
  801. Here an example on how to catch a <code>cameraPositionChange</code> event.
  802. </p>
  803. <pre class="prettyprint lang-js">
  804. function onCameraPositionChange(event) {
  805. alert('The camera position changed to:\n' +
  806. 'Horizontal: ' + event.horizontal + '\n' +
  807. 'Vertical: ' + event.vertical + '\n' +
  808. 'Distance: ' + event.distance);
  809. }
  810. // assuming var graph3d = new vis.Graph3d(document.getElementById('mygraph'));
  811. graph3d.on('cameraPositionChange', onCameraPositionChange);
  812. </pre>
  813. <p>
  814. The following events are available.
  815. </p>
  816. <table class="events">
  817. <tr>
  818. <th>name</th>
  819. <th>Properties</th>
  820. <th>Description</th>
  821. </tr>
  822. <tr>
  823. <td>cameraPositionChange</td>
  824. <td>
  825. <ul>
  826. <li><code>horizontal</code>: Number. The horizontal angle of the camera.</li>
  827. <li><code>vertical</code>: Number. The vertical angle of the camera.</li>
  828. <li><code>distance</code>: Number. The distance of the camera to the center of the graph.</li>
  829. </ul>
  830. </td>
  831. <td>The camera position changed. Fired after the user modified the camera position
  832. by moving (dragging) the graph, or by zooming (scrolling),
  833. but not after a call to <code>setCameraPosition</code> method.
  834. The new camera position can be retrieved by calling the method
  835. <code>getCameraPosition</code>.</td>
  836. </tr>
  837. </table>
  838. <h2 id="Data_Policy">Data Policy</h2>
  839. <p>
  840. All code and data are processed and rendered in the browser. No data is sent to any server.
  841. </p>
  842. </div>
  843. <?js= self.partial('tmpl/html-foot.tmpl') ?>