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.

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