mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-11 18:32:50 +00:00
changed colors and added humidity
This commit is contained in:
@@ -76,12 +76,12 @@ function displayChart(chart_id, chart_legend_id, year, month){
|
|||||||
|
|
||||||
data.datasets.push({
|
data.datasets.push({
|
||||||
label: "Max Temperature",
|
label: "Max Temperature",
|
||||||
fillColor: "rgba(220,220,220,0.2)",
|
fillColor: "rgba(255,100,100,0.2)",
|
||||||
strokeColor: "rgba(220,220,220,1)",
|
strokeColor: "rgba(255,100,100,1)",
|
||||||
pointColor: "rgba(220,220,220,1)",
|
pointColor: "rgba(255,100,100,1)",
|
||||||
pointStrokeColor: "#fff",
|
pointStrokeColor: "#fff",
|
||||||
pointHighlightFill: "#fff",
|
pointHighlightFill: "#fff",
|
||||||
pointHighlightStroke: "rgba(220,220,220,1)",
|
pointHighlightStroke: "rgba(255,50,50,1)",
|
||||||
data: []
|
data: []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -93,6 +93,16 @@ function displayChart(chart_id, chart_legend_id, year, month){
|
|||||||
pointHighlightFill: "#fff",
|
pointHighlightFill: "#fff",
|
||||||
pointHighlightStroke: "rgba(151,187,205,1)",
|
pointHighlightStroke: "rgba(151,187,205,1)",
|
||||||
data: []
|
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){
|
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[0].data.push(json[i].max);
|
||||||
data.datasets[1].data.push(json[i].min);
|
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.
|
// 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 = {
|
Chart.defaults.global = {
|
||||||
// Boolean - Whether to animate the chart
|
// Boolean - Whether to animate the chart
|
||||||
animation: true,
|
animation: true,
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ router.get('/allsensors', function(req, res, next) {
|
|||||||
min : {$min : "$temperature"}}},
|
min : {$min : "$temperature"}}},
|
||||||
{$sort : {"_id.month" : 1, "_id.day" : 1, "_id.year" : 1}}]).exec(function(err, info){
|
{$sort : {"_id.month" : 1, "_id.day" : 1, "_id.year" : 1}}]).exec(function(err, info){
|
||||||
|
|
||||||
console.log(info);
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
res.setHeader('Content-Type', 'application/json');
|
||||||
res.send(JSON.stringify(info, null, 4));
|
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
|
//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
|
//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)}},
|
{$match : {location : loc, year : parseInt(ye)}},
|
||||||
{$group : {_id : {location : "$location", day: "$day", month : "$month", year : "$year"},
|
{$group : {_id : {location : "$location", day: "$day", month : "$month", year : "$year"},
|
||||||
max : {$max : "$temperature"},
|
max : {$max : "$temperature"},
|
||||||
min : {$min : "$temperature"}}},
|
min : {$min : "$temperature"},
|
||||||
|
humidity : {$avg : "$humidity"}}},
|
||||||
{$sort : {"_id.month" : 1, "_id.day" : 1}}]).exec(function(err, info){
|
{$sort : {"_id.month" : 1, "_id.day" : 1}}]).exec(function(err, info){
|
||||||
|
|
||||||
console.log(info);
|
|
||||||
res.setHeader('Content-Type', 'application/json');
|
res.setHeader('Content-Type', 'application/json');
|
||||||
res.send(JSON.stringify(info, null, 4));
|
res.send(JSON.stringify(info, null, 4));
|
||||||
|
|
||||||
@@ -65,14 +64,14 @@ router.get('/sensorbylocation/month', function(req, res, next) {
|
|||||||
mo = date.getMonth();
|
mo = date.getMonth();
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(ye + "/" + mo);
|
|
||||||
//query finds a entries in a collection based on location and the year specified
|
//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
|
//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)}},
|
{$match : {location : loc, year : parseInt(ye), month : parseInt(mo)}},
|
||||||
{$group : {_id : {location : "$location", day: "$day", month : "$month", year : "$year"},
|
{$group : {_id : {location : "$location", day: "$day", month : "$month", year : "$year"},
|
||||||
max : {$max : "$temperature"},
|
max : {$max : "$temperature"},
|
||||||
min : {$min : "$temperature"}}},
|
min : {$min : "$temperature"},
|
||||||
|
humidity : {$avg : "$humidity"}}},
|
||||||
{$sort : {"_id.day" : 1}}]).exec(function(err, info){
|
{$sort : {"_id.day" : 1}}]).exec(function(err, info){
|
||||||
|
|
||||||
console.log(info);
|
console.log(info);
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ router.get('/vpn', function(req, res, next){
|
|||||||
/* GET home page. */
|
/* GET home page. */
|
||||||
router.get('/', function(req, res, next) {
|
router.get('/', function(req, res, next) {
|
||||||
|
|
||||||
console.log(req.query.post);
|
|
||||||
|
|
||||||
renderIndex(res, {getPost : req.query.post, validation : {}});
|
renderIndex(res, {getPost : req.query.post, validation : {}});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -56,7 +54,6 @@ router.post('/', function(req, res,next) {
|
|||||||
|
|
||||||
|
|
||||||
var time = hours + ":" + minutes + ampm;
|
var time = hours + ":" + minutes + ampm;
|
||||||
console.log("--time: " + time);
|
|
||||||
|
|
||||||
if(!numberValidator(number)){
|
if(!numberValidator(number)){
|
||||||
invalid.number = 'Invalid Number';
|
invalid.number = 'Invalid Number';
|
||||||
@@ -117,7 +114,6 @@ router.post('/', function(req, res,next) {
|
|||||||
console.dir(entry);
|
console.dir(entry);
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(entry);
|
|
||||||
res.render('success');
|
res.render('success');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ router.get('/information', function(req, res, err){
|
|||||||
{$match : {location : sensor_location}},
|
{$match : {location : sensor_location}},
|
||||||
{$group : {_id : {year : "$year", month : "$month", location : "$location"}}},
|
{$group : {_id : {year : "$year", month : "$month", location : "$location"}}},
|
||||||
{$sort : {"_id.year" : -1, "_id.month" : -1}}]).exec(function(err, info){
|
{$sort : {"_id.year" : -1, "_id.month" : -1}}]).exec(function(err, info){
|
||||||
console.log(info);
|
|
||||||
|
|
||||||
//generate list of unique years to display in dropdown menu
|
//generate list of unique years to display in dropdown menu
|
||||||
var years_list = [];
|
var years_list = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user