Created graphs without d3 ;)
This commit is contained in:
@@ -26,3 +26,4 @@ percolate:synced-cron
|
|||||||
rzymek:moment-locale-bs
|
rzymek:moment-locale-bs
|
||||||
peppelg:bootstrap-3-modal
|
peppelg:bootstrap-3-modal
|
||||||
fortawesome:fontawesome
|
fortawesome:fontawesome
|
||||||
|
mfpierre:chartist-js
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ email@1.0.8
|
|||||||
es5-shim@4.1.14
|
es5-shim@4.1.14
|
||||||
fastclick@1.0.7
|
fastclick@1.0.7
|
||||||
fortawesome:fontawesome@4.5.0
|
fortawesome:fontawesome@4.5.0
|
||||||
|
fourseven:scss@3.4.1
|
||||||
geojson-utils@1.0.4
|
geojson-utils@1.0.4
|
||||||
handlebars@1.0.4
|
handlebars@1.0.4
|
||||||
hot-code-push@1.0.0
|
hot-code-push@1.0.0
|
||||||
@@ -47,6 +48,7 @@ localstorage@1.0.5
|
|||||||
logging@1.0.8
|
logging@1.0.8
|
||||||
meteor@1.1.10
|
meteor@1.1.10
|
||||||
meteor-base@1.0.1
|
meteor-base@1.0.1
|
||||||
|
mfpierre:chartist-js@1.6.1
|
||||||
minifiers@1.1.7
|
minifiers@1.1.7
|
||||||
minimongo@1.0.10
|
minimongo@1.0.10
|
||||||
mobile-experience@1.0.1
|
mobile-experience@1.0.1
|
||||||
|
|||||||
@@ -80,10 +80,11 @@ Template.state.helpers({
|
|||||||
|
|
||||||
pretty_days: function(daysInNumbers) {
|
pretty_days: function(daysInNumbers) {
|
||||||
var days = ["Nedjelja", "Ponedjeljak", "Utorak", "Srijeda", "Četvrtak", "Petak", "Subota"];
|
var days = ["Nedjelja", "Ponedjeljak", "Utorak", "Srijeda", "Četvrtak", "Petak", "Subota"];
|
||||||
if (daysInNumbers.length == 7) {
|
if (!daysInNumbers || daysInNumbers.length == 0) {
|
||||||
return "Svaki dan"
|
|
||||||
} else if (!daysInNumbers || daysInNumbers.length == 0) {
|
|
||||||
return "Nikad"
|
return "Nikad"
|
||||||
|
}
|
||||||
|
else if (daysInNumbers.length == 7) {
|
||||||
|
return "Svaki dan"
|
||||||
} else {
|
} else {
|
||||||
return daysInNumbers.map(function(number) {
|
return daysInNumbers.map(function(number) {
|
||||||
return days[number -1 ];
|
return days[number -1 ];
|
||||||
|
|||||||
@@ -8,9 +8,29 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 chart">
|
||||||
<div><strong>Otpusni ventil:</strong> {{pretty_valve state.out_valve }}</div>
|
<div><strong>Otpusni ventil:</strong> {{pretty_valve state.out_valve }}</div>
|
||||||
<div><strong>Ulazni ventil/pumpa:</strong> {{pretty_valve state.in_valve }}</div>
|
<div><strong>Ulazni ventil/pumpa:</strong> {{pretty_valve state.in_valve }}</div>
|
||||||
<div><strong>Zadnja komunikacija: {{ last_communication_time }}</strong></div>
|
<div><strong>Zadnja komunikacija: {{ last_communication_time }}</strong>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 chart">
|
||||||
|
<h3>Temperatura:</h3>
|
||||||
|
<div id="temperature_graph">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 chart">
|
||||||
|
<h3>Vlažnost:</h3>
|
||||||
|
<div id="humidity_graph">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
|||||||
@@ -10,5 +10,99 @@ Template.state_details.helpers({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.state_details.events({
|
Template.state_details.events({});
|
||||||
});
|
|
||||||
|
Template.state_details.rendered = function() {
|
||||||
|
this.node = this.find('#temperature_graph'); // our d3 code goes here
|
||||||
|
var yScale = d3.scale.linear()
|
||||||
|
.domain([0, 4])
|
||||||
|
.range([10, 60]);
|
||||||
|
var xScale = d3.scale.linear()
|
||||||
|
.domain([0, self.duration])
|
||||||
|
.range([0, $(self.timelineWrapper).width()])
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function sensor_data_collection() {
|
||||||
|
var controllerId = Session.get('controller_id');
|
||||||
|
return SensorData.find({
|
||||||
|
controllerId: controllerId
|
||||||
|
}, {
|
||||||
|
sort: {
|
||||||
|
created_at: -1
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Template.state_details.rendered = function() {
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
/*
|
||||||
|
* add point when new temperature is added
|
||||||
|
*/
|
||||||
|
setTimeout(function() {
|
||||||
|
self.autorun(function() {
|
||||||
|
sensor_data_collection().observe({
|
||||||
|
added: function(reading) {
|
||||||
|
buildTemperatureGraph();
|
||||||
|
buildHumidityGraph()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function to draw the graph
|
||||||
|
*/
|
||||||
|
function buildTemperatureGraph() {
|
||||||
|
|
||||||
|
var sensorReadings = sensor_data_collection();
|
||||||
|
|
||||||
|
console.log("Added: ", sensorReadings.count());
|
||||||
|
var times = sensorReadings.map(function(reading) {
|
||||||
|
return moment(reading.created_at).format("HH:mm:ss");
|
||||||
|
});
|
||||||
|
var values = sensorReadings.map(function(reading) {
|
||||||
|
return reading.temperatureValue;
|
||||||
|
});
|
||||||
|
|
||||||
|
return new Chartist.Line('#temperature_graph', {
|
||||||
|
labels: times,
|
||||||
|
series: [values]
|
||||||
|
}, {
|
||||||
|
fullWidth: true,
|
||||||
|
chartPadding: {
|
||||||
|
right: 40
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function to draw the graph
|
||||||
|
*/
|
||||||
|
function buildHumidityGraph() {
|
||||||
|
|
||||||
|
var sensorReadings = sensor_data_collection();
|
||||||
|
|
||||||
|
console.log("Added: ", sensorReadings.count());
|
||||||
|
var times = sensorReadings.map(function(reading) {
|
||||||
|
return moment(reading.created_at).format("HH:mm:ss");
|
||||||
|
});
|
||||||
|
var values = sensorReadings.map(function(reading) {
|
||||||
|
return reading.humidityValue;
|
||||||
|
});
|
||||||
|
|
||||||
|
return new Chartist.Line('#humidity_graph', {
|
||||||
|
labels: times,
|
||||||
|
series: [values]
|
||||||
|
}, {
|
||||||
|
fullWidth: true,
|
||||||
|
chartPadding: {
|
||||||
|
right: 40
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user