From 31ad768941a01e0cd2500cb99a0acc4652e78bf1 Mon Sep 17 00:00:00 2001 From: mgerb42 Date: Sun, 20 Dec 2015 21:50:17 -0600 Subject: [PATCH] fixed charts --- public/javascripts/sensor_information.js | 12 ++++++++++-- routes/sensors.js | 2 +- views/sensor_information.ejs | 3 --- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/public/javascripts/sensor_information.js b/public/javascripts/sensor_information.js index 1085411..25d4845 100644 --- a/public/javascripts/sensor_information.js +++ b/public/javascripts/sensor_information.js @@ -1,8 +1,16 @@ $(document).ready(function(){ + + var yearChart_year = $("#option-year").val(); + displayChart("#info-chart-year", "#legend-year", yearChart_year, null); - displayChart("#info-chart-year", "#legend-year", 2015, null); - displayChart("#info-chart-month", "#legend-month", 2015, 9); + + var text = $("#option-month option:selected").text(); + console.log(text); + var month = $("#option-month").val(); + var monthChart_year = text.substring(text.length, text.length -4); + displayChart("#info-chart-month", "#legend-month", monthChart_year, month); + }); $("#option-year").on("change", function(){ diff --git a/routes/sensors.js b/routes/sensors.js index 4bf41aa..2a58546 100644 --- a/routes/sensors.js +++ b/routes/sensors.js @@ -78,7 +78,7 @@ router.get('/information', function(req, res, err){ temperature.aggregate([{$project : {location : "$location", year : {$year : "$updated"}, month : {$month : "$updated"}}}, {$match : {location : sensor_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 diff --git a/views/sensor_information.ejs b/views/sensor_information.ejs index a55425a..7acdca5 100644 --- a/views/sensor_information.ejs +++ b/views/sensor_information.ejs @@ -21,7 +21,6 @@
- <% for (var i in info){ %> @@ -53,7 +51,6 @@
-

Month