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.

769 lines
24 KiB

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