diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java index 595102cf04..bdda2f47dd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.java @@ -1560,7 +1560,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, graphData.formatAxis(fromTime, endTime); if(SP.getBoolean("showactivityprimary", true)) { - graphData.addActivity(fromTime, endTime, 1d); + graphData.addActivity(fromTime, endTime, false,1d); } // Treatments @@ -1588,6 +1588,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, boolean useDevForScale = false; boolean useRatioForScale = false; boolean useDSForScale = false; + boolean useIAForScale = false; if (SP.getBoolean("showiob", true)) { useIobForScale = true; @@ -1597,6 +1598,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, useDevForScale = true; } else if (SP.getBoolean("showratios", false)) { useRatioForScale = true; + } else if (SP.getBoolean("showactivitysecondary", false)) { + useIAForScale = true; } else if (SP.getBoolean("showdevslope", false)) { useDSForScale = true; } @@ -1610,7 +1613,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, if (SP.getBoolean("showratios", false)) secondGraphData.addRatio(fromTime, now, useRatioForScale, 1d); if(SP.getBoolean("showactivitysecondary", true)) - secondGraphData.addActivity(fromTime, endTime, 1d); + secondGraphData.addActivity(fromTime, endTime, useIAForScale,1d); if (SP.getBoolean("showdevslope", false) && MainApp.devBranch) secondGraphData.addDeviationSlope(fromTime, now, useDSForScale, 1d); @@ -1627,6 +1630,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, || SP.getBoolean("showcob", true) || SP.getBoolean("showdeviations", false) || SP.getBoolean("showratios", false) + || SP.getBoolean("showactivitysecondary", false) || SP.getBoolean("showdevslope", false)) { iobGraph.setVisibility(View.VISIBLE); } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.java index fb073b77bd..29e190055a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.java @@ -346,7 +346,7 @@ public class GraphData { ? Profile.fromMgdlToUnits(bgReadingsArray.get(0).value, units) : Profile.fromMgdlToUnits(100, units); } - public void addActivity(long fromTime, long toTime, double scale) { + public void addActivity(long fromTime, long toTime, boolean useForScale, double scale) { FixedLineGraphSeries actSeriesHist; List actArrayHist = new ArrayList<>(); FixedLineGraphSeries actSeriesPred; @@ -369,9 +369,6 @@ public class GraphData { actArrayPred.add(new ScaledDataPoint(time, act, actScale)); } - double maxIAValue = SP.getDouble(R.string.key_scale_insulin_activity, 0.05); - actScale.setMultiplier(maxY*scale / maxIAValue); - ScaledDataPoint[] actData = new ScaledDataPoint[actArrayHist.size()]; actData = actArrayHist.toArray(actData); actSeriesHist = new FixedLineGraphSeries<>(actData); @@ -392,6 +389,13 @@ public class GraphData { paint.setColor(MainApp.gc(R.color.activity)); actSeriesPred.setCustomPaint(paint); + double maxIAValue = SP.getDouble(R.string.key_scale_insulin_activity, 0.05); + if (useForScale) { + maxY = maxIAValue; + minY = -maxIAValue; + } + actScale.setMultiplier(maxY * scale / maxIAValue); + addSeries(actSeriesPred); }