Datastream Time Series Chart
by openfirmware
HTML
<script src="http://canarie-sensor-rpi.github.io/geocens-js-api/javascripts/geocens.js"></script>
<script src="http://canarie-sensor-rpi.github.io/geocens-js-api/javascripts/highstock.js"></script>
<script src="http://canarie-sensor-rpi.github.io/geocens-js-api/javascripts/geocens-chart.js"></script>
<div id="chart"></div>
JavaScript
// Draw the chart after time series is returned
var drawChart = function (seriesData, datastream) {
var chart = $("#chart").GeocensChart({
datastream: datastream
});
};
// Retrieve the time series after datastream is returned
var getSeries = function (datastream) {
datastream.getTimeSeries({
start: new Date("2012-01-01T00:00:00Z"),
end: new Date("2013-01-01T00:00:00Z"),
done: drawChart
});
};
// Retrieve the datastream
Geocens.DataService.getDatastream({
api_key: "57378dc18d74bef1051312e29a26f0b3",
sensor_id: "4ddecd5124661f9442cfca8be23f8dda",
datastream_id: "ccc92c6fe57dff592ff687d99c4ebf70",
done: getSeries
});