diff --git a/lib/client/chart.js b/lib/client/chart.js index a40aa8ff542..d37f9047e97 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; @@ -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'); 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];