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.

69 lines
1.6 KiB

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Graph 3D cloud with sized 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. // Called when the Visualization API is loaded.
  13. function drawVisualization() {
  14. // create the data table.
  15. data = new vis.DataSet();
  16. // create some shortcuts to math functions
  17. var sqrt = Math.sqrt;
  18. var pow = Math.pow;
  19. var random = Math.random;
  20. // create the animation data
  21. var imax = 100;
  22. for (var i = 0; i < imax; i++) {
  23. var x = pow(random(), 2);
  24. var y = pow(random(), 2);
  25. var z = pow(random(), 2);
  26. var dist = sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2));
  27. var range = sqrt(2) - dist;
  28. data.add({x:x,y:y,z:z,style:range});
  29. }
  30. // specify options
  31. var options = {
  32. width: '600px',
  33. height: '600px',
  34. style: 'dot-size',
  35. showPerspective: false,
  36. showGrid: true,
  37. keepAspectRatio: true,
  38. legendLabel:'value',
  39. verticalRatio: 1.0,
  40. cameraPosition: {
  41. horizontal: -0.54,
  42. vertical: 0.5,
  43. distance: 1.6
  44. },
  45. dotSizeMinFraction: 0.5,
  46. dotSizeMaxFraction: 2.5
  47. };
  48. // create our graph
  49. var container = document.getElementById('mygraph');
  50. graph = new vis.Graph3d(container, data, options);
  51. }
  52. </script>
  53. </head>
  54. <body onload="drawVisualization()">
  55. <div id="mygraph"></div>
  56. <div id="info"></div>
  57. </body>
  58. </html>