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.

101 lines
3.4 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>Data from datasource</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 dataSourceUrl = "datasource.php";
  12. var data = null;
  13. var graph = null;
  14. var query = null;
  15. function sendRequest () {
  16. drawVisualization = function(response) {
  17. document.getElementById("info").innerHTML = "";
  18. document.getElementById("getdata").disabled = "";
  19. if (response.isError()) {
  20. alert('Error: ' + response.getMessage());
  21. return;
  22. }
  23. // retrieve the data from the query response
  24. data = response.getDataTable();
  25. // specify options
  26. var options = {width: "600px",
  27. height: "600px",
  28. style: "surface",
  29. showPerspective: true,
  30. showGrid: true,
  31. showShadow: false,
  32. keepAspectRatio: true,
  33. verticalRatio: 0.5
  34. };
  35. // Instantiate our graph object.
  36. graph = new links.Graph3d(document.getElementById('mygraph'));
  37. // Draw our graph with the created data and options
  38. graph.draw(data, options);
  39. };
  40. // built up the url with parameters
  41. var url = dataSourceUrl + "?" +
  42. "xmin=" + document.getElementById("xmin").value + "&" +
  43. "xmax=" + document.getElementById("xmax").value + "&" +
  44. "xstepnum=" + document.getElementById("xstepnum").value + "&" +
  45. "ymin=" + document.getElementById("ymin").value+ "&" +
  46. "ymax=" + document.getElementById("ymax").value + "&" +
  47. "ystepnum=" + document.getElementById("ystepnum").value;
  48. document.getElementById("info").innerHTML = "Loading...";
  49. document.getElementById("getdata").disabled = "disabled";
  50. // send the request
  51. query && query.abort();
  52. query = new google.visualization.Query(url);
  53. query.send(drawVisualization);
  54. }
  55. google.load("visualization", "1");
  56. // Set callback to run when API is loaded
  57. google.setOnLoadCallback(sendRequest);
  58. </script>
  59. </head>
  60. <body>
  61. <h1>Data from datasource</h1>
  62. <p style="font-style:italic;">
  63. Note: this example works only when running it on a PHP server,
  64. as the datasource is a php file.
  65. </p>
  66. <p>
  67. xmin: <input type="text" value="-100" id="xmin" style="width:50px;">
  68. xmax: <input type="text" value="300" id="xmax" style="width:50px;">
  69. steps: <input type="text" value="50" id="xstepnum" style="width:50px;">
  70. </p>
  71. <p>
  72. ymin: <input type="text" value="-100" id="ymin" style="width:50px;">
  73. ymax: <input type="text" value="100" id="ymax" style="width:50px;">
  74. steps: <input type="text" value="25" id="ystepnum" style="width:50px;">
  75. </p>
  76. <p>
  77. <input type="button" value="Get Data" id="getdata" onclick="sendRequest();">
  78. <span id="info"></span>
  79. </p>
  80. <div id="mygraph"></div>
  81. <div id="info"></div>
  82. </body>
  83. </html>