added colum to show energy consumption in kWh (unit stil missing)

This commit is contained in:
Steffen Vogel 2011-02-25 00:34:58 +01:00
parent 443081f9a0
commit 8eff32104e
2 changed files with 15 additions and 10 deletions

View file

@ -75,9 +75,10 @@
<th>Typ</th>
<th>Min.</th>
<th>Max.</th>
<th>Avg.</th>
<th>Last</th>
<th></th>
<th>&empty;</th>
<th>Verbrauch</th>
<th>akt.</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody></tbody>

View file

@ -305,12 +305,13 @@ vz.entities.show = function() {
.addClass((entity.type == 'group') ? 'group' : 'channel')
)
)
.append($('<td>').text(entity.type)) // channel type
.append($('<td>').addClass('min')) // min
.append($('<td>').addClass('max')) // max
.append($('<td>').addClass('average')) // avg
.append($('<td>').addClass('last')) // last
.append($('<td>') // operations
.append($('<td>').text(entity.type)) // channel type
.append($('<td>').addClass('min')) // min
.append($('<td>').addClass('max')) // max
.append($('<td>').addClass('average')) // avg
.append($('<td>').addClass('consumption')) // consumption
.append($('<td>').addClass('last')) // last
.append($('<td>') // operations
.addClass('ops')
.append($('<input>')
.attr('type', 'image')
@ -384,9 +385,12 @@ vz.entities.loadData = function() {
.text(entity.data.max.value)
.attr('title', $.plot.formatDate(new Date(entity.data.max.timestamp), '%d. %b %h:%M:%S', vz.options.plot.xaxis.monthNames));
}
// rounding: Math.round rounds to whole numbers; to round to one decimal (e.g. 15.2) we multiply by 10, round and reverse the multiplication again; therefore "vz.options.rounding" needs to be set to 1 (for 1 decimal) in that case
if (entity.data.average) {
$('#entity-' + entity.uuid + ' .average').text(Math.round(entity.data.average*Math.pow(10, vz.options.rounding))/Math.pow(10, vz.options.rounding));
// rounding: Math.round rounds to whole numbers; to round to one decimal (e.g. 15.2) we multiply by 10, round and reverse the multiplication again; therefore "vz.options.rounding" needs to be set to 1 (for 1 decimal) in that case
}
if (entity.data.consumption) {
$('#entity-' + entity.uuid + ' .consumption').text(Math.round(entity.data.consumption*Math.pow(10, vz.options.rounding))/Math.pow(10, vz.options.rounding));
}
if (entity.data.tuples) {
$('#entity-' + entity.uuid + ' .last').text(Math.round(entity.data.tuples.last()[1]*Math.pow(10, vz.options.rounding))/Math.pow(10, vz.options.rounding));