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.

79 lines
2.3 KiB

10 years ago
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  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="http://www.google.com/jsapi"></script>
  9. <script type="text/javascript" src="../graph3d.js"></script>
  10. <script type="text/javascript">
  11. var data = null;
  12. var graph = null;
  13. google.load("visualization", "1");
  14. // Set callback to run when API is loaded
  15. google.setOnLoadCallback(drawVisualization);
  16. // Called when the Visualization API is loaded.
  17. function drawVisualization() {
  18. // create the data table.
  19. data = new google.visualization.DataTable();
  20. data.addColumn('number', 'x');
  21. data.addColumn('number', 'y');
  22. data.addColumn('number', 'z');
  23. data.addColumn('number', 'value');
  24. // create some shortcuts to math functions
  25. var sqrt = Math.sqrt;
  26. var pow = Math.pow;
  27. var random = Math.random;
  28. // create the animation data
  29. var imax = 100;
  30. for (var i = 0; i < imax; i++) {
  31. var x = pow(random(), 2);
  32. var y = pow(random(), 2);
  33. var z = pow(random(), 2);
  34. var dist = sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2));
  35. var range = sqrt(2) - dist;
  36. data.addRow([x, y, z, range]);
  37. }
  38. // specify options
  39. var options = {
  40. width: "600px",
  41. height: "600px",
  42. style: "dot-size",
  43. showPerspective: false,
  44. showGrid: true,
  45. keepAspectRatio: true,
  46. verticalRatio: 1.0,
  47. cameraPosition: {
  48. horizontal: -0.54,
  49. vertical: 0.5,
  50. distance: 1.6
  51. }
  52. };
  53. // Instantiate our graph object.
  54. graph = new links.Graph3d(document.getElementById('mygraph'));
  55. // Draw our graph with the created data and options
  56. graph.draw(data, options);
  57. }
  58. </script>
  59. </head>
  60. <body>
  61. <div id="mygraph"></div>
  62. <div id="info"></div>
  63. </body>
  64. </html>