diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java index ce66a988c3..32ed9f8ed5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java @@ -8,7 +8,7 @@ import java.util.Date; public class AutosensData { long time = 0L; - String pastSensitivity = ""; + public String pastSensitivity = ""; public double deviation = 0d; boolean calculateWithDeviation = false; double absorbed = 0d; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index 0fa1da6a9f..da6580a05a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -1123,10 +1123,17 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, basalsLineSeries.setCustomPaint(paint); } - // **** IOB COB graph **** + // **** IOB COB DEV graph **** + class DeviationDataPoint extends DataPoint { + public int color; + public DeviationDataPoint(double x, double y, int color) { + super(x, y); + this.color = color; + } + } FixedLineGraphSeries iobSeries; FixedLineGraphSeries cobSeries; - BarGraphSeries devSeries; + BarGraphSeries devSeries; Double maxIobValueFound = 0d; Double maxCobValueFound = 0d; Double maxDevValueFound = 0d; @@ -1135,7 +1142,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, //Date start = new Date(); List iobArray = new ArrayList<>(); List cobArray = new ArrayList<>(); - List devArray = new ArrayList<>(); + List devArray = new ArrayList<>(); for (long time = fromTime; time <= now; time += 5 * 60 * 1000L) { if (showIobView.isChecked()) { IobTotal iob = IobCobCalculatorPlugin.calulateFromTreatmentsAndTemps(time); @@ -1149,7 +1156,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, maxCobValueFound = Math.max(maxCobValueFound, autosensData.cob); } if (autosensData != null && showDeviationsView.isChecked()) { - devArray.add(new DataPoint(time, autosensData.deviation)); + int color = Color.BLACK; // "=" + if (autosensData.pastSensitivity.equals("C")) color = Color.BLUE; + if (autosensData.pastSensitivity.equals("+")) color = Color.GREEN; + if (autosensData.pastSensitivity.equals("-")) color = Color.RED; + devArray.add(new DeviationDataPoint(time, autosensData.deviation, color)); maxDevValueFound = Math.max(maxDevValueFound, Math.abs(autosensData.deviation)); } } @@ -1166,12 +1177,12 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, if (showIobView.isChecked() && (showCobView.isChecked() || showDeviationsView.isChecked())) { List cobArrayRescaled = new ArrayList<>(); - List devArrayRescaled = new ArrayList<>(); + List devArrayRescaled = new ArrayList<>(); for (int ci = 0; ci < cobArray.size(); ci++) { cobArrayRescaled.add(new DataPoint(cobArray.get(ci).getX(), cobArray.get(ci).getY() * maxIobValueFound / maxCobValueFound / 2)); } for (int ci = 0; ci < devArray.size(); ci++) { - devArrayRescaled.add(new DataPoint(devArray.get(ci).getX(), devArray.get(ci).getY() * maxIobValueFound / maxDevValueFound)); + devArrayRescaled.add(new DeviationDataPoint(devArray.get(ci).getX(), devArray.get(ci).getY() * maxIobValueFound / maxDevValueFound, devArray.get(ci).color)); } cobArray = cobArrayRescaled; devArray = devArrayRescaled; @@ -1186,14 +1197,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, cobSeries.setThickness(3); // DEVIATIONS - DataPoint[] devData = new DataPoint[devArray.size()]; + DeviationDataPoint[] devData = new DeviationDataPoint[devArray.size()]; devData = devArray.toArray(devData); devSeries = new BarGraphSeries<>(devData); - devSeries.setValueDependentColor(new ValueDependentColor() { + devSeries.setValueDependentColor(new ValueDependentColor() { @Override - public int get(DataPoint data) { - if (data.getY() < 0) return Color.RED; - else return Color.GREEN; + public int get(DeviationDataPoint data) { + return data.color; } }); //devSeries.setBackgroundColor(0xB0FFFFFF & MainApp.sResources.getColor(R.color.cob)); //50%