mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-12 02:42:48 +00:00
fixed charts
This commit is contained in:
@@ -1,8 +1,16 @@
|
|||||||
$(document).ready(function(){
|
$(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(){
|
$("#option-year").on("change", function(){
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ router.get('/information', function(req, res, err){
|
|||||||
temperature.aggregate([{$project : {location : "$location", year : {$year : "$updated"}, month : {$month : "$updated"}}},
|
temperature.aggregate([{$project : {location : "$location", year : {$year : "$updated"}, month : {$month : "$updated"}}},
|
||||||
{$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);
|
console.log(info);
|
||||||
|
|
||||||
//generate list of unique years to display in dropdown menu
|
//generate list of unique years to display in dropdown menu
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
<form class="text-center form-inline">
|
<form class="text-center form-inline">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="input-year">Year</label>
|
|
||||||
<select class="form-control" id="option-year">
|
<select class="form-control" id="option-year">
|
||||||
<%
|
<%
|
||||||
for (var i in years_list){ %>
|
for (var i in years_list){ %>
|
||||||
@@ -40,7 +39,6 @@
|
|||||||
|
|
||||||
<form class="text-center form-inline">
|
<form class="text-center form-inline">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="input-month">Month</label>
|
|
||||||
<select class="form-control" id="option-month">
|
<select class="form-control" id="option-month">
|
||||||
<%
|
<%
|
||||||
for (var i in info){ %>
|
for (var i in info){ %>
|
||||||
@@ -53,7 +51,6 @@
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<h2 class="text-center">Month</h2>
|
|
||||||
<canvas class="center" id="info-chart-month" width="800" height="400"></canvas>
|
<canvas class="center" id="info-chart-month" width="800" height="400"></canvas>
|
||||||
<br>
|
<br>
|
||||||
<div id="legend-month" class="chart-legend"></div>
|
<div id="legend-month" class="chart-legend"></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user