Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 8 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,11 @@ glucosedistribution.report = function report_glucosedistribution (datastorage, s
var data = datastorage.allstatsrecords;
var days = datastorage.alldays;

$('#glucosedistribution-days').text(days + ' ' + translate('days total'));
var reportPlugins = Nightscout.report_plugins;
var firstDay = reportPlugins.utils.localeDate(sorteddaystoshow[sorteddaystoshow.length - 1]);
var lastDay = reportPlugins.utils.localeDate(sorteddaystoshow[0]);

$('#glucosedistribution-days').text(days + ' ' + translate('days total') + ', ' + firstDay + ' - ' + lastDay);

for (var i = 0; i < 24; i++) {
$('#glucosedistribution-' + i).unbind('click').click(onClick);
Expand Down
31 changes: 22 additions & 9 deletions lib/report_plugins/percentile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@ 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>'
;
'<h2>'
+ translate('Glucose Percentile report')
+ ' ('
+ '<span id="percentile-days"></span>'
+ ')'
+ '</h2>'
+ '<div style="height:500px;">'
+ ' <div class="chart" id="percentile-chart"></div>'
+ '</div>'
;

return ret;
};

Expand All @@ -36,16 +42,23 @@ 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;
};


var reportPlugins = Nightscout.report_plugins;
var firstDay = reportPlugins.utils.localeDate(sorteddaystoshow[sorteddaystoshow.length - 1]);
var lastDay = reportPlugins.utils.localeDate(sorteddaystoshow[0]);
var countDays = sorteddaystoshow.length;

$('#percentile-days').text(countDays + ' ' + translate('days total') + ', ' + firstDay + ' - ' + lastDay);

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