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.

72 lines
1.6 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Graph 3D cloud with colored dots</title>
  5. <style>
  6. body {font: 10pt arial;}
  7. </style>
  8. <script type="text/javascript" src="../../dist/vis.js"></script>
  9. <script type="text/javascript">
  10. var data = null;
  11. var graph = null;
  12. function onclick(point) {
  13. console.log(point);
  14. }
  15. // Called when the Visualization API is loaded.
  16. function drawVisualization() {
  17. // create the data table.
  18. data = new vis.DataSet();
  19. // create some shortcuts to math functions
  20. var sqrt = Math.sqrt;
  21. var pow = Math.pow;
  22. var random = Math.random;
  23. // create the animation data
  24. var imax = 100;
  25. for (var i = 0; i < imax; i++) {
  26. var x = pow(random(), 2);
  27. var y = pow(random(), 2);
  28. var z = pow(random(), 2);
  29. var style = (i%2==0) ? sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2)) : "#00ffff";
  30. data.add({x:x,y:y,z:z,style:style});
  31. }
  32. // specify options
  33. var options = {
  34. width: '600px',
  35. height: '600px',
  36. style: 'dot-color',
  37. showPerspective: true,
  38. showGrid: true,
  39. keepAspectRatio: true,
  40. verticalRatio: 1.0,
  41. legendLabel: 'distance',
  42. onclick: onclick,
  43. cameraPosition: {
  44. horizontal: -0.35,
  45. vertical: 0.22,
  46. distance: 1.8
  47. }
  48. };
  49. // create our graph
  50. var container = document.getElementById('mygraph');
  51. graph = new vis.Graph3d(container, data, options);
  52. }
  53. </script>
  54. </head>
  55. <body onload="drawVisualization()">
  56. <div id="mygraph"></div>
  57. <div id="info"></div>
  58. </body>
  59. </html>