Merge pull request #952 from jotomo/rainbow
Fix missing predictions in graph, color them.
This commit is contained in:
commit
dbca668afd
11 changed files with 14 additions and 35 deletions
|
@ -211,7 +211,7 @@ public class BgReading implements DataPointWithLabelInterface {
|
||||||
}
|
}
|
||||||
int color = MainApp.sResources.getColor(R.color.inrange);
|
int color = MainApp.sResources.getColor(R.color.inrange);
|
||||||
if (isPrediction())
|
if (isPrediction())
|
||||||
color = MainApp.sResources.getColor(R.color.prediction);
|
return getPredectionColor();
|
||||||
else if (valueToUnits(units) < lowLine)
|
else if (valueToUnits(units) < lowLine)
|
||||||
color = MainApp.sResources.getColor(R.color.low);
|
color = MainApp.sResources.getColor(R.color.low);
|
||||||
else if (valueToUnits(units) > highLine)
|
else if (valueToUnits(units) > highLine)
|
||||||
|
@ -219,8 +219,7 @@ public class BgReading implements DataPointWithLabelInterface {
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private int getPredectionColor() {
|
||||||
public int getSecondColor() {
|
|
||||||
if (isIOBPrediction)
|
if (isIOBPrediction)
|
||||||
return MainApp.sResources.getColor(R.color.iob);
|
return MainApp.sResources.getColor(R.color.iob);
|
||||||
if (isCOBPrediction)
|
if (isCOBPrediction)
|
||||||
|
|
|
@ -263,9 +263,4 @@ public class CareportalEvent implements DataPointWithLabelInterface {
|
||||||
return Color.GRAY;
|
return Color.GRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSecondColor() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -297,8 +297,4 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
|
||||||
return Color.CYAN;
|
return Color.CYAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSecondColor() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,11 +263,6 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
|
||||||
return Color.CYAN;
|
return Color.CYAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSecondColor() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ProfileSwitch{" +
|
return "ProfileSwitch{" +
|
||||||
"date=" + date +
|
"date=" + date +
|
||||||
|
|
|
@ -164,9 +164,4 @@ public class AutosensData implements DataPointWithLabelInterface {
|
||||||
return MainApp.gc(R.color.cob);
|
return MainApp.gc(R.color.cob);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSecondColor() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1359,7 +1359,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
|
|
||||||
// **** BG ****
|
// **** BG ****
|
||||||
if (predictionsAvailable && SP.getBoolean("showprediction", false))
|
if (predictionsAvailable && SP.getBoolean("showprediction", false))
|
||||||
graphData.addBgReadings(fromTime, toTime, lowLine, highLine, finalLastRun.constraintsProcessed);
|
graphData.addBgReadings(fromTime, toTime, lowLine, highLine,
|
||||||
|
finalLastRun.constraintsProcessed.getPredictions());
|
||||||
else
|
else
|
||||||
graphData.addBgReadings(fromTime, toTime, lowLine, highLine, null);
|
graphData.addBgReadings(fromTime, toTime, lowLine, highLine, null);
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import com.jjoe64.graphview.series.LineGraphSeries;
|
||||||
import com.jjoe64.graphview.series.Series;
|
import com.jjoe64.graphview.series.Series;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
|
@ -61,7 +62,7 @@ public class GraphData {
|
||||||
this.iobCobCalculatorPlugin = iobCobCalculatorPlugin;
|
this.iobCobCalculatorPlugin = iobCobCalculatorPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addBgReadings(long fromTime, long toTime, double lowLine, double highLine, APSResult apsResult) {
|
public void addBgReadings(long fromTime, long toTime, double lowLine, double highLine, List<BgReading> predictions) {
|
||||||
double maxBgValue = 0d;
|
double maxBgValue = 0d;
|
||||||
bgReadingsArray = MainApp.getDbHelper().getBgreadingsDataFromTime(fromTime, true);
|
bgReadingsArray = MainApp.getDbHelper().getBgreadingsDataFromTime(fromTime, true);
|
||||||
List<DataPointWithLabelInterface> bgListArray = new ArrayList<>();
|
List<DataPointWithLabelInterface> bgListArray = new ArrayList<>();
|
||||||
|
@ -74,9 +75,12 @@ public class GraphData {
|
||||||
if (bg.value > maxBgValue) maxBgValue = bg.value;
|
if (bg.value > maxBgValue) maxBgValue = bg.value;
|
||||||
bgListArray.add(bg);
|
bgListArray.add(bg);
|
||||||
}
|
}
|
||||||
if (apsResult != null) {
|
if (predictions != null) {
|
||||||
List<BgReading> predArray = apsResult.getPredictions();
|
Collections.sort(predictions, (o1, o2) -> Double.compare(o1.getX(), o2.getX()));
|
||||||
bgListArray.addAll(predArray);
|
for (BgReading prediction : predictions) {
|
||||||
|
if (prediction.value >= 40)
|
||||||
|
bgListArray.add(prediction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
maxBgValue = Profile.fromMgdlToUnits(maxBgValue, units);
|
maxBgValue = Profile.fromMgdlToUnits(maxBgValue, units);
|
||||||
|
@ -273,6 +277,7 @@ public class GraphData {
|
||||||
for (int tx = 0; tx < treatments.size(); tx++) {
|
for (int tx = 0; tx < treatments.size(); tx++) {
|
||||||
Treatment t = treatments.get(tx);
|
Treatment t = treatments.get(tx);
|
||||||
if (t.getX() < fromTime || t.getX() > endTime) continue;
|
if (t.getX() < fromTime || t.getX() > endTime) continue;
|
||||||
|
if (t.isSMB && !t.isValid) continue;
|
||||||
t.setY(getNearestBg((long) t.getX()));
|
t.setY(getNearestBg((long) t.getX()));
|
||||||
filteredTreatments.add(t);
|
filteredTreatments.add(t);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,5 +55,4 @@ public interface DataPointWithLabelInterface extends DataPointInterface{
|
||||||
PointsWithLabelGraphSeries.Shape getShape();
|
PointsWithLabelGraphSeries.Shape getShape();
|
||||||
float getSize();
|
float getSize();
|
||||||
int getColor();
|
int getColor();
|
||||||
int getSecondColor();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,7 +211,6 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
mPaint.setStyle(Paint.Style.FILL);
|
mPaint.setStyle(Paint.Style.FILL);
|
||||||
mPaint.setStrokeWidth(0);
|
mPaint.setStrokeWidth(0);
|
||||||
canvas.drawCircle(endX, endY, scaledPxSize, mPaint);
|
canvas.drawCircle(endX, endY, scaledPxSize, mPaint);
|
||||||
mPaint.setColor(value.getSecondColor());
|
|
||||||
mPaint.setStyle(Paint.Style.FILL);
|
mPaint.setStyle(Paint.Style.FILL);
|
||||||
mPaint.setStrokeWidth(0);
|
mPaint.setStrokeWidth(0);
|
||||||
canvas.drawCircle(endX, endY, scaledPxSize / 3, mPaint);
|
canvas.drawCircle(endX, endY, scaledPxSize / 3, mPaint);
|
||||||
|
|
|
@ -193,11 +193,6 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
return MainApp.instance().getResources().getColor(android.R.color.holo_red_light);
|
return MainApp.instance().getResources().getColor(android.R.color.holo_red_light);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSecondColor() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setY(double y) {
|
public void setY(double y) {
|
||||||
yValue = y;
|
yValue = y;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<color name="bolus">#FFFFCC03</color>
|
<color name="bolus">#FFFFCC03</color>
|
||||||
<color name="cob">#FFFB8C00</color>
|
<color name="cob">#FFFB8C00</color>
|
||||||
<color name="uam">#ffea00</color>
|
<color name="uam">#ffea00</color>
|
||||||
<color name="zt">#ff9500</color>
|
<color name="zt">#00ffff</color>
|
||||||
<color name="ratio">#FFFFFF</color>
|
<color name="ratio">#FFFFFF</color>
|
||||||
<color name="devslopepos">#FFFFFF00</color>
|
<color name="devslopepos">#FFFFFF00</color>
|
||||||
<color name="devslopeneg">#FFFF00FF</color>
|
<color name="devslopeneg">#FFFF00FF</color>
|
||||||
|
|
Loading…
Reference in a new issue