This program fetches data from the Data Canvas - Sense Your City API.
Last active
August 29, 2015 14:16
-
-
Save curran/5f255332a9dcb9906f84 to your computer and use it in GitHub Desktop.
Data Canvas Part 1 - Data
This file contains 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> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script> | |
<meta charset="utf-8"> | |
<title>Getting the Data</title> | |
</head> | |
<body> | |
<h2>All fields available in Geneva, every 5 minutes, for the past 24 hours.</h2> | |
<div id="container"></div> | |
<script> | |
// See API documentation at http://map.datacanvas.org/#!/data | |
var API_URL = "http://sensor-api.localdata.com/api/v1/aggregations.csv"; | |
$.get(API_URL, { | |
op: "mean", | |
fields: "temperature,light,airquality_raw,sound,humidity,dust", | |
resolution: "5m", | |
"over.city": "Geneva", | |
from: new Date(Date.now() - 1000 * 60 * 60 * 24).toISOString(), | |
before: new Date().toISOString() | |
}, function(csv) { | |
var data = d3.csv.parse(csv), | |
container = d3.select("#container"); | |
container.append("p").text(data.length + " rows"); | |
container.append("p").text( Object.getOwnPropertyNames(data[0]).length + " columns" ); | |
container.append("p").text("raw data: " + csv); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment