1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-11 18:32:50 +00:00
Files
mywebsite/public/javascripts/sensor_information.js
2015-12-19 03:53:29 -06:00

78 lines
2.3 KiB
JavaScript

$(document).ready(function(){
Chart.defaults.global.responsive = true;
var loc = $("#sensor-location").text();
console.log(loc);
loc = loc.split().join("+");
$.get("/api/sensorbylocation?location=" + loc, function(request){
var json = request;
var data = {labels : [], datasets : []};
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)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(220,220,220,1)",
data: []
},
{
label: "Min Temperature",
fillColor: "rgba(151,187,205,0.2)",
strokeColor: "rgba(151,187,205,1)",
pointColor: "rgba(151,187,205,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(151,187,205,1)",
data: []
});
for (var i in json){
data.labels.push(json[i]._id.month + "/" + json[i]._id.day + "/" + json[i]._id.year);
data.datasets[0].data.push(json[i].max);
data.datasets[1].data.push(json[i].min);
}
// Get context with jQuery - using jQuery's .get() method.
var ctx = $("#info-chart").get(0).getContext("2d");
// This will get the first returned node in the jQuery collection.
var myLineChart = new Chart(ctx).Line(data);
});
});
var test123 = {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [
{
label: "My First dataset",
fillColor: "rgba(220,220,220,0.2)",
strokeColor: "rgba(220,220,220,1)",
pointColor: "rgba(220,220,220,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(220,220,220,1)",
data: [65, 59, 80, 81, 56, 55, 40]
},
{
label: "My Second dataset",
fillColor: "rgba(151,187,205,0.2)",
strokeColor: "rgba(151,187,205,1)",
pointColor: "rgba(151,187,205,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(151,187,205,1)",
data: [28, 48, 40, 19, 86, 27, 90]
}
]
};