From 8eff32104e5d24efcdb233994ac87010914a3514 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Fri, 25 Feb 2011 00:34:58 +0100 Subject: [PATCH] added colum to show energy consumption in kWh (unit stil missing) --- htdocs/frontend/index.html | 7 ++++--- htdocs/frontend/javascripts/frontend.js | 18 +++++++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/htdocs/frontend/index.html b/htdocs/frontend/index.html index 52b514b..e60f67a 100644 --- a/htdocs/frontend/index.html +++ b/htdocs/frontend/index.html @@ -75,9 +75,10 @@ Typ Min. Max. - Avg. - Last - + ∅ + Verbrauch + akt. +   diff --git a/htdocs/frontend/javascripts/frontend.js b/htdocs/frontend/javascripts/frontend.js index 6d30781..07ddd45 100644 --- a/htdocs/frontend/javascripts/frontend.js +++ b/htdocs/frontend/javascripts/frontend.js @@ -305,12 +305,13 @@ vz.entities.show = function() { .addClass((entity.type == 'group') ? 'group' : 'channel') ) ) - .append($('').text(entity.type)) // channel type - .append($('').addClass('min')) // min - .append($('').addClass('max')) // max - .append($('').addClass('average')) // avg - .append($('').addClass('last')) // last - .append($('') // operations + .append($('').text(entity.type)) // channel type + .append($('').addClass('min')) // min + .append($('').addClass('max')) // max + .append($('').addClass('average')) // avg + .append($('').addClass('consumption')) // consumption + .append($('').addClass('last')) // last + .append($('') // operations .addClass('ops') .append($('') .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));