void DrawQuantizedPlot(List <DataPoint> previousPoints, out List <double> measuredValues) { DrawChart(previousPoints, false); var quantizedPoints = SignalConverter.QuantizeSignal(previousPoints, QuantizationLevel, out var measures); //var interpolatedPoints = SignalConverter.Interpolate(previousPoints.Count, // previousPoints.Select(p => new ScatterPoint(p.X, p.Y)).ToList(), SamplingFrequency, SamplingFrequencyAc, InitialTime, out var measures); measuredValues = measures; var stepSizeSeries = new StairStepSeries { MarkerStrokeThickness = .1, MarkerSize = 1, MarkerStroke = OxyColors.Blue, MarkerFill = OxyColors.Transparent, MarkerType = MarkerType.Diamond, Color = OxyColors.Blue, BrokenLineColor = OxyColors.Blue, BrokenLineThickness = .1, StrokeThickness = .1, }; foreach (var point in quantizedPoints) { stepSizeSeries.Points.Add(point); } upperPlot.Model.Series.Add(stepSizeSeries); }
public void AddStepPlot(string title, List <Point> points) { var plot = new PlotModel() { Title = title }; StairStepSeries series = new StairStepSeries(); points.ForEach(p => series.Points.Add(new DataPoint(p.X, p.Y))); plot.Series.Add(series); plotList.Add(plot); }
// Инициализация public SystemGraph() { stepAxesX = 0; plotModel = new PlotModel { }; // Ось X plotModel.Axes.Add(linearAxisX = new LinearAxis() { MajorGridlineStyle = LineStyle.Solid, MaximumPadding = 0, MinimumPadding = 0, AbsoluteMinimum = 0, MinimumRange = 1000, MaximumRange = 1000, MinorGridlineStyle = LineStyle.Dot, Position = AxisPosition.Bottom }); // Ось Y plotModel.Axes.Add(linearAxisY = new LinearAxis() { MajorGridlineStyle = LineStyle.Solid, MaximumPadding = 0, AbsoluteMinimum = 0, AbsoluteMaximum = 1000, MinorGridlineStyle = LineStyle.Dot, Position = AxisPosition.Left }); // Линия текущей температуры plotModel.Series.Add(lineCurTemp = new LineSeries() { Title = "Текущая температура", }); // Линия температуры, к которой мы стремимся plotModel.Series.Add(lineTargetTemp = new StairStepSeries() { Title = "Нужная температура", VerticalStrokeThickness = 0.4 }); // Линия мощности которую вкачали в систему plotModel.Series.Add(lineSystemPower = new LineSeries() { Title = "Мощность" }); }
public static PlotModel StairStepSeriesDashedVertical() { var model = new PlotModel("StairStepSeries", "With dashed vertical lines"); var s1 = new StairStepSeries("sin(x)") { Color = OxyColors.SkyBlue, VerticalLineStyle = LineStyle.Dash, MarkerType = MarkerType.None }; for (double x = 0; x < Math.PI * 2; x += 0.5) s1.Points.Add(new DataPoint(x, Math.Sin(x))); model.Series.Add(s1); return model; }
public static PlotModel StairStepSeriesThinVertical() { var model = new PlotModel("StairStepSeries", "With thin vertical lines"); var s1 = new StairStepSeries("sin(x)") { Color = OxyColors.SkyBlue, StrokeThickness = 3, VerticalStrokeThickness = 0.4, MarkerType = MarkerType.None }; for (double x = 0; x < Math.PI * 2; x += 0.5) s1.Points.Add(new DataPoint(x, Math.Sin(x))); model.Series.Add(s1); return model; }
public MainWindow(ILogContainer logContainer) { this.logContainer = logContainer; this.logContainer.Updated += LoggingUpdated; InitializeComponent(); MenuMru.MenuClick += (s, e) => FileOpenCore(e.Filepath); ITest selectedTest = null; var testFactory = new TestFactory(); foreach (var test in testFactory.GetList()) { tests.Add(test); if (test.Name.Equals(Settings.Default.SelectedTest)) { selectedTest = test; } } CmbTests.DataContext = tests; if (selectedTest != null) { CmbTests.SelectedItem = selectedTest; BtnStart.Focus(); } else { CmbTests.Focus(); CmbTests.IsDropDownOpen = true; BtnStart.IsEnabled = false; } var lineSerie = new StairStepSeries() { Smooth = true, MarkerType = MarkerType.Diamond }; lineSerie.Points.Add(new DataPoint(0.4, 4)); lineSerie.Points.Add(new DataPoint(10, 13)); lineSerie.Points.Add(new DataPoint(20, 15)); lineSerie.Points.Add(new DataPoint(30, 16)); lineSerie.Points.Add(new DataPoint(40, 12)); lineSerie.Points.Add(new DataPoint(50, 12)); var model = new PlotModel(); model.Series.Add(lineSerie); Plot.Model = model; }
public static PlotModel StairStepSeriesDashedVertical() { var model = new PlotModel("StairStepSeries", "With dashed vertical lines"); var s1 = new StairStepSeries("sin(x)") { Color = OxyColors.SkyBlue, VerticalLineStyle = LineStyle.Dash, MarkerType = MarkerType.None }; for (double x = 0; x < Math.PI * 2; x += 0.5) { s1.Points.Add(new DataPoint(x, Math.Sin(x))); } model.Series.Add(s1); return(model); }
public static PlotModel StairStepSeries() { var model = new PlotModel("StairStepSeries") { LegendSymbolLength = 24 }; var s1 = new StairStepSeries("sin(x)") { Color = OxyColors.SkyBlue, MarkerType = MarkerType.Circle, MarkerSize = 6, MarkerStroke = OxyColors.White, MarkerFill = OxyColors.SkyBlue, MarkerStrokeThickness = 1.5 }; for (double x = 0; x < Math.PI * 2; x += 0.5) s1.Points.Add(new DataPoint(x, Math.Sin(x))); model.Series.Add(s1); return model; }
public void Setup_Oxyplot() { m_spectrum = new OxyPlot.Series.StairStepSeries() { StrokeThickness = 2, Color = OxyColors.Blue, LineStyle = LineStyle.Solid }; m_spectrum_max = new OxyPlot.Series.StairStepSeries() { StrokeThickness = 2, Color = OxyColors.Gray, LineStyle = LineStyle.Solid }; sweep_plot_model = new PlotModel { PlotAreaBackground = OxyColors.White, Title = "RF Sweep dBm", PlotType = PlotType.XY, Axes = { new OxyPlot.Axes.LinearAxis() { Minimum = -120, Maximum = 0, Position = OxyPlot.Axes.AxisPosition.Right, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dash }, new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dash } }, Series = { m_spectrum_max, m_spectrum } }; }
public static PlotModel StairStepSeriesThinVertical() { var model = new PlotModel("StairStepSeries", "With thin vertical lines"); var s1 = new StairStepSeries("sin(x)") { Color = OxyColors.SkyBlue, StrokeThickness = 3, VerticalStrokeThickness = 0.4, MarkerType = MarkerType.None }; for (double x = 0; x < Math.PI * 2; x += 0.5) { s1.Points.Add(new DataPoint(x, Math.Sin(x))); } model.Series.Add(s1); return(model); }
public void AddStairPlot(IEnumerable <double> xVal, IEnumerable <double> yVal, string name = null, LineStyle style = LineStyle.Automatic) { if (xVal.Count() != yVal.Count()) { throw new Exception("X and Y values count must be equal."); } StairStepSeries step = new StairStepSeries(); step.Title = name; step.LineStyle = style; var enumX = xVal.GetEnumerator(); var enumY = yVal.GetEnumerator(); while (enumX.MoveNext() && enumY.MoveNext()) { step.Points.Add(new DataPoint(enumX.Current, enumY.Current)); } PlotModel.Series.Add(step); }
private bool JustPlotter(object ChartControl, object[] Data) { try { string[] lines; lines = (Data[0] as string).Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); List <DataPoint> points = new List <DataPoint>(lines.Length); foreach (var item in lines) { string[] tmp = item.Split(':'); if (tmp.Length > 1) { int i, j; bool b = int.TryParse(tmp[0], out i); b = int.TryParse(tmp[1], out j) && b; if (b) { points.Add(new DataPoint(i, j)); } } } var mySeries = new StairStepSeries(); mySeries.Points.AddRange(points); mySeries.Color = OxyColor.FromRgb(((Color)(Data[2])).R, ((Color)(Data[2])).G, ((Color)(Data[2])).B); (ChartControl as PlotView).Model.Axes[0].MaximumRange = points.Last().X - points.First().X + 1; (ChartControl as PlotView).Model.Axes[0].AbsoluteMaximum = points.Last().X + 1; (ChartControl as PlotView).Model.Axes[0].AbsoluteMinimum = points.First().X - 1; (ChartControl as PlotView).Model.Series.Add(mySeries); } catch (Exception ex) { MessageBox.Show("Error during plotting: " + ex.Message); return(false); } return(true); }
//internal static LineSeries CreateSaldoverlaufLine(this BudgetVm aBudgetVm, DateTime aStartDate, DateTime aEndDate, bool aIncludeStartAndEndSaldo) //{ // LineSeries lSerie = new LineSeries(); // lSerie.Title = aBudgetVm.Bezeichnung; // lSerie.XAxisKey = "X"; // lSerie.YAxisKey = "Y"; // var lBuchungenRelevant = aBudgetVm.Buchungen.OrderBy(aB => aB.Datum).Where(aB => aB.Datum >= aStartDate && aB.Datum <= aEndDate); // int lSaldo = aBudgetVm.Buchungen.Where(aB => aB.Datum < aStartDate).Sum(aB => aB.Betrag); // if (aIncludeStartAndEndSaldo) // { // // Startwert // lSerie.Points.Add(new DataPoint(DateTimeAxis.ToDouble(aStartDate), Convert.ToDouble(MoneyManager.GetFrankenRappen(lSaldo, true)))); // } // foreach (var lBuchung in lBuchungenRelevant) // { // lSaldo += lBuchung.Betrag; // DataPoint lPoint = new DataPoint( // DateTimeAxis.ToDouble(lBuchung.Datum), // Convert.ToDouble(MoneyManager.GetFrankenRappen(lSaldo, true))); // lSerie.Points.Add(lPoint); // } // if (aIncludeStartAndEndSaldo) // { // // Endwert // lSerie.Points.Add(new DataPoint(DateTimeAxis.ToDouble(aEndDate), Convert.ToDouble(MoneyManager.GetFrankenRappen(lSaldo, true)))); // } // return lSerie; //} internal static StairStepSeries CreateSaldoChangeStairLine(this BudgetVm aBudgetVm, DateTime aStartDate, DateTime aEndDate, bool aIncludeStartAndEndSaldo) { StairStepSeries lSerie = new StairStepSeries(); lSerie.Title = aBudgetVm.Bezeichnung; lSerie.XAxisKey = "X"; lSerie.YAxisKey = "Y"; lSerie.MarkerType = MarkerType.Circle; var lBuchungenRelevant = aBudgetVm.Buchungen.OrderBy(aB => aB.Datum).Where(aB => aB.Datum >= aStartDate && aB.Datum <= aEndDate); int lSaldo = aBudgetVm.Buchungen.Where(aB => aB.Datum < aStartDate).Sum(aB => aB.Betrag); if (aIncludeStartAndEndSaldo) { // Startwert lSerie.Points.Add(new DataPoint(DateTimeAxis.ToDouble(aStartDate), Convert.ToDouble(MoneyManager.GetFrankenRappen(lSaldo, true)))); } foreach (var lBuchung in lBuchungenRelevant) { lSaldo += lBuchung.Betrag; DataPoint lPoint = new DataPoint( DateTimeAxis.ToDouble(lBuchung.Datum), Convert.ToDouble(MoneyManager.GetFrankenRappen(lSaldo, true))); lSerie.Points.Add(lPoint); } if (aIncludeStartAndEndSaldo) { // Endwert lSerie.Points.Add(new DataPoint(DateTimeAxis.ToDouble(aEndDate), Convert.ToDouble(MoneyManager.GetFrankenRappen(lSaldo, true)))); } return(lSerie); }
public static PlotModel StairStepSeries() { var model = new PlotModel("StairStepSeries") { LegendSymbolLength = 24 }; var s1 = new StairStepSeries("sin(x)") { Color = OxyColors.SkyBlue, MarkerType = MarkerType.Circle, MarkerSize = 6, MarkerStroke = OxyColors.White, MarkerFill = OxyColors.SkyBlue, MarkerStrokeThickness = 1.5 }; for (double x = 0; x < Math.PI * 2; x += 0.5) { s1.Points.Add(new DataPoint(x, Math.Sin(x))); } model.Series.Add(s1); return(model); }
internal bool OneWirePlotter(object ChartControl, object[] Data) { try { string[] lines; //Load points (Data[0]) lines = (Data[0] as string).Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); List <DataPoint> points = new List <DataPoint>(lines.Length); foreach (var item in lines) { string[] tmp = item.Split(':'); points.Add(new DataPoint(int.Parse(tmp[0]), int.Parse(tmp[1]))); } //Load annotations (Data[1]) Data[1] = (Data[1] as string).Remove(0, (Data[1] as string).IndexOf("L:")).Trim('\r', '\n').Remove(0, 2).Trim('\r', '\n'); //Get the list of pulses lines = (Data[1] as string).Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); int last_coord = 0; int[] last_len = new int[] { 0, 0 }; double[] pos = new double[] { 1.1, -0.15 }; for (int i = 0; i < lines.Length; i++) { string[] tmp = lines[i].Split('@').Select(x => x.Trim()).ToArray(); string[] dur = tmp[0].Split('=').Select(x => x.Trim()).ToArray(); tmp[0] = dur[0]; if (tmp[0].Length == 0) { continue; } int[] len = new int[] { tmp[0].Length, dur[1].Length }; int coord = int.Parse(tmp[1]); double size = (ChartControl as PlotView).Model.DefaultFontSize; if (((last_len[0] > 1) || (len[0] > 1) || (coord - last_coord < 25)) && (coord - last_coord < 600)) { pos[0] = pos[0] > 1.2 ? 1.1 : 1.25; } else { pos[0] = 1.1; } if ((len[0] > 6) && (coord - last_coord < 100)) //Try not to create a mess { size /= 1.5; } else { if (len[0] > 4) { size /= 1.2; } } (ChartControl as PlotView).Model.Annotations.Add(new ImageAnnotation() //Type { ImageSource = DrawText(tmp[0], size), X = new PlotLength(coord, PlotLengthUnit.Data), Y = new PlotLength(pos[0], PlotLengthUnit.Data) }); size = (ChartControl as PlotView).Model.DefaultFontSize / 1.5; if (((last_len[1] > 1) || (len[1] > 1) || (coord - last_coord < 25)) && (coord - last_coord < 150)) { pos[1] = (pos[1] < -0.15) ? -0.15 : -0.3; } else { pos[1] = -0.15; } (ChartControl as PlotView).Model.Annotations.Add(new ImageAnnotation() //Duration { ImageSource = DrawText(dur[1], size), X = new PlotLength(coord, PlotLengthUnit.Data), Y = new PlotLength(pos[1], PlotLengthUnit.Data) }); last_coord = coord; last_len = len; } //Setup the plot var mySeries = new StairStepSeries(); mySeries.Points.AddRange(points); mySeries.Color = OxyColor.FromRgb(((Color)(Data[2])).R, ((Color)(Data[2])).G, ((Color)(Data[2])).B); (ChartControl as PlotView).Model.Axes[0].MaximumRange = points.Last().X - points.First().X + 1; (ChartControl as PlotView).Model.Axes[0].AbsoluteMaximum = points.Last().X + 1; (ChartControl as PlotView).Model.Axes[0].AbsoluteMinimum = points.First().X - 1; (ChartControl as PlotView).Model.Series.Add(mySeries); } catch (Exception ex) { MessageBox.Show("Error during listing parsing: " + ex.Message); return(false); } return(true); }
public SVPlot() { // Select .qua file OpenFileDialog dialog = new OpenFileDialog(); dialog.DefaultExt = ".qua"; dialog.Filter = "Quaver map files (.qua)|*.qua"; dialog.InitialDirectory = "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Quaver\\Songs"; bool?result = dialog.ShowDialog(); if (result == true) { Map = Qua.Parse(dialog.FileName, false); } Map.NormalizeSVs(); Map.SliderVelocities.Insert(0, new SliderVelocityInfo { StartTime = Math.Min(Map.SliderVelocities[0].StartTime, 0) - 3000, Multiplier = Map.InitialScrollVelocity }); Map.SliderVelocities.Add(new SliderVelocityInfo { StartTime = Math.Max(Map.SliderVelocities.Last().StartTime, Map.Length) + 3000, Multiplier = Map.SliderVelocities.Last().Multiplier }); // Plot stuff Model = new PlotModel { Title = Map.ToString() }; Model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Key = "Time", Title = "Time (ms)" }); Model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Key = "Velocity", Title = "Velocity", Minimum = -10, Maximum = 10 }); Model.Axes.Add(new LinearAxis { Position = AxisPosition.Right, Key = "Position", Title = "Position", PositionTier = 1 }); // Scroll Velocities SVSeries = new StairStepSeries(); SVSeries.Title = "Scroll Velocities"; SVSeries.VerticalStrokeThickness = .25; SVSeries.CanTrackerInterpolatePoints = false; SVSeries.DataFieldX = "Time"; SVSeries.DataFieldY = "Multiplier"; SVSeries.YAxisKey = "Velocity"; foreach (SliderVelocityInfo sv in Map.SliderVelocities) { SVSeries.Points.Add(new DataPoint(sv.StartTime, sv.Multiplier)); } // Position PositionSeries = new LineSeries(); PositionSeries.Title = "Position"; PositionSeries.CanTrackerInterpolatePoints = true; PositionSeries.DataFieldX = "Time"; PositionSeries.DataFieldY = "Position"; PositionSeries.YAxisKey = "Position"; // Calculate position data points based off of Quaver's position calculations // This is pretty much just HitObjectManagerKeys.InitializePositionMarkers() long position = (long)(Map.SliderVelocities[0].StartTime * Map.InitialScrollVelocity * 100); PositionSeries.Points.Add(new DataPoint(Map.SliderVelocities[0].StartTime, position)); for (int i = 1; i < Map.SliderVelocities.Count; i++) { position += (long)((Map.SliderVelocities[i].StartTime - Map.SliderVelocities[i - 1].StartTime) * Map.SliderVelocities[i - 1].Multiplier * 100); PositionSeries.Points.Add(new DataPoint(Map.SliderVelocities[i].StartTime, position)); } Model.Series.Add(SVSeries); Model.Series.Add(PositionSeries); }
public static PlotModel StairStepSeries() { // prepare the model var model = new PlotModel() { Title = "Gillespie Simulation", LegendPlacement = LegendPlacement.Outside, LegendPosition = LegendPosition.TopCenter, LegendOrientation = LegendOrientation.Horizontal }; // add two linear axes model.Axes.Add(new LinearAxis() { Title = "Time (hours)", Position = AxisPosition.Bottom }); model.Axes.Add(new LinearAxis() { Title = "Count", Position = AxisPosition.Left }); // initialise series var stairStepSeries1 = new StairStepSeries() { Title = "Species 1" }; model.Series.Add(stairStepSeries1); var stairStepSeries2 = new StairStepSeries() { Title = "Species 2" }; model.Series.Add(stairStepSeries2); // perform simple Gillespie simulation var rnd = new Random(0); double sampleExponentialDistribution(double λ) => System.Math.Log(1 - rnd.NextDouble()) / -λ; int s1 = 10; int s2 = 0; double t = 0; while (true) { // add data-points to series stairStepSeries1.Points.Add(new DataPoint(t, s1)); stairStepSeries2.Points.Add(new DataPoint(t, s2)); if (s1 + s2 == 0) { break; } var r1 = 0.2 * s1; var r2 = 0.1 * s2; t += sampleExponentialDistribution(r1 + r2); if (rnd.NextDouble() * (r1 + r2) < r1) { s1--; s2++; } else { s2--; } } return(model); }
private async Task UpdateMeasurements() { _viewModel.IsBusy = true; _viewModel.TodayDate = DateTime.Now; // _viewModel.MeasurementsList = await ProgenyService.GetMeasurementsList(_viewChild, _viewModel.UserAccessLevel, _userInfo.Timezone); List <Measurement> measurementsList = await ProgenyService.GetMeasurementsList(_viewModel.ViewChild, _viewModel.UserAccessLevel); if (measurementsList != null && measurementsList.Count > 0) { measurementsList = measurementsList.OrderBy(m => m.Date).ToList(); LineSeries heightLineSeries = new LineSeries() { Color = OxyColors.DarkGreen, MarkerType = MarkerType.Circle, MarkerSize = 3, MarkerStroke = OxyColors.White, MarkerFill = OxyColors.Green, MarkerStrokeThickness = 1.5, Title = HeightLabel.Text }; StairStepSeries heightStairStepSeries = new StairStepSeries() { Color = OxyColors.DarkGreen, MarkerType = MarkerType.Circle, MarkerSize = 3, MarkerStroke = OxyColors.White, MarkerFill = OxyColors.Green, MarkerStrokeThickness = 1.5, Title = HeightLabel.Text }; StemSeries heightStemSeries = new StemSeries() { Color = OxyColors.DarkGreen, MarkerType = MarkerType.Circle, MarkerSize = 3, MarkerStroke = OxyColors.White, MarkerFill = OxyColors.Green, MarkerStrokeThickness = 1.5, Title = HeightLabel.Text }; LineSeries weightLineSeries = new LineSeries() { Color = OxyColors.DarkGreen, MarkerType = MarkerType.Circle, MarkerSize = 3, MarkerStroke = OxyColors.White, MarkerFill = OxyColors.Green, MarkerStrokeThickness = 1.5, Title = WeightLabel.Text }; StairStepSeries weightStairStepSeries = new StairStepSeries() { Color = OxyColors.DarkGreen, MarkerType = MarkerType.Circle, MarkerSize = 3, MarkerStroke = OxyColors.White, MarkerFill = OxyColors.Green, MarkerStrokeThickness = 1.5, Title = WeightLabel.Text }; StemSeries weightStemSeries = new StemSeries() { Color = OxyColors.DarkGreen, MarkerType = MarkerType.Circle, MarkerSize = 3, MarkerStroke = OxyColors.White, MarkerFill = OxyColors.Green, MarkerStrokeThickness = 1.5, Title = WeightLabel.Text }; double maxHeight = 0; double maxWeight = 0; double minHeight = 1000; double minWeight = 1000; DateTime firstMeasurementItem = _viewModel.EndDate; DateTime lastMeasurementItem = _viewModel.StartDate; foreach (Measurement mes in measurementsList) { if (mes.Date >= StartDatePicker.Date && mes.Date <= EndDatePicker.Date) { double dateDouble = DateTimeAxis.ToDouble(mes.Date.Date); if (mes.Height > 0) { heightLineSeries.Points.Add(new DataPoint(dateDouble, mes.Height)); heightStairStepSeries.Points.Add(new DataPoint(dateDouble, mes.Height)); heightStemSeries.Points.Add(new DataPoint(dateDouble, mes.Height)); if (mes.Height > maxHeight) { maxHeight = mes.Height; } if (mes.Height < minHeight) { minHeight = mes.Height; } } if (mes.Weight > 0) { weightLineSeries.Points.Add(new DataPoint(dateDouble, mes.Weight)); weightStairStepSeries.Points.Add(new DataPoint(dateDouble, mes.Weight)); weightStemSeries.Points.Add(new DataPoint(dateDouble, mes.Weight)); if (mes.Weight > maxWeight) { maxWeight = mes.Weight; } if (mes.Weight < minWeight) { minWeight = mes.Weight; } } } if (mes.Date < firstMeasurementItem) { firstMeasurementItem = mes.Date; } if (mes.Date > lastMeasurementItem) { lastMeasurementItem = mes.Date; } } _viewModel.HeightMinValue = Math.Floor(minHeight); _viewModel.HeightMaxValue = Math.Ceiling(maxHeight); _viewModel.WeightMinValue = Math.Floor(minWeight); _viewModel.WeightMaxValue = Math.Ceiling(maxWeight); _viewModel.FirstDate = firstMeasurementItem; _viewModel.LastDate = lastMeasurementItem; LinearAxis heightAxis = new LinearAxis(); heightAxis.Key = "HeightAxis"; heightAxis.Minimum = _viewModel.HeightMinValue * 0.9; heightAxis.Maximum = _viewModel.HeightMaxValue * 1.1; heightAxis.Position = AxisPosition.Left; heightAxis.MajorStep = 10; heightAxis.MinorStep = 5; heightAxis.MajorGridlineStyle = LineStyle.Solid; heightAxis.MinorGridlineStyle = LineStyle.Solid; heightAxis.MajorGridlineColor = OxyColor.FromRgb(200, 190, 170); heightAxis.MinorGridlineColor = OxyColor.FromRgb(250, 225, 205); heightAxis.AxislineColor = OxyColor.FromRgb(0, 0, 0); LinearAxis weightAxis = new LinearAxis(); weightAxis.Key = "WeightAxis"; weightAxis.Minimum = _viewModel.WeightMinValue * 0.9; weightAxis.Maximum = _viewModel.WeightMaxValue * 1.1; weightAxis.Position = AxisPosition.Left; weightAxis.MajorStep = 2; weightAxis.MinorStep = 1; weightAxis.MajorGridlineStyle = LineStyle.Solid; weightAxis.MinorGridlineStyle = LineStyle.Solid; weightAxis.MajorGridlineColor = OxyColor.FromRgb(200, 190, 170); weightAxis.MinorGridlineColor = OxyColor.FromRgb(250, 225, 205); weightAxis.AxislineColor = OxyColor.FromRgb(0, 0, 0); DateTimeAxis dateAxis = new DateTimeAxis(); dateAxis.Key = "DateAxisHeight"; dateAxis.Minimum = DateTimeAxis.ToDouble(StartDatePicker.Date); dateAxis.Maximum = DateTimeAxis.ToDouble(EndDatePicker.Date); dateAxis.Position = AxisPosition.Bottom; dateAxis.AxislineColor = OxyColor.FromRgb(0, 0, 0); dateAxis.StringFormat = "dd-MMM-yyyy"; dateAxis.MajorGridlineStyle = LineStyle.Solid; dateAxis.MajorGridlineColor = OxyColor.FromRgb(230, 190, 190); dateAxis.IntervalType = DateTimeIntervalType.Auto; dateAxis.FirstDayOfWeek = DayOfWeek.Monday; dateAxis.MinorIntervalType = DateTimeIntervalType.Auto; DateTimeAxis dateAxisWeight = new DateTimeAxis(); dateAxisWeight.Key = "DateAxisWeight"; dateAxisWeight.Minimum = DateTimeAxis.ToDouble(StartDatePicker.Date); dateAxisWeight.Maximum = DateTimeAxis.ToDouble(EndDatePicker.Date); dateAxisWeight.Position = AxisPosition.Bottom; dateAxisWeight.AxislineColor = OxyColor.FromRgb(0, 0, 0); dateAxisWeight.StringFormat = "dd-MMM-yyyy"; dateAxisWeight.MajorGridlineStyle = LineStyle.Solid; dateAxisWeight.MajorGridlineColor = OxyColor.FromRgb(230, 190, 190); dateAxisWeight.IntervalType = DateTimeIntervalType.Auto; dateAxisWeight.FirstDayOfWeek = DayOfWeek.Monday; dateAxisWeight.MinorIntervalType = DateTimeIntervalType.Auto; _viewModel.PlotModelHeight = new PlotModel(); _viewModel.PlotModelHeight.Background = OxyColors.White; _viewModel.PlotModelHeight.Axes.Add(heightAxis); _viewModel.PlotModelHeight.Axes.Add(dateAxis); _viewModel.PlotModelHeight.LegendPosition = LegendPosition.BottomCenter; _viewModel.PlotModelHeight.LegendBackground = OxyColors.LightYellow; _viewModel.PlotModelWeight = new PlotModel(); _viewModel.PlotModelWeight.Background = OxyColors.White; _viewModel.PlotModelWeight.Axes.Add(weightAxis); _viewModel.PlotModelWeight.Axes.Add(dateAxisWeight); _viewModel.PlotModelWeight.LegendPosition = LegendPosition.BottomCenter; _viewModel.PlotModelWeight.LegendBackground = OxyColors.LightYellow; if (ChartTypePicker.SelectedIndex == 0) { _viewModel.PlotModelHeight.Series.Add(heightLineSeries); _viewModel.PlotModelWeight.Series.Add(weightLineSeries); } if (ChartTypePicker.SelectedIndex == 1) { _viewModel.PlotModelHeight.Series.Add(heightStairStepSeries); _viewModel.PlotModelWeight.Series.Add(weightStairStepSeries); } if (ChartTypePicker.SelectedIndex == 2) { _viewModel.PlotModelHeight.Series.Add(heightStemSeries); _viewModel.PlotModelWeight.Series.Add(weightStemSeries); } _viewModel.PlotModelHeight.InvalidatePlot(true); _viewModel.PlotModelWeight.InvalidatePlot(true); } _viewModel.IsBusy = false; }
private async Task UpdateVocabulary() { _viewModel.IsBusy = true; _viewModel.TodayDate = DateTime.Now; List <VocabularyItem> vocabularyList = await ProgenyService.GetVocabularyList(_viewModel.ViewChild, _viewModel.UserAccessLevel, _viewModel.UserInfo.Timezone); _viewModel.VocabularyItems.ReplaceRange(vocabularyList); if (vocabularyList != null && vocabularyList.Count > 0) { vocabularyList = vocabularyList.OrderBy(v => v.Date).ToList(); List <WordDateCount> dateTimesList = new List <WordDateCount>(); int wordCount = 0; foreach (VocabularyItem vocabularyItem in vocabularyList) { wordCount++; if (vocabularyItem.Date != null) { if (dateTimesList.SingleOrDefault(d => d.WordDate.Date == vocabularyItem.Date.Value.Date) == null) { WordDateCount newDate = new WordDateCount(); newDate.WordDate = vocabularyItem.Date.Value.Date; newDate.WordCount = wordCount; dateTimesList.Add(newDate); } else { WordDateCount wrdDateCount = dateTimesList.SingleOrDefault(d => d.WordDate.Date == vocabularyItem.Date.Value.Date); if (wrdDateCount != null) { wrdDateCount.WordCount = wordCount; } } } } LineSeries vocabularyLineSeries = new LineSeries() { Color = OxyColors.DarkGreen, MarkerType = MarkerType.Circle, MarkerSize = 3, MarkerStroke = OxyColors.White, MarkerFill = OxyColors.Green, MarkerStrokeThickness = 1.5, Title = this.Title }; StairStepSeries vocabularyStairStepSeries = new StairStepSeries() { Color = OxyColors.DarkGreen, MarkerType = MarkerType.Circle, MarkerSize = 3, MarkerStroke = OxyColors.White, MarkerFill = OxyColors.Green, MarkerStrokeThickness = 1.5, Title = this.Title }; StemSeries vocabularyStemSeries = new StemSeries() { Color = OxyColors.DarkGreen, MarkerType = MarkerType.Circle, MarkerSize = 3, MarkerStroke = OxyColors.White, MarkerFill = OxyColors.Green, MarkerStrokeThickness = 1.5, Title = this.Title }; double maxCount = 0; double minCount = 100000; DateTime firstWordDate = _viewModel.EndDate; DateTime lastWordDate = _viewModel.StartDate; foreach (WordDateCount wordDateCount in dateTimesList) { if (wordDateCount.WordDate >= StartDatePicker.Date && wordDateCount.WordDate <= EndDatePicker.Date) { double wordDateDouble = DateTimeAxis.ToDouble(wordDateCount.WordDate.Date); vocabularyLineSeries.Points.Add(new DataPoint(wordDateDouble, wordDateCount.WordCount)); vocabularyStairStepSeries.Points.Add(new DataPoint(wordDateDouble, wordDateCount.WordCount)); vocabularyStemSeries.Points.Add(new DataPoint(wordDateDouble, wordDateCount.WordCount)); if (wordDateCount.WordCount > maxCount) { maxCount = wordDateCount.WordCount; } if (wordDateCount.WordCount < minCount) { minCount = wordDateCount.WordCount; } } if (wordDateCount.WordDate < firstWordDate) { firstWordDate = wordDateCount.WordDate; } if (wordDateCount.WordDate > lastWordDate) { lastWordDate = wordDateCount.WordDate; } } _viewModel.MinValue = Math.Floor(minCount); _viewModel.MaxValue = Math.Ceiling(maxCount); _viewModel.FirstDate = firstWordDate; _viewModel.LastDate = lastWordDate; LinearAxis wordCountAxis = new LinearAxis(); wordCountAxis.Key = "WordCountAxis"; wordCountAxis.Minimum = 0; //_viewModel.MinValue -1; wordCountAxis.Maximum = _viewModel.MaxValue; // + 1; wordCountAxis.Position = AxisPosition.Left; wordCountAxis.MajorStep = 10; wordCountAxis.MinorStep = 5; wordCountAxis.MajorGridlineStyle = LineStyle.Solid; wordCountAxis.MinorGridlineStyle = LineStyle.Solid; wordCountAxis.MajorGridlineColor = OxyColor.FromRgb(200, 190, 170); wordCountAxis.MinorGridlineColor = OxyColor.FromRgb(250, 225, 205); wordCountAxis.AxislineColor = OxyColor.FromRgb(0, 0, 0); DateTimeAxis dateAxis = new DateTimeAxis(); dateAxis.Key = "DateAxis"; dateAxis.Minimum = DateTimeAxis.ToDouble(StartDatePicker.Date); dateAxis.Maximum = DateTimeAxis.ToDouble(EndDatePicker.Date); dateAxis.Position = AxisPosition.Bottom; dateAxis.AxislineColor = OxyColor.FromRgb(0, 0, 0); dateAxis.StringFormat = "dd-MMM-yyyy"; dateAxis.MajorGridlineStyle = LineStyle.Solid; dateAxis.MajorGridlineColor = OxyColor.FromRgb(230, 190, 190); dateAxis.IntervalType = DateTimeIntervalType.Auto; dateAxis.FirstDayOfWeek = DayOfWeek.Monday; dateAxis.MinorIntervalType = DateTimeIntervalType.Auto; _viewModel.VocabularyPlotModel = new PlotModel(); _viewModel.VocabularyPlotModel.Background = OxyColors.White; _viewModel.VocabularyPlotModel.Axes.Add(wordCountAxis); _viewModel.VocabularyPlotModel.Axes.Add(dateAxis); _viewModel.VocabularyPlotModel.LegendPosition = LegendPosition.TopLeft; _viewModel.VocabularyPlotModel.LegendBackground = OxyColors.LightYellow; if (ChartTypePicker.SelectedIndex == 0) { _viewModel.VocabularyPlotModel.Series.Add(vocabularyLineSeries); } if (ChartTypePicker.SelectedIndex == 1) { _viewModel.VocabularyPlotModel.Series.Add(vocabularyStairStepSeries); } if (ChartTypePicker.SelectedIndex == 2) { _viewModel.VocabularyPlotModel.Series.Add(vocabularyStemSeries); } _viewModel.VocabularyPlotModel.InvalidatePlot(true); } _viewModel.IsBusy = false; }
private async Task UpdateSleep() { _viewModel.IsBusy = true; _viewModel.TodayDate = DateTime.Now; _viewModel.SleepStats = await ProgenyService.GetSleepStats(_viewModel.ViewChild, _viewModel.UserAccessLevel); if (_viewModel.SleepStats != null) { Device.BeginInvokeOnMainThread(() => { _viewModel.SleepTotal = _viewModel.SleepStats.SleepTotal; _viewModel.TotalAverage = _viewModel.SleepStats.TotalAverage; _viewModel.SleepLastMonth = _viewModel.SleepStats.SleepLastMonth; _viewModel.LastMonthAverage = _viewModel.SleepStats.LastMonthAverage; _viewModel.SleepLastYear = _viewModel.SleepStats.SleepLastYear; _viewModel.LastYearAverage = _viewModel.SleepStats.LastYearAverage; }); } List <Sleep> sleepList = await ProgenyService.GetSleepChartData(_viewModel.ViewChild, _viewModel.UserAccessLevel); _viewModel.SleepItems.ReplaceRange(sleepList); if (sleepList != null && sleepList.Count > 0) { LineSeries sleepLineSeries = new LineSeries() { Color = OxyColors.DarkGreen, MarkerType = MarkerType.Circle, MarkerSize = 3, MarkerStroke = OxyColors.White, MarkerFill = OxyColors.Green, MarkerStrokeThickness = 1.5, Title = this.Title }; StairStepSeries sleepStairStepSeries = new StairStepSeries() { Color = OxyColors.DarkGreen, MarkerType = MarkerType.Circle, MarkerSize = 3, MarkerStroke = OxyColors.White, MarkerFill = OxyColors.Green, MarkerStrokeThickness = 1.5, Title = this.Title }; StemSeries sleepStemSeries = new StemSeries() { Color = OxyColors.DarkGreen, MarkerType = MarkerType.Circle, MarkerSize = 3, MarkerStroke = OxyColors.White, MarkerFill = OxyColors.Green, MarkerStrokeThickness = 1.5, Title = this.Title }; double maxSleep = 0; double minSleep = 24; DateTime firstSleepItem = _viewModel.EndDate; DateTime lastSleepItem = _viewModel.StartDate; foreach (Sleep slp in _viewModel.SleepItems) { if (slp.SleepStart >= StartDatePicker.Date && slp.SleepStart <= EndDatePicker.Date) { slp.SleepStart = slp.SleepStart.Date; slp.SleepDurDouble = slp.SleepDuration.TotalMinutes / 60.0; double startDateDouble = DateTimeAxis.ToDouble(slp.SleepStart.Date); sleepLineSeries.Points.Add(new DataPoint(startDateDouble, slp.SleepDurDouble)); sleepStairStepSeries.Points.Add(new DataPoint(startDateDouble, slp.SleepDurDouble)); sleepStemSeries.Points.Add(new DataPoint(startDateDouble, slp.SleepDurDouble)); if (slp.SleepDurDouble > maxSleep) { maxSleep = slp.SleepDurDouble; } if (slp.SleepDurDouble < minSleep) { minSleep = slp.SleepDurDouble; } } if (slp.SleepStart < firstSleepItem) { firstSleepItem = slp.SleepStart; } if (slp.SleepStart > lastSleepItem) { lastSleepItem = slp.SleepStart; } } if (sleepLineSeries.Points.Any()) { _viewModel.MinValue = Math.Floor(minSleep); _viewModel.MaxValue = Math.Ceiling(maxSleep); _viewModel.FirstDate = firstSleepItem; _viewModel.LastDate = lastSleepItem; LinearAxis durationAxis = new LinearAxis(); durationAxis.Key = "DurationAxis"; durationAxis.Minimum = 0; //_viewModel.MinValue -1; durationAxis.Maximum = _viewModel.MaxValue; // + 1; durationAxis.AbsoluteMinimum = 0; //_viewModel.MinValue -1; durationAxis.AbsoluteMaximum = _viewModel.MaxValue; // + 1; durationAxis.Position = AxisPosition.Left; durationAxis.MajorStep = 1; durationAxis.MinorStep = 0.5; durationAxis.MajorGridlineStyle = LineStyle.Solid; durationAxis.MinorGridlineStyle = LineStyle.Solid; durationAxis.MajorGridlineColor = OxyColor.FromRgb(200, 190, 170); durationAxis.MinorGridlineColor = OxyColor.FromRgb(250, 225, 205); durationAxis.AxislineColor = OxyColor.FromRgb(0, 0, 0); DateTimeAxis dateAxis = new DateTimeAxis(); dateAxis.Key = "DateAxis"; dateAxis.Minimum = DateTimeAxis.ToDouble(StartDatePicker.Date); dateAxis.Maximum = DateTimeAxis.ToDouble(EndDatePicker.Date); dateAxis.AbsoluteMinimum = DateTimeAxis.ToDouble(StartDatePicker.Date); dateAxis.AbsoluteMaximum = DateTimeAxis.ToDouble(EndDatePicker.Date); dateAxis.Position = AxisPosition.Bottom; dateAxis.AxislineColor = OxyColor.FromRgb(0, 0, 0); dateAxis.StringFormat = "dd-MMM-yyyy"; dateAxis.MajorGridlineStyle = LineStyle.Solid; dateAxis.MajorGridlineColor = OxyColor.FromRgb(230, 190, 190); dateAxis.IntervalType = DateTimeIntervalType.Auto; dateAxis.FirstDayOfWeek = DayOfWeek.Monday; dateAxis.MinorIntervalType = DateTimeIntervalType.Auto; _viewModel.SleepPlotModel = new PlotModel(); _viewModel.SleepPlotModel.Background = OxyColors.White; _viewModel.SleepPlotModel.Axes.Add(dateAxis); _viewModel.SleepPlotModel.Axes.Add(durationAxis); _viewModel.SleepPlotModel.LegendPosition = LegendPosition.BottomCenter; _viewModel.SleepPlotModel.LegendBackground = OxyColors.LightYellow; Func <double, double> averageFunc = (x) => _viewModel.SleepStats.TotalAverage.TotalMinutes / 60.0; _viewModel.SleepPlotModel.Series.Add(new FunctionSeries(averageFunc, dateAxis.Minimum, dateAxis.Maximum, (int)(dateAxis.Maximum - dateAxis.Minimum), AverageSleepTitle.Text)); Func <double, double> averageYearFunc = (x) => _viewModel.SleepStats.LastYearAverage.TotalMinutes / 60.0; _viewModel.SleepPlotModel.Series.Add(new FunctionSeries(averageYearFunc, dateAxis.Minimum, dateAxis.Maximum, (int)(dateAxis.Maximum - dateAxis.Minimum), AverageSleepYearTitle.Text)); Func <double, double> averageMonthFunc = (x) => _viewModel.SleepStats.LastMonthAverage.TotalMinutes / 60.0; _viewModel.SleepPlotModel.Series.Add(new FunctionSeries(averageMonthFunc, dateAxis.Minimum, dateAxis.Maximum, (int)(dateAxis.Maximum - dateAxis.Minimum), AverageSleepMonthTitle.Text)); if (ChartTypePicker.SelectedIndex == 0) { _viewModel.SleepPlotModel.Series.Add(sleepLineSeries); } if (ChartTypePicker.SelectedIndex == 1) { _viewModel.SleepPlotModel.Series.Add(sleepStairStepSeries); } if (ChartTypePicker.SelectedIndex == 2) { _viewModel.SleepPlotModel.Series.Add(sleepStemSeries); } _viewModel.SleepPlotModel.InvalidatePlot(true); } } _viewModel.IsBusy = false; }