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.

63 lines
1.8 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
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. 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 custom(x, y) {
  13. return (Math.sin(x/50) * Math.cos(y/50) * 50 + 50);
  14. }
  15. // Called when the Visualization API is loaded.
  16. function drawVisualization() {
  17. // Create and populate a data table.
  18. var data = new vis.DataSet({});
  19. // create some nice looking data with sin/cos
  20. var steps = 50; // number of datapoints will be steps*steps
  21. var axisMax = 314;
  22. var axisStep = axisMax / steps;
  23. for (var x = 0; x < axisMax; x+=axisStep) {
  24. for (var y = 0; y < axisMax; y+=axisStep) {
  25. var value = custom(x,y);
  26. data.add([
  27. {x:x,y:y,z:value,style:value}
  28. ]);
  29. }
  30. }
  31. // specify options
  32. var options = {
  33. width: "600px",
  34. height: "600px",
  35. style: "surface",
  36. showPerspective: true,
  37. showGrid: true,
  38. showShadow: false,
  39. keepAspectRatio: true,
  40. verticalRatio: 0.5
  41. };
  42. // Instantiate our graph object.
  43. graph = new vis.Graph3d(document.getElementById('mygraph'));
  44. // Draw our graph with the created data and options
  45. graph.draw(data, options);
  46. }
  47. </script>
  48. </head>
  49. <body onload="drawVisualization();">
  50. <div id="mygraph"></div>
  51. <div id="info"></div>
  52. </body>
  53. </html>