relocated rounding from backend to frontend
This commit is contained in:
parent
e231f75ac1
commit
929a4f7c39
3 changed files with 5 additions and 3 deletions
|
@ -368,10 +368,11 @@ vz.entities.loadData = function() {
|
|||
.attr('title', $.plot.formatDate(new Date(entity.data.max.timestamp), '%d. %b %h:%M:%S', vz.options.plot.xaxis.monthNames));
|
||||
}
|
||||
if (entity.data.average) {
|
||||
$('#entity-' + entity.uuid + ' .average').text(entity.data.average);
|
||||
$('#entity-' + entity.uuid + ' .average').text(Math.round(entity.data.average/vz.options.rounding)*vz.options.rounding);
|
||||
// rounding: Math.round rounds to whole numbers; to round to one decimal (e.g. 15.2) we multiply by 10 (resp. divide through 0.1), round and reverse the multiplication again; therefore "vz.options.rounding" needs to be set to 0.1 in that case
|
||||
}
|
||||
if (entity.data.last) {
|
||||
$('#entity-' + entity.uuid + ' .last').text(entity.data.last)
|
||||
$('#entity-' + entity.uuid + ' .last').text(Math.round(entity.data.last/vz.options.rounding)*vz.options.rounding);
|
||||
}
|
||||
}, vz.drawPlot, 'data')
|
||||
);
|
||||
|
|
|
@ -29,6 +29,7 @@ vz.options = {
|
|||
language: 'de',
|
||||
backendUrl: '../backend.php',
|
||||
tuples: 300,
|
||||
rounding: 0.1,
|
||||
render: 'lines',
|
||||
refresh: false,
|
||||
refreshInterval: 5*1000, // 5 secs
|
||||
|
|
|
@ -87,7 +87,7 @@ class SensorInterpreter extends Interpreter {
|
|||
* @return float
|
||||
*/
|
||||
public function getLast() {
|
||||
return round((float) $this->conn->fetchColumn('SELECT value FROM data WHERE channel_id = ?' . parent::buildDateTimeFilterSQL($this->from, $this->to). ' ORDER BY timestamp DESC', array($this->channel->getId()), 0), 1);
|
||||
return (float) $this->conn->fetchColumn('SELECT value FROM data WHERE channel_id = ?' . parent::buildDateTimeFilterSQL($this->from, $this->to). ' ORDER BY timestamp DESC', array($this->channel->getId()), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue