diff --git a/public/javascripts/sensor_information.js b/public/javascripts/sensor_information.js index e6b80eb..35ce2d4 100644 --- a/public/javascripts/sensor_information.js +++ b/public/javascripts/sensor_information.js @@ -76,12 +76,12 @@ function displayChart(chart_id, chart_legend_id, year, month){ data.datasets.push({ label: "Max Temperature", - fillColor: "rgba(220,220,220,0.2)", - strokeColor: "rgba(220,220,220,1)", - pointColor: "rgba(220,220,220,1)", + fillColor: "rgba(255,100,100,0.2)", + strokeColor: "rgba(255,100,100,1)", + pointColor: "rgba(255,100,100,1)", pointStrokeColor: "#fff", pointHighlightFill: "#fff", - pointHighlightStroke: "rgba(220,220,220,1)", + pointHighlightStroke: "rgba(255,50,50,1)", data: [] }, { @@ -93,6 +93,16 @@ function displayChart(chart_id, chart_legend_id, year, month){ pointHighlightFill: "#fff", pointHighlightStroke: "rgba(151,187,205,1)", data: [] + }, + { + label: "Average Humidity", + fillColor: "rgba(200,200,200,0.2)", + strokeColor: "rgba(200,200,200,1)", + pointColor: "rgba(200,200,200,1)", + pointStrokeColor: "#fff", + pointHighlightFill: "#fff", + pointHighlightStroke: "rgba(200,200,200,1)", + data: [] }); for (var i in json){ @@ -106,6 +116,7 @@ function displayChart(chart_id, chart_legend_id, year, month){ data.datasets[0].data.push(json[i].max); data.datasets[1].data.push(json[i].min); + data.datasets[2].data.push(json[i].humidity); } // Get context with jQuery - using jQuery's .get() method. @@ -121,28 +132,6 @@ function displayChart(chart_id, chart_legend_id, year, month){ } - - - - - - - - - - - - - - - - - - - - - - Chart.defaults.global = { // Boolean - Whether to animate the chart animation: true, diff --git a/routes/api.js b/routes/api.js index 102c62f..e9d719b 100644 --- a/routes/api.js +++ b/routes/api.js @@ -15,7 +15,6 @@ router.get('/allsensors', function(req, res, next) { min : {$min : "$temperature"}}}, {$sort : {"_id.month" : 1, "_id.day" : 1, "_id.year" : 1}}]).exec(function(err, info){ - console.log(info); res.setHeader('Content-Type', 'application/json'); res.send(JSON.stringify(info, null, 4)); @@ -35,14 +34,14 @@ router.get('/sensorbylocation/year', function(req, res, next) { //query finds a entries in a collection based on location and the year specified //they are then grouped by date and sorted by date as well - temperature.aggregate([ {$project : {location : 1, temperature : 1, year : {$year : "$updated"}, month : {$month : "$updated"}, day : {$dayOfMonth : "$updated"}}}, + temperature.aggregate([ {$project : {location : 1, temperature : 1, humidity : 1, year : {$year : "$updated"}, month : {$month : "$updated"}, day : {$dayOfMonth : "$updated"}}}, {$match : {location : loc, year : parseInt(ye)}}, {$group : {_id : {location : "$location", day: "$day", month : "$month", year : "$year"}, max : {$max : "$temperature"}, - min : {$min : "$temperature"}}}, + min : {$min : "$temperature"}, + humidity : {$avg : "$humidity"}}}, {$sort : {"_id.month" : 1, "_id.day" : 1}}]).exec(function(err, info){ - console.log(info); res.setHeader('Content-Type', 'application/json'); res.send(JSON.stringify(info, null, 4)); @@ -65,14 +64,14 @@ router.get('/sensorbylocation/month', function(req, res, next) { mo = date.getMonth(); } - console.log(ye + "/" + mo); //query finds a entries in a collection based on location and the year specified //they are then grouped by date and sorted by date as well - temperature.aggregate([ {$project : {location : 1, temperature : 1, year : {$year : "$updated"}, month : {$month : "$updated"}, day : {$dayOfMonth : "$updated"}}}, + temperature.aggregate([ {$project : {location : 1, temperature : 1, humidity : 1, year : {$year : "$updated"}, month : {$month : "$updated"}, day : {$dayOfMonth : "$updated"}}}, {$match : {location : loc, year : parseInt(ye), month : parseInt(mo)}}, {$group : {_id : {location : "$location", day: "$day", month : "$month", year : "$year"}, max : {$max : "$temperature"}, - min : {$min : "$temperature"}}}, + min : {$min : "$temperature"}, + humidity : {$avg : "$humidity"}}}, {$sort : {"_id.day" : 1}}]).exec(function(err, info){ console.log(info); diff --git a/routes/index.js b/routes/index.js index 29714c4..0845093 100644 --- a/routes/index.js +++ b/routes/index.js @@ -25,8 +25,6 @@ router.get('/vpn', function(req, res, next){ /* GET home page. */ router.get('/', function(req, res, next) { - console.log(req.query.post); - renderIndex(res, {getPost : req.query.post, validation : {}}); }); @@ -56,7 +54,6 @@ router.post('/', function(req, res,next) { var time = hours + ":" + minutes + ampm; - console.log("--time: " + time); if(!numberValidator(number)){ invalid.number = 'Invalid Number'; @@ -117,7 +114,6 @@ router.post('/', function(req, res,next) { console.dir(entry); }); - console.log(entry); res.render('success'); } }); diff --git a/routes/sensors.js b/routes/sensors.js index f294ff7..58bc42b 100644 --- a/routes/sensors.js +++ b/routes/sensors.js @@ -83,7 +83,6 @@ router.get('/information', function(req, res, err){ {$match : {location : sensor_location}}, {$group : {_id : {year : "$year", month : "$month", location : "$location"}}}, {$sort : {"_id.year" : -1, "_id.month" : -1}}]).exec(function(err, info){ - console.log(info); //generate list of unique years to display in dropdown menu var years_list = [];