private async Task <PlotModel> GetInsulinModel(NightView nv) { var model = new PlotModel(); model.Axes.Add(new DateTimeAxis { Position = AxisPosition.Bottom, Minimum = DateTimeAxis.ToDouble(Start.LocalDateTime), Maximum = DateTimeAxis.ToDouble(End.LocalDateTime) }); model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = 0, Maximum = 10 }); var basalSeries = new AreaSeries { Title = "Basal rate", InterpolationAlgorithm = new PreviousValueInterpolationAlgorithm() }; await foreach (var tv in nv.BasalRates(Start, End)) { basalSeries.Points.Add(new DataPoint(DateTimeAxis.ToDouble(tv.Time.LocalDateTime), (double)tv.Value)); } model.Series.Add(basalSeries); return(model); }
private async Task <PlotModel> GetBgcModel(NightView nv) { var model = new PlotModel(); model.Axes.Add(new DateTimeAxis { Position = AxisPosition.Bottom, Minimum = DateTimeAxis.ToDouble(Start.LocalDateTime), Maximum = DateTimeAxis.ToDouble(End.LocalDateTime) }); model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = 20, Maximum = 400 }); var bgSeries = new LineSeries { Title = "Blood Glucose Concentration" }; await foreach (var tv in nv.GlucoseValues(Start, End)) { bgSeries.Points.Add(new DataPoint(DateTimeAxis.ToDouble(tv.Time.LocalDateTime), (double)tv.Value)); } model.Series.Add(bgSeries); return(model); }
private async Task <PlotModel> GetModel() { var nv = new NightView(App.Configuration); var dtStart = DateTimeOffset.Now.AddHours(-6); var dtEnd = DateTimeOffset.Now; var model = new PlotModel { Title = "Something" }; model.Axes.Add(new DateTimeAxis { Position = AxisPosition.Bottom, Minimum = DateTimeAxis.ToDouble(dtStart.LocalDateTime), Maximum = DateTimeAxis.ToDouble(dtEnd.LocalDateTime) }); model.Axes.Add(new LinearAxis { Position = AxisPosition.Left }); var lineSeries = new LineSeries(); await foreach (var gv in nv.GlucoseValues(dtStart, dtEnd)) { lineSeries.Points.Add(new DataPoint(DateTimeAxis.ToDouble(gv.Time.LocalDateTime), (double)gv.Value)); } lineSeries.Title = "Nice"; model.Series.Add(lineSeries); return(model); }
public async Task Update() { var nv = new NightView(App.Configuration); BgcModel = await GetBgcModel(nv); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(BgcModel))); InsulinModel = await GetInsulinModel(nv); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(InsulinModel))); }