Skip to content

Commit

Permalink
only show focusHours' worth of predictions; strip leading zero from b…
Browse files Browse the repository at this point in the history
…olus amounts
  • Loading branch information
scottleibrand committed Oct 17, 2017
1 parent 6c86a6d commit e433cc8
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/client/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var _ = require('lodash');
var times = require('../times');

var DEFAULT_FOCUS = times.hours(3).msecs
var DEFAULT_FOCUS = times.hours(4).msecs
, WIDTH_SMALL_DOTS = 420
, WIDTH_BIG_DOTS = 800
, TOOLTIP_TRANS_MS = 100 // milliseconds
Expand All @@ -23,7 +23,7 @@ function init (client, d3) {
}

function focusRangeAdjustment ( ) {
return client.foucusRangeMS === DEFAULT_FOCUS ? 1 : 1 + ((client.foucusRangeMS - DEFAULT_FOCUS) / DEFAULT_FOCUS / 8);
return client.focusRangeMS === DEFAULT_FOCUS ? 1 : 1 + ((client.focusRangeMS - DEFAULT_FOCUS) / DEFAULT_FOCUS / 8);
}

var dotRadius = function(type) {
Expand Down Expand Up @@ -74,6 +74,9 @@ function init (client, d3) {
return client.settings.showForecast.indexOf(point.info.type) > -1;
});
var maxForecastMills = _.max(_.map(shownForecastPoints, function (point) {return point.mills}));
// limit lookahead to the same as lookback
var focusHoursAheadMills = chart().brush.extent()[1].getTime() + client.focusRangeMS;
maxForecastMills = Math.min(focusHoursAheadMills, maxForecastMills);
client.forecastTime = maxForecastMills > 0 ? maxForecastMills - client.sbx.lastSGVMills() : 0;
focusData = focusData.concat(shownForecastPoints);
}
Expand Down Expand Up @@ -431,8 +434,10 @@ function init (client, d3) {
arc_data[1].element = arc_data[1].element + " " + treatment.foodType;
}

if (treatment.insulin > 0) {
arc_data[3].element = Math.round(treatment.insulin * 100) / 100 + ' U';
if ( treatment.insulin > 0) {
// remove leading zeros to avoid overlap with adjacent boluses
var units = Math.round(treatment.insulin * 100)/100;
arc_data[3].element = (units+"").replace(/^0/,"");
}

if (treatment.status) {
Expand Down

0 comments on commit e433cc8

Please sign in to comment.