Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
19 changes: 15 additions & 4 deletions lib/report_plugins/glucosedistribution.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ glucosedistribution.html = function html (client) {
var ret =
'<h2>' +
translate('Glucose distribution') +
' (' +
' <span id="glucosedistribution-days"></span>' +
' )' +
' (' +
'<span id="glucosedistribution-days"></span>' +
')' +
' </h2>' +
'<table><tr>' +
'<td rowspan="2" style="valign:middle;"><div id="glucosedistribution-overviewchart"></div></td>' +
Expand Down Expand Up @@ -122,7 +122,18 @@ glucosedistribution.report = function report_glucosedistribution (datastorage, s
var data = datastorage.allstatsrecords;
var days = datastorage.alldays;

$('#glucosedistribution-days').text(days + ' ' + translate('days total'));
// Peter Leimbach (begin)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove these lines that add your name and other comments unrelated to the logic, would prefer to not merge them. LGTM otherwise

// I would like to print the period for the data into the report headline
// 1) I define the variables to get the data out of the existing function paramter sorteddaystoshow
var report_plugins = Nightscout.report_plugins;
var firstday = report_plugins.utils.localeDate(sorteddaystoshow[sorteddaystoshow.length - 1]);
var lastday = report_plugins.utils.localeDate(sorteddaystoshow[0]);

// 2) now I use firstay and lastday to print the values in the headline
$('#glucosedistribution-days').text(days + ' ' + translate('days total') + ', ' + firstday + ' - ' + lastday);
//$('#glucosedistribution-days').text(days + ' ' + translate('days total'));
// Peter Leimbach (end)


for (var i = 0; i < 24; i++) {
$('#glucosedistribution-' + i).unbind('click').click(onClick);
Expand Down
36 changes: 27 additions & 9 deletions lib/report_plugins/percentile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@ module.exports = init;
percentile.html = function html(client) {
var translate = client.translate;
var ret =
'<h2>' + translate('Glucose Percentile report') + '</h2>'
+ '<div style="height:500px;">'
+ ' <div class="chart" id="percentile-chart"></div>'
+ '</div>'
;
// Peter Leimbach (begin)
// '<h2>' + translate('Glucose Percentile report') + '</h2>'
'<h2>'
+ translate('Glucose Percentile report')
+ ' ('
+ '<span id="percentile-days"></span>'
+ ')'
+ '</h2>'
+ '<div style="height:500px;">'
+ ' <div class="chart" id="percentile-chart"></div>'
+ '</div>'
;
// Peter Leimbach (end)

return ret;
};

Expand All @@ -36,16 +45,25 @@ percentile.report = function report_percentile(datastorage, sorteddaystoshow, op
var translate = client.translate;
var ss = require('simple-statistics');

var minutewindow = 30; //minute-window should be a divisor of 60
var minutewindow = 30; //minute-window should be a divisor of 60

var data = datastorage.allstatsrecords;

var bins = [];
var filterFunc = function withinWindow(record) {
var recdate = new Date(record.displayTime);
return recdate.getHours() === hour && recdate.getMinutes() >= minute && recdate.getMinutes() < minute + minutewindow;
};


// Peter Leimbach (begin)
var report_plugins = Nightscout.report_plugins;
var firstday = report_plugins.utils.localeDate(sorteddaystoshow[sorteddaystoshow.length - 1]);
var lastday = report_plugins.utils.localeDate(sorteddaystoshow[0]);
var countdays = sorteddaystoshow.length;

$('#percentile-days').text(countdays + ' ' + translate('days total') + ', ' + firstday + ' - ' + lastday);
// Peter Leimbach (end)

for (var hour = 0; hour < 24; hour++) {
for (var minute = 0; minute < 60; minute = minute + minutewindow) {
var date = new Date();
Expand Down