#1851 initial commit
This commit is contained in:
parent
c0cbaafe09
commit
4b5189403c
2 changed files with 33 additions and 0 deletions
|
@ -1523,6 +1523,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
// set manual x bounds to have nice steps
|
||||
graphData.formatAxis(fromTime, endTime);
|
||||
|
||||
// insulin activity
|
||||
graphData.addActivity(fromTime, endTime, graphData.maxY);
|
||||
|
||||
// Treatments
|
||||
graphData.addTreatments(fromTime, endTime);
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.List;
|
|||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.db.BgReading;
|
||||
import info.nightscout.androidaps.db.CareportalEvent;
|
||||
|
@ -344,6 +345,35 @@ public class GraphData {
|
|||
? Profile.fromMgdlToUnits(bgReadingsArray.get(0).value, units) : Profile.fromMgdlToUnits(100, units);
|
||||
}
|
||||
|
||||
public void addActivity(long fromTime, long toTime, double scale) {
|
||||
FixedLineGraphSeries<ScaledDataPoint> actSeries;
|
||||
List<ScaledDataPoint> actArray = new ArrayList<>();
|
||||
double lastAct = 0;
|
||||
Scale actScale = new Scale();
|
||||
IobTotal total = null;
|
||||
|
||||
for (long time = fromTime; time <= toTime; time += 5 * 60 * 1000L) {
|
||||
Profile profile = ProfileFunctions.getInstance().getProfile(time);
|
||||
double act = 0d;
|
||||
if (profile != null)
|
||||
total = iobCobCalculatorPlugin.calculateFromTreatmentsAndTempsSynchronized(time, profile);
|
||||
act = total.activity;
|
||||
|
||||
actArray.add(new ScaledDataPoint(time, act, actScale));
|
||||
lastAct = act;
|
||||
}
|
||||
|
||||
ScaledDataPoint[] actData = new ScaledDataPoint[actArray.size()];
|
||||
actData = actArray.toArray(actData);
|
||||
actSeries = new FixedLineGraphSeries<>(actData);
|
||||
actSeries.setDrawBackground(false);
|
||||
actSeries.setColor(MainApp.gc(R.color.mdtp_white));
|
||||
actSeries.setThickness(3);
|
||||
actScale.setMultiplier(scale / 0.04d); //TODO for clarity should be fixed scale, but what max? For now 0.04d seems reasonable.
|
||||
|
||||
addSeries(actSeries);
|
||||
}
|
||||
|
||||
// scale in % of vertical size (like 0.3)
|
||||
public void addIob(long fromTime, long toTime, boolean useForScale, double scale) {
|
||||
FixedLineGraphSeries<ScaledDataPoint> iobSeries;
|
||||
|
|
Loading…
Reference in a new issue