-
-
Save schappim/ea0fe0cc5305e12b90f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <!-- EXTERNAL LIBS--> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> | |
| <script src="https://www.google.com/jsapi"></script> | |
| <!-- EXAMPLE SCRIPT --> | |
| <script> | |
| // onload callback | |
| function drawChart() { | |
| var public_key = 'xRlVOD5Q3Qu60YzRZ8Wx'; | |
| // JSONP request | |
| var jsonData = $.ajax({ | |
| url: 'https://data.sparkfun.com/output/' + public_key + '.json', | |
| data: {page: 1}, | |
| dataType: 'jsonp', | |
| }).done(function (results) { | |
| var data = new google.visualization.DataTable(); | |
| data.addColumn('datetime', 'Time'); | |
| data.addColumn('number', 'Temperature'); | |
| data.addColumn('number', 'Humidity'); | |
| $.each(results, function (i, row) { | |
| data.addRow([ | |
| (new Date(row.timestamp)), | |
| parseFloat(row.temperature), | |
| parseFloat(row.humidity) | |
| ]); | |
| }); | |
| var chart = new google.visualization.LineChart($('#chart').get(0)); | |
| chart.draw(data, { | |
| title: 'Workshop Weather Station' | |
| }); | |
| }); | |
| } | |
| // load chart lib | |
| google.load('visualization', '1', { | |
| packages: ['corechart'] | |
| }); | |
| // call drawChart once google charts is loaded | |
| google.setOnLoadCallback(drawChart); | |
| </script> | |
| </head> | |
| <body> | |
| <div id="chart" style="width: 100%;"></div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment