| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>numeric axis</title> |
| 5 | <!-- |
| 6 | For production (minified) code, use: |
| 7 | <script type="text/javascript" src="dygraph-combined.js"></script> |
| 8 | --> |
| 9 | <script type="text/javascript" src="../dist/dygraph.js"></script> |
| 10 | |
| 11 | <script type="text/javascript" src="http://www.google.com/jsapi"></script> |
| 12 | </head> |
| 13 | <body> |
| 14 | <p>CSV data source:</p> |
| 15 | <div id="div_g" style="width:600px; height:300px;"></div> |
| 16 | |
| 17 | <p>GViz data source:</p> |
| 18 | <div id="gviz" style="width:600px; height:300px;"></div> |
| 19 | |
| 20 | <script type="text/javascript"> |
| 21 | g = new Dygraph( |
| 22 | document.getElementById("div_g"), |
| 23 | function() { |
| 24 | var ret = "X,Y1,Y2\n"; |
| 25 | for (var i = 0; i < 100; i++) { |
| 26 | ret += i + "," + i + "," + (i * (100-i) * 100/(50*50)) + "\n"; |
| 27 | } |
| 28 | return ret; |
| 29 | }, |
| 30 | { } |
| 31 | ); |
| 32 | |
| 33 | google.load('visualization', '1', {packages: ['linechart']}); |
| 34 | function addGViz() { |
| 35 | data = new google.visualization.DataTable(); |
| 36 | data.addColumn('number', 'X'); |
| 37 | data.addColumn('number', 'Y1'); |
| 38 | data.addColumn('number', 'Y2'); |
| 39 | data.addRows(100); |
| 40 | for (var i = 0; i < 100; i++) { |
| 41 | data.setCell(i, 0, i); |
| 42 | data.setCell(i, 1, i); |
| 43 | data.setCell(i, 2, i * (100-i) * 100/(50*50)); |
| 44 | } |
| 45 | |
| 46 | new Dygraph.GVizChart( |
| 47 | document.getElementById('gviz')).draw(data, |
| 48 | { |
| 49 | }); |
| 50 | } |
| 51 | |
| 52 | google.setOnLoadCallback(addGViz); |
| 53 | </script> |
| 54 | </body> |
| 55 | </html> |