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