From 8041b15631163a49eacc9eaedfa3ef8e326253f3 Mon Sep 17 00:00:00 2001 From: Jeremy Cunningham Date: Sun, 10 Nov 2019 15:56:55 -0600 Subject: [PATCH 1/3] don't use dynamic scale unless have entries --- lib/client/chart.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/chart.js b/lib/client/chart.js index a40aa8ff542..30ad00641fe 100644 --- a/lib/client/chart.js +++ b/lib/client/chart.js @@ -118,7 +118,7 @@ function init (client, d3, $) { } function dynamicDomainOrElse (defaultDomain) { - if (client.settings.scaleY === 'linear' || client.settings.scaleY === 'log-dynamic') { + if (client.entries && (client.entries.length > 0) && (client.settings.scaleY === 'linear' || client.settings.scaleY === 'log-dynamic')) { return dynamicDomain(); } else { return defaultDomain; From 6d8055a6ac9257d7c43c2222df0353d9a7b01cc3 Mon Sep 17 00:00:00 2001 From: Jeremy Cunningham Date: Sun, 10 Nov 2019 21:07:14 -0600 Subject: [PATCH 2/3] fix report crash when no entries --- lib/report_plugins/glucosedistribution.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/report_plugins/glucosedistribution.js b/lib/report_plugins/glucosedistribution.js index 4a5e7dd31fb..c2709cd28e5 100644 --- a/lib/report_plugins/glucosedistribution.js +++ b/lib/report_plugins/glucosedistribution.js @@ -146,6 +146,11 @@ glucosedistribution.report = function report_glucosedistribution (datastorage, s var glucose_data = [data[0]]; + if (data.length === 0) { + $('#glucosedistribution-days').text(translate('Result is empty')); + return; + } + // data cleaning pass 1 - add interpolated missing points for (i = 0; i <= data.length - 2; i++) { var entry = data[i]; From c3e9d3f169a3fe375e4440ba8adfdce5ddef442a Mon Sep 17 00:00:00 2001 From: Jeremy Cunningham Date: Sun, 10 Nov 2019 21:31:30 -0600 Subject: [PATCH 3/3] set forecastTime correctly when no entries present --- lib/client/chart.js | 5 ++++- lib/client/index.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/client/chart.js b/lib/client/chart.js index 30ad00641fe..d37f9047e97 100644 --- a/lib/client/chart.js +++ b/lib/client/chart.js @@ -714,7 +714,10 @@ function init (client, d3, $) { } maxForecastMills = Math.min(focusHoursAheadMills, maxForecastMills); - client.forecastTime = maxForecastMills > 0 ? maxForecastMills - client.sbx.lastSGVMills() : 0; + + var lastSGVMills = client.sbx.lastSGVMills(); + + client.forecastTime = ((maxForecastMills > 0) && lastSGVMills) ? maxForecastMills - lastSGVMills : client.defaultForecastTime; } }; diff --git a/lib/client/index.js b/lib/client/index.js index 8c5d22f5c82..84f0dff70fb 100644 --- a/lib/client/index.js +++ b/lib/client/index.js @@ -131,7 +131,7 @@ client.load = function load (serverSettings, callback) { client.now = Date.now(); client.ddata = require('../data/ddata')(); - client.forecastTime = times.mins(30).msecs; + client.forecastTime = client.defaultForecastTime = times.mins(30).msecs; client.entries = []; client.ticks = require('./ticks');