Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/report_plugins/hourlystats.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ hourlystats.report = function report_hourlystats(datastorage, sorteddaystoshow,

var totalPositive = [];
var totalNegative = [];
var positivesCount = [];
var negativesCount = [];
var totalNet = [];
var days = 0;
table = $('<table width="100%" border="1">');
Expand All @@ -157,6 +159,8 @@ hourlystats.report = function report_hourlystats(datastorage, sorteddaystoshow,
$('<th>' + hour + '</th>').appendTo(thead);
totalPositive[hour] = 0;
totalNegative[hour] = 0;
positivesCount[hour] = 0;
negativesCount[hour] = 0;
totalNet[hour] = 0;
});
thead.appendTo(table);
Expand All @@ -172,6 +176,8 @@ hourlystats.report = function report_hourlystats(datastorage, sorteddaystoshow,
var net = positive + negative;
totalPositive[h] += positive;
totalNegative[h] += negative;
if (Math.abs(positive) > Math.abs(negative)) positivesCount[h] += 1;
else negativesCount[h] += 1;
totalNet[h] += net;
var color = Math.abs(net) < 0.019 ? "black" : (net < 0 ? "red" : "lightgreen");
$('<td>' +
Expand All @@ -189,8 +195,8 @@ hourlystats.report = function report_hourlystats(datastorage, sorteddaystoshow,
for (var h = 0; h < 24; h++) {
var color = Math.abs(totalNet[h]) < 0.01 ? "white" : (totalNet[h] < 0 ? "red" : "lightgreen");
$('<td style="background-color:' + color + '";>' +
'<span style="color:black;">' + (totalNegative[h] / days).toFixed(2) + '</span>' + '<br>' +
'<span style="color:black;">' + (totalPositive[h] / days).toFixed(2) + '</span>' + '<br>' +
'<span style="color:black;">' + (totalNegative[h] / days).toFixed(2) + ' (' + negativesCount[h] + ')' + '</span>' + '<br>' +
'<span style="color:black;">' + (totalPositive[h] / days).toFixed(2) + ' (' + positivesCount[h] + ')' + '</span>' + '<br>' +
'<span style="color:black;font-weight:bold;">' + (totalNet[h] / days).toFixed(2) + '</span>' +
'</td>').appendTo(tr);
}
Expand Down