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.

87 lines
2.6 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 demo</title>
  5. <style>
  6. html, body {
  7. font: 10pt arial;
  8. padding: 0;
  9. margin: 0;
  10. width: 100%;
  11. height: 100%;
  12. }
  13. #mygraph {
  14. position: absolute;
  15. width: 100%;
  16. height: 100%;
  17. }
  18. </style>
  19. <!-- for mobile devices like android and iphone -->
  20. <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width" />
  21. <script type="text/javascript" src="http://www.google.com/jsapi"></script>
  22. <script type="text/javascript" src="../graph3d.js"></script>
  23. <script type="text/javascript">
  24. var data = null;
  25. var graph = null;
  26. google.load("visualization", "1");
  27. // Set callback to run when API is loaded
  28. google.setOnLoadCallback(drawVisualization);
  29. function custom(x, y) {
  30. return (Math.sin(x/50) * Math.cos(y/50) * 50 + 50);
  31. }
  32. // Called when the Visualization API is loaded.
  33. function drawVisualization() {
  34. // Create and populate a data table.
  35. data = new google.visualization.DataTable();
  36. data.addColumn('number', 'x');
  37. data.addColumn('number', 'y');
  38. data.addColumn('number', 'z');
  39. // create some nice looking data with sin/cos
  40. var steps = 10; // number of datapoints will be steps*steps
  41. var axisMax = 314;
  42. var axisStep = axisMax / steps;
  43. for (var x = 0; x < axisMax; x+=axisStep) {
  44. for (var y = 0; y < axisMax; y+=axisStep) {
  45. var value = custom(x,y);
  46. data.addRow([x, y, value]);
  47. }
  48. }
  49. // specify options
  50. var options = {
  51. width: "100%",
  52. height: "100%",
  53. style: "surface",
  54. showPerspective: true,
  55. showGrid: true,
  56. showShadow: false,
  57. keepAspectRatio: true,
  58. verticalRatio: 0.5,
  59. backgroundColor: {
  60. strokeWidth: 0
  61. }
  62. };
  63. // Instantiate our graph object.
  64. graph = new links.Graph3d(document.getElementById('mygraph'));
  65. // Draw our graph with the created data and options
  66. graph.draw(data, options);
  67. }
  68. </script>
  69. </head>
  70. <body onresize="graph.redraw();">
  71. <div id="mygraph"></div>
  72. </body>
  73. </html>