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.

90 lines
2.8 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 Internet Explorer 9 support</title>
  5. <style>
  6. body {font: 10pt arial; width: 600px; }
  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. function custom(x, y) {
  17. return (Math.sin(x/50) * Math.cos(y/50) * 50 + 50);
  18. }
  19. // Called when the Visualization API is loaded.
  20. function drawVisualization() {
  21. // Create and populate a data table.
  22. data = new google.visualization.DataTable();
  23. data.addColumn('number', 'x');
  24. data.addColumn('number', 'y');
  25. data.addColumn('number', 'value');
  26. // create some nice looking data with sin/cos
  27. var steps = 50; // number of datapoints will be steps*steps
  28. var axisMax = 314;
  29. var axisStep = axisMax / steps;
  30. for (var x = 0; x < axisMax; x+=axisStep) {
  31. for (var y = 0; y < axisMax; y+=axisStep) {
  32. var value = custom(x,y);
  33. data.addRow([x, y, value]);
  34. }
  35. }
  36. // specify options
  37. var options = {
  38. width: "100%",
  39. height: "600px",
  40. style: "surface",
  41. showPerspective: true,
  42. showGrid: true,
  43. showShadow: false,
  44. keepAspectRatio: true,
  45. verticalRatio: 0.5
  46. };
  47. // Instantiate our graph object.
  48. graph = new links.Graph3d(document.getElementById('mygraph'));
  49. // Draw our graph with the created data and options
  50. graph.draw(data, options);
  51. }
  52. </script>
  53. </head>
  54. <body>
  55. <p>
  56. Graph3D uses the HTML Canvas element. This element is supported by all
  57. major browsers. The Canvas element is also supported in Internet Explorer
  58. 9 and newer. However, for Internet Explorer it is necessary to specify
  59. the doctype of the html page:
  60. </p>
  61. <pre style= "margin-left:40px;" ><code >
  62. <b style= "color:red;" >&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;</b>
  63. &lt;html&gt;
  64. &lt;head&gt;
  65. &lt;!-- ... --&gt;
  66. &lt;/head&gt;
  67. &lt;body&gt;
  68. &lt;!-- ... --&gt;
  69. &lt;/body&gt;
  70. &lt;/html&gt;
  71. </code></pre>
  72. <div id="mygraph"></div>
  73. <div id="info"></div>
  74. </body>
  75. </html>