Skip to content

Commit

Permalink
Merge pull request #3464 from trallen/trallen-fixed-time-period
Browse files Browse the repository at this point in the history
Make X axis scaling consistent
  • Loading branch information
jamorham authored May 22, 2024
2 parents 50b8dab + b2bc51b commit 8cc5c66
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions app/src/main/java/com/eveningoutpost/dexdrip/Home.java
Original file line number Diff line number Diff line change
Expand Up @@ -2296,8 +2296,12 @@ private void setHoursViewPort(final String source) {
break;
}

float ideal_hours_to_show = DEFAULT_CHART_HOURS + bgGraphBuilder.getPredictivehours();
// always show at least the ideal number of hours if locked or auto
// always show at least the ideal number of hours
float ideal_hours_to_show = DEFAULT_CHART_HOURS;
// ... and rescale to accommodate predictions if not locked
if (! homeShelf.get("time_locked_always")) {
ideal_hours_to_show += bgGraphBuilder.getPredictivehours();
}
float hours_to_show = exactHoursSpecified ? hours : Math.max(hours, ideal_hours_to_show);

UserError.Log.d(TAG, "VIEWPORT " + source + " moveviewport in setHours: asked " + hours + " vs auto " + ideal_hours_to_show + " = " + hours_to_show + " full chart width: " + bgGraphBuilder.hoursShownOnChart());
Expand All @@ -2308,6 +2312,12 @@ private void setHoursViewPort(final String source) {
holdViewport.top = maxViewPort.top;
holdViewport.bottom = maxViewPort.bottom;

// if locked, center display on current bg values, not predictions
if (homeShelf.get("time_locked_always")) {
holdViewport.left -= hour_width * bgGraphBuilder.getPredictivehours();
holdViewport.right -= hour_width * bgGraphBuilder.getPredictivehours();
}

if (d) {
UserError.Log.d(TAG, "HOLD VIEWPORT " + holdViewport);
UserError.Log.d(TAG, "MAX VIEWPORT " + maxViewPort);
Expand Down

0 comments on commit 8cc5c66

Please sign in to comment.