D3 Upgrade Residual Cleanup (#5140)

* fix forecast limit logic

(cherry picked from commit e88ce7e5d1f5fb12c71ae67da4131ff1a50940c9)

* fix minimum focus forecast time

* make min forecast 30 min
This commit is contained in:
Jeremy Cunningham
2019-10-23 07:21:25 -05:00
committed by GitHub
parent 243ff2e28e
commit 4fd28434c1
2 changed files with 15 additions and 10 deletions
+9 -4
View File
@@ -82,12 +82,17 @@ function init (client, d3) {
var shownForecastPoints = _.filter(client.sbx.pluginBase.forecastPoints, function isShown (point) {
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 selectedRange = chart().createAdjustedRange();
var selectedRange = chart().createBrushedRange();
var to = selectedRange[1].getTime();
var focusHoursAheadMills = to + client.focusRangeMS;
var focusHoursAheadMills = to + times.mins(30).msecs;
var maxForecastMills = focusHoursAheadMills;
if (shownForecastPoints.length > 0) {
maxForecastMills = _.max(_.map(shownForecastPoints, function(point) { return point.mills }));
}
maxForecastMills = Math.min(focusHoursAheadMills, maxForecastMills);
client.forecastTime = maxForecastMills > 0 ? maxForecastMills - client.sbx.lastSGVMills() : 0;
focusData = focusData.concat(shownForecastPoints);
@@ -1028,7 +1033,7 @@ function init (client, d3) {
var comboareadata = [];
var selectedRange = chart().createAdjustedRange();
var from = selectedRange[0].getTime();
var to = Math.max(selectedRange[1].getTime(), client.sbx.time) + client.forecastTime;
var to = selectedRange[1].getTime();
var date = from;
var lastbasal = 0;