private void plot_xcounts_vs_time(ScatterSeries scatterSeries1, StemSeries stemSeries1, LineSeries lineSeries1, ScatterSeries scatterSeries2, StemSeries stemSeries2, LineSeries lineSeries2) { xlabel = "Time (ms)"; ylabel = "xCounts"; reset_minmax(); for (int i = last_start; i <= last_end; i++) { double x = mlog.Events[i].ts; if (mlog.Events[i].handle == mlog.Handle1) { double y = mlog.Events[i].lastx; update_minmax(x, y); scatterSeries1.Points.Add(new ScatterPoint(x, y)); lineSeries1.Points.Add(new DataPoint(x, y)); stemSeries1.Points.Add(new DataPoint(x, y)); } else if (mlog.Events[i].handle == mlog.Handle2) { double y = (mlog.Events[i].lastx * Math.Cos(mlog.NormT) - mlog.Events[i].lasty * Math.Sin(mlog.NormT)) * mlog.NormR; update_minmax(x, y); scatterSeries2.Points.Add(new ScatterPoint(x, y)); lineSeries2.Points.Add(new DataPoint(x, y)); stemSeries2.Points.Add(new DataPoint(x, y)); } } }
public GraphComponents(OxyColor color) { scatters = new ScatterSeries { BinSize = 8, MarkerFill = color, MarkerSize = 2.0, MarkerStroke = color, MarkerStrokeThickness = 1.0, MarkerType = MarkerType.Circle }; lines = new LineSeries { Color = color, LineStyle = LineStyle.Solid, StrokeThickness = 1.0, Smooth = true }; stems = new StemSeries { Color = color, StrokeThickness = 1.0, }; }
public static PlotModel StemSeries() { var model = new PlotModel { Title = "Trigonometric functions" }; var start = -Math.PI; var end = Math.PI; var step = 0.1; int steps = (int)((Math.Abs(start) + Math.Abs(end)) / step); //generate points for functions var sinData = new DataPoint[steps]; for (int i = 0; i < steps; ++i) { var x = (start + step * i); sinData[i] = new DataPoint(x, Math.Sin(x)); } //sin(x) var sinStemSeries = new StemSeries { MarkerStroke = OxyColors.Green, MarkerType = MarkerType.Circle }; sinStemSeries.Points.AddRange(sinData); model.Series.Add(sinStemSeries); return(model); }
public void PlotSpectra(MSSpectra spectrum) { Model.Series.Clear(); var colorIterator = new ColorTypeIterator(); var charge = 0; if (spectrum.ParentFeature != null) { charge = spectrum.ParentFeature.ChargeState; } var series = new StemSeries { Title = string.Format("{0} m/z charge {1}", spectrum.PrecursorMz, charge), Color = colorIterator.GetColor(charge) }; foreach (var peak in spectrum.Peaks) { series.Points.Add(new DataPoint(peak.X, peak.Y)); } Model.Series.Add(series); }
internal static StemSeries CreateSaldoChangePoints(this BudgetVm aBudgetVm, DateTime aStartDate, DateTime aEndDate) { StemSeries lSerie = new StemSeries(); lSerie.Title = aBudgetVm.Bezeichnung; lSerie.XAxisKey = "X"; lSerie.YAxisKey = "Y"; lSerie.MarkerType = MarkerType.Circle; lSerie.Color = OxyColors.Transparent; lSerie.MarkerFill = OxyColors.Black; 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); foreach (var lBuchung in lBuchungenRelevant) { lSaldo += lBuchung.Betrag; DataPoint lPoint = new DataPoint( DateTimeAxis.ToDouble(lBuchung.Datum), Convert.ToDouble(lBuchung.BetragDisplay)); lSerie.Points.Add(lPoint); } return(lSerie); }
public void TestMethod2() { var diff = new AllpassDiffuser(3000, 48000); diff.Seeds = new ShaRandom().Generate(652, 10000).ToArray(); diff.SetDelay(100); diff.Stages = 3; diff.SetFeedback(0.7); diff.SetModAmount(0.0); var inp = new double[3000]; inp[0] = 1.0; diff.Process(inp, inp.Length); var outp = diff.Output; var pm = new PlotModel(); var series = new StemSeries(); series.MarkerSize = 1.0; series.Color = OxyColors.Black; series.Points.AddRange(outp.ToDataPoints()); pm.Series.Add(series); pm.ToPng(@"e:\allpass3.png", 800, 600); }
/// <summary> /// 生成绘图模型 /// </summary> /// <param name="dat">数据</param> /// <param name="Tittle">数据标题</param> /// <returns></returns> PlotModel generateplotmodel(Complex[] dat, string Tittle) { PlotModel plotmodelTemp = new PlotModel { Title = Tittle }; List <DataPoint> datlist = new List <DataPoint>(); for (int i = 0; i < dat.Length; i++) { datlist.Add(new DataPoint(i, dat[i].Length)); } StemSeries s1 = new StemSeries { Title = "Example 1", ItemsSource = datlist }; ScatterSeries s2 = new ScatterSeries { MarkerType = MarkerType.Circle, Title = "Example 1" }; for (int i = 0; i < dat.Length; i++) { s2.Points.Add(new ScatterPoint(i, dat[i].Length, 10, 500)); } LineSeries lineSeries = new LineSeries { Title = "Example 1", ItemsSource = datlist }; plotmodelTemp.Series.Add(s1); // plotmodelTemp.Axes.Add(new LinearColorAxis { Position = AxisPosition.Right, Palette = OxyPalettes.Jet(200) }); return(plotmodelTemp); }
private static PlotView GetPlot(List <float> xAxisSamples, List <float> yAxisSamples) { var plot = new PlotView(); LinearAxis XAxis = new LinearAxis() { Position = AxisPosition.Bottom }; //, Minimum = 0, Maximum = 10 }; LinearAxis YAxis = new LinearAxis(); PlotModel pm = new PlotModel(); pm.Axes.Add(XAxis); pm.Axes.Add(YAxis); StemSeries fs = new StemSeries(); for (int i = 0; i < xAxisSamples.Count; i++) { double x = i; fs.Points.Add(new DataPoint(xAxisSamples[i], yAxisSamples[i])); } pm.Series.Add(fs); plot.Model = pm; //plot.Anchor = AnchorStyles.Left|AnchorStyles.Right; //plot.Size = new System.Drawing.Size(100, 100); plot.Dock = DockStyle.Fill; return(plot); }
private PlotModel createEnergyPlotModel(List <LayerView> layerViews) { PlotModel pm = new PlotModel() { Title = $"Spot Stats for plan {this.plan.Id}" }; pm.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = "(%)" }); pm.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "Energy" }); var s = new StemSeries { Title = beam.Id, MarkerStroke = OxyColors.Blue, MarkerType = MarkerType.Circle, TrackerFormatString = "{0}\n{1}: {2:0.00}MeV\n{3}: {4:0.00}%" }; foreach (var lv in layerViews) { DataPoint dp = new DataPoint(lv.Energy, lv.MUpercent); s.Points.Add(dp); } pm.Series.Add(s); return(pm); }
public void AddStemPlot(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."); } var stem = new StemSeries(); stem.Title = name; stem.Color = OxyColors.DeepSkyBlue; stem.MarkerFill = OxyColors.DeepSkyBlue; stem.MarkerSize = 6; stem.MarkerStroke = OxyColors.White; stem.MarkerStrokeThickness = 1.5; stem.MarkerType = MarkerType.Circle; stem.LineStyle = style; var enumX = xVal.GetEnumerator(); var enumY = yVal.GetEnumerator(); while (enumX.MoveNext() && enumY.MoveNext()) { stem.Points.Add(new DataPoint(enumX.Current, enumY.Current)); } PlotModel.Series.Add(stem); }
private void plot_yvelocity_vs_time(ScatterSeries scatterSeries1, StemSeries stemSeries1, LineSeries lineSeries1) { xlabel = "Time (ms)"; ylabel = "yVelocity (m/s)"; reset_minmax(); if (this.mlog.Cpi > 0) { for (int i = last_start; i <= last_end; i++) { double x = this.mlog.Events[i].ts; double y; if (i == 0) { y = 0.0; } else { y = (this.mlog.Events[i].lasty) / (this.mlog.Events[i].ts - this.mlog.Events[i - 1].ts) / this.mlog.Cpi * 25.4; } update_minmax(x, y); scatterSeries1.Points.Add(new ScatterPoint(x, y)); lineSeries1.Points.Add(new DataPoint(x, y)); stemSeries1.Points.Add(new DataPoint(x, y)); } } else { MessageBox.Show("CPI value is invalid, please run Measure"); } }
private void plot_ysum_vs_time(ScatterSeries scatterSeries1, StemSeries stemSeries1, LineSeries lineSeries1, ScatterSeries scatterSeries2, StemSeries stemSeries2, LineSeries lineSeries2) { xlabel = "Time (ms)"; ylabel = "ySum"; reset_minmax(); double y1 = 0.0; double y2 = 0.0; for (int i = last_start; i <= last_end; i++) { double x = mlog.Events[i].ts; if (mlog.Events[i].handle == mlog.Handle1) { y1 += mlog.Events[i].lasty; update_minmax(x, y1); scatterSeries1.Points.Add(new ScatterPoint(x, y1)); lineSeries1.Points.Add(new DataPoint(x, y1)); stemSeries1.Points.Add(new DataPoint(x, y1)); } else if (mlog.Events[i].handle == mlog.Handle2) { y2 += (mlog.Events[i].lastx * Math.Sin(mlog.NormT) + mlog.Events[i].lasty * Math.Cos(mlog.NormT)) * mlog.NormR; update_minmax(x, y2); scatterSeries2.Points.Add(new ScatterPoint(x, y2)); lineSeries2.Points.Add(new DataPoint(x, y2)); stemSeries2.Points.Add(new DataPoint(x, y2)); } } }
private PlotModel CreatePlot(List <XYData> peaksX, double tolerance) { var plotModel1 = new PlotModel(); plotModel1.LegendBorderThickness = 0; plotModel1.LegendOrientation = LegendOrientation.Horizontal; plotModel1.LegendPlacement = LegendPlacement.Outside; plotModel1.LegendPosition = LegendPosition.BottomCenter; plotModel1.Title = "MS/MS Spectra"; var categoryAxis1 = new LinearAxis(); categoryAxis1.MinorStep = tolerance; plotModel1.Axes.Add(categoryAxis1); var linearAxis1 = new LinearAxis(); linearAxis1.MaximumPadding = 0.06; linearAxis1.MinimumPadding = 0.06; plotModel1.Axes.Add(linearAxis1); var xseries = new StemSeries(); for (var j = 0; j < peaksX.Count; j++) { var peakX = peaksX[j]; double value = 0; if (peakX.Y > 0) { value = 1; } xseries.Points.Add(new DataPoint(peakX.X, value)); } xseries.Color = OxyColors.Green; var series = new StemSeries(); series.Title = "Spectra X"; double max = 0; foreach (var datum in peaksX) { max = Math.Max(max, datum.Y); } foreach (var datum in peaksX) { series.Points.Add(new DataPoint(datum.X, datum.Y / max)); } plotModel1.Series.Add(series); return(plotModel1); }
private void plot_ycounts_vs_time(ScatterSeries scatterSeries1, StemSeries stemSeries1, LineSeries lineSeries1) { xlabel = "Time (ms)"; ylabel = "yCounts"; reset_minmax(); for (int i = last_start; i <= last_end; i++) { double x = this.mlog.Events[i].ts; double y = this.mlog.Events[i].lasty; update_minmax(x, y); scatterSeries1.Points.Add(new ScatterPoint(x, y)); lineSeries1.Points.Add(new DataPoint(x, y)); stemSeries1.Points.Add(new DataPoint(x, y)); } }
public void TestMethod1() { var diff = new MultitapDiffuser(3000); diff.SetTapCount(50); diff.SetTapDecay(0.9); diff.SetTapGain(1.0); diff.SetTapLength((int)(2000)); var inp = new double[3000]; inp[0] = 1.0; diff.Process(inp, inp.Length); var outp = diff.Output; var pm = new PlotModel(); var series = new StemSeries(); series.MarkerSize = 1.0; series.Color = OxyColors.Black; series.Points.AddRange(outp.ToDataPoints()); pm.Series.Add(series); pm.ToPng(@"e:\multitap.png", 800, 600); }
private static Series GetPlotSeries(Signal Sig, bool sample, bool freqAmp, bool freqPhase) { StemSeries fs = new StemSeries(); for (int i = 0; i < Sig.Samples.Count; i++) { double x = i; if (sample) { fs.Points.Add(new DataPoint(Sig.SamplesIndices[i], Sig.Samples[i])); } else if (freqAmp) { fs.Points.Add(new DataPoint(Sig.Frequencies[i], Sig.FrequenciesAmplitudes[i])); } else if (freqPhase) { fs.Points.Add(new DataPoint(Sig.Frequencies[i], Sig.FrequenciesPhaseShifts[i])); } } return(fs); }
private void plot_interval_vs_time(ScatterSeries scatterSeries1, StemSeries stemSeries1, LineSeries lineSeries1) { xlabel = "Time (ms)"; ylabel = "Update Time (ms)"; reset_minmax(); for (int i = last_start; i <= last_end; i++) { double x = this.mlog.Events[i].ts; double y; if (i == 0) { y = 0.0; } else { y = this.mlog.Events[i].ts - this.mlog.Events[i - 1].ts; } update_minmax(x, y); scatterSeries1.Points.Add(new ScatterPoint(x, y)); lineSeries1.Points.Add(new DataPoint(x, y)); stemSeries1.Points.Add(new DataPoint(x, y)); } }
public static PlotModel StemSeries() { var model = new PlotModel("StemSeries") { LegendSymbolLength = 24 }; var s1 = new StemSeries("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.1) { s1.Points.Add(new DataPoint(x, Math.Sin(x))); } model.Series.Add(s1); return(model); }
private void button3_Click(object sender, EventArgs e) { if (audiolabel.Text == "AudioOff") { try { this.microphoneCapturer = CapturerFactory.CreateMicrophoneCapturer(0); int sm = this.microphoneCapturer.SampleRate; this.microphoneCapturer.AudioCaptured += new ESBasic.CbGeneric <byte[]>(microphoneCapturer_AudioCaptured); this.audioPlayer = PlayerFactory.CreateAudioPlayer(0, 16000, 1, 16, 2); this.microphoneCapturer.Start(); audiolabel.Text = "AudioOn"; audioButton.Text = "Stop"; //this.label_msg.Text = "正在采集麦克风,并播放 . . ."; //this.label_msg.Visible = true; //this.button_wav.Enabled = false; //this.button_mic.Enabled = false; //this.button_stop.Enabled = true; } catch (Exception ee) { MessageBox.Show(ee.Message); } plotmodelTemp = new PlotModel { Title = "声音" }; lineSeries = new LineSeries { Title = "Example 1", ItemsSource = datlist }; StemSeries s1 = new StemSeries { Title = "Example 1", ItemsSource = datlist }; plotmodelTemp.Series.Add(s1); audiowindow = new drawWindow(plotmodelTemp); audiowindow.Show(); } else { if (this.audioPlayer == null) { return; } if (this.microphoneCapturer != null) { this.microphoneCapturer.Stop(); this.microphoneCapturer.Dispose(); this.microphoneCapturer = null; } this.audioPlayer.Clear(); this.audioPlayer.Dispose(); this.audioPlayer = null; audiolabel.Text = "AudioOff"; audioButton.Text = "Audio"; //this.label_msg.Visible = false; //this.button_wav.Enabled = true; //this.button_mic.Enabled = true; //this.button_stop.Enabled = false; } }
/// <summary> /// Creates a plot for the given peaks list /// </summary> /// <param name="peaksX"></param> /// <param name="peaksY"></param> /// <param name="tolerance"></param> /// <returns></returns> private static PlotModel CreatePlot(IReadOnlyList<XYData> peaksX, IReadOnlyList<XYData> peaksY, double tolerance) { var plotModel1 = new PlotModel { LegendBorderThickness = 0, LegendOrientation = LegendOrientation.Horizontal, LegendPlacement = LegendPlacement.Outside, LegendPosition = LegendPosition.BottomCenter, Title = "MS/MS Spectra" }; var categoryAxis1 = new LinearAxis {MinorStep = tolerance}; plotModel1.Axes.Add(categoryAxis1); var linearAxis1 = new LinearAxis {MaximumPadding = 0.06, MinimumPadding = 0.06}; plotModel1.Axes.Add(linearAxis1); var xseries = new StemSeries(); for (var j = 0; j < peaksY.Count; j++) { var peakX = peaksX[j]; var peakY = peaksY[j]; double value = 0; if (peakX.Y > 0 && peakY.Y > 0) value = 1; xseries.Points.Add(new DataPoint(peakX.X, value)); } xseries.Color = OxyColor.FromAColor(100, OxyColors.Green); //plotModel1.Series.Add(xseries); var series = new StemSeries {Title = "Spectra X"}; var max = peaksX.Select(datum => datum.Y).Concat(new double[] {0}).Max(); foreach (var datum in peaksX) { series.Points.Add(new DataPoint(datum.X, datum.Y/max)); } plotModel1.Series.Add(series); max = peaksY.Select(datum => datum.Y).Concat(new[] {max}).Max(); var series2 = new StemSeries {Title = "Spectra Y"}; foreach (var datum in peaksY) { series2.Points.Add(new DataPoint(datum.X, (datum.Y*-1)/max)); } plotModel1.Series.Add(series2); return plotModel1; }
public static PlotModel StemSeries() { var model = new PlotModel("StemSeries") { LegendSymbolLength = 24 }; var s1 = new StemSeries("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.1) s1.Points.Add(new DataPoint(x, Math.Sin(x))); model.Series.Add(s1); return model; }
private void plotSpectrum() { SortedDictionary <float, float> unmatchedPeaks = new SortedDictionary <float, float>(); SortedDictionary <float, AnnotatedPeak> matchedPeak = new SortedDictionary <float, AnnotatedPeak>(); float smallestMz = 99999; float maxIntensity = 0; foreach (KeyValuePair <float, int> peak in currentPeakList) { if (peak.Key < smallestMz) { smallestMz = peak.Key; } if (peak.Value > maxIntensity) { maxIntensity = peak.Value; } AnnotatedPeak annotatedPeak = null; if (checkBox1.Checked) { annotatedPeak = matchLinearIon(peak, 1); } if ((annotatedPeak == null) && checkBox2.Checked) { annotatedPeak = matchLinearIon(peak, 2); } if ((annotatedPeak == null) && checkBox3.Checked) { annotatedPeak = matchLinearIon(peak, 3); } if ((annotatedPeak == null) && checkBox4.Checked) { annotatedPeak = matchXLIon(peak, 2); } if ((annotatedPeak == null) && checkBox5.Checked) { annotatedPeak = matchXLIon(peak, 3); } if ((annotatedPeak == null) && checkBox6.Checked) { annotatedPeak = matchXLIon(peak, 4); } if ((annotatedPeak == null) && checkBox7.Checked) { annotatedPeak = matchXLIon(peak, 5); } if (annotatedPeak == null) { unmatchedPeaks[peak.Key] = peak.Value; } else { matchedPeak[peak.Key] = annotatedPeak; } } PlotModel plotModel = new PlotModel { Title = String.Format("Spectrum: {0}.{1}", currentScanNum, currentCharge) }; // make the y-axis limit bigger. DataPointSeries transparntSeries = new StemSeries { MarkerType = MarkerType.None, Color = OxyColors.Transparent }; transparntSeries.Points.Add(new DataPoint(smallestMz - 1, maxIntensity * 1.1)); plotModel.Series.Add(transparntSeries); // unmatched peaks DataPointSeries unmatchedSeries = new StemSeries { MarkerType = MarkerType.None, Color = OxyColors.Gray, StrokeThickness = 0.5 }; foreach (KeyValuePair <float, float> peak in unmatchedPeaks) { unmatchedSeries.Points.Add(new DataPoint(peak.Key, peak.Value)); } plotModel.Series.Add(unmatchedSeries); // matched peaks DataPointSeries matchedSeries = new StemSeries { MarkerType = MarkerType.None, Color = OxyColors.Blue, StrokeThickness = 0.5 }; foreach (KeyValuePair <float, AnnotatedPeak> peak in matchedPeak) { matchedSeries.Points.Add(new DataPoint(peak.Key, peak.Value.intensity)); AnnotatedPeak annotatedPeak = peak.Value; string annotateText = annotatedPeak.chainType + annotatedPeak.byType + annotatedPeak.fragmentLocation; for (int i = 0; i < annotatedPeak.charge; ++i) { annotateText += "+"; } Annotation ann = new PointAnnotation { Shape = MarkerType.None, Size = 0, TextVerticalAlignment = VerticalAlignment.Bottom, X = peak.Key, Y = annotatedPeak.intensity, Text = annotateText }; plotModel.Annotations.Add(ann); } plotModel.Series.Add(matchedSeries); plotViewSpectrum.Model = plotModel; }
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; }
public void ShowFrameEvents() { // can't update if no session is selected, just keep current graph if (!SessionSelected) { if (displayedIndex == -1) { return; } Graph = framedetailGraph; Type = GraphType.FrameDetail; savedframedetailIndex = displayedIndex; SubType = " " + frameRanges[displayedIndex].Item1 + " - " + frameRanges[displayedIndex].Item2 + " "; AdditionalOption = "Frames: "; NextOption = (frameRanges[displayedIndex].Item2 < (Sessions[displayedIndex].frameStart.Count() - 1)); PrevOption = (frameRanges[displayedIndex].Item1 != 0); return; } // no need to recreate graph if current is still valid and in the correct range if (savedframedetailIndex == SelectedIndex) { Type = GraphType.FrameDetail; Graph = framedetailGraph; displayedIndex = savedframedetailIndex; EnableFrameDetail = false; SubType = " " + frameRanges[SelectedIndex].Item1 + " - " + frameRanges[SelectedIndex].Item2 + " "; AdditionalOption = "Frames: "; NextOption = (frameRanges[displayedIndex].Item2 < (Sessions[displayedIndex].frameStart.Count() - 1)); PrevOption = (frameRanges[displayedIndex].Item1 != 0); return; } System.Func <object, DataPoint> handler = myDelegate; PlotModel model = new PlotModel(); int lineRow = 0; double xAxisMinimum = 0; double xAxisMaximum = 0; var vSyncIndicators = new StemSeries { MarkerType = MarkerType.Circle }; // limit displayed frames to ~500 due to performance issues if too many frames/series are loaded into graph for (var i = frameRanges[SelectedIndex].Item1; i < Sessions[SelectedIndex].frameStart.Count() && i <= frameRanges[SelectedIndex].Item2; i++) { LineSeries series = new LineSeries(); series.Mapping = handler; List <EventDataPoint> frame = new List <EventDataPoint>(); if (Sessions[SelectedIndex].isVR) { vSyncIndicators.Points.Add(new DataPoint(Sessions[SelectedIndex].vSync[i], 300)); if (Sessions[SelectedIndex].frameStart[i] != 0) { frame.Add(new EventDataPoint(Sessions[SelectedIndex].frameStart[i], lineRow + 106, "Start frame (App)")); } if (Sessions[SelectedIndex].frameEnd[i] != 0) { frame.Add(new EventDataPoint(Sessions[SelectedIndex].frameEnd[i], lineRow + 106, "End frame (App)")); } if (Sessions[SelectedIndex].reprojectionStart[i] != 0) { frame.Add(new EventDataPoint(Sessions[SelectedIndex].reprojectionStart[i], lineRow + 106, "Start Reprojection")); } if (Sessions[SelectedIndex].reprojectionEnd[i] != 0) { frame.Add(new EventDataPoint(Sessions[SelectedIndex].reprojectionEnd[i], lineRow + 106, "End Reprojection")); } } else { if (Sessions[SelectedIndex].frameStart[i] != 0) { frame.Add(new EventDataPoint(Sessions[SelectedIndex].frameStart[i], lineRow + 106, "Start frame")); } if (Sessions[SelectedIndex].frameEnd.Count() > i && Sessions[SelectedIndex].frameEnd[i] != 0) { frame.Add(new EventDataPoint(Sessions[SelectedIndex].frameEnd[i], lineRow + 106, "Render Complete")); } if (Sessions[SelectedIndex].reprojectionEnd.Count() > i && Sessions[SelectedIndex].reprojectionEnd[i] != 0) { frame.Add(new EventDataPoint(Sessions[SelectedIndex].reprojectionEnd[i], lineRow + 106, "Displayed")); } } series.ItemsSource = frame; // at the beginning we jump to the first few frames, axis values depend on the specific session if (xAxisMinimum == 0) { xAxisMinimum = Sessions[SelectedIndex].frameStart[i]; if (xAxisMinimum == 0) { xAxisMinimum = Sessions[SelectedIndex].reprojectionStart[i]; } } if (Sessions[SelectedIndex].reprojectionEnd.Count() > i) { if (i <= frameRanges[SelectedIndex].Item1 + 3 && xAxisMaximum < Sessions[SelectedIndex].reprojectionEnd[i]) { xAxisMaximum = Sessions[SelectedIndex].reprojectionEnd[i]; } } else { // probably don't have reprojection end data here, just use frame start event timestamp if (i <= frameRanges[SelectedIndex].Item1 + 3 && xAxisMaximum < Sessions[SelectedIndex].frameStart[i]) { xAxisMaximum = Sessions[SelectedIndex].frameStart[i]; } } // toggle between two rows to prevent too much visual overlap of the frames lineRow = (lineRow + 1) % 2; series.MarkerType = MarkerType.Circle; series.ToolTip = "Frame" + i; series.Title = "Frame " + i; if (Sessions[SelectedIndex].appMissed[i]) { series.MarkerFill = OxyColors.Orange; series.Color = OxyColors.Orange; series.ToolTip += " - App Miss"; series.Title += " - App Miss"; } else if (Sessions[SelectedIndex].isVR && Sessions[SelectedIndex].warpMissed[i]) { series.MarkerFill = OxyColors.Red; series.Color = OxyColors.Red; series.ToolTip += " - Warp Miss"; series.Title += " - Warp Miss"; } else { series.MarkerFill = OxyColor.FromRgb(125, 125, 125); series.Color = OxyColor.FromRgb(0, 0, 0); } series.TrackerFormatString = "{0}\n{EventTitle}: {2:0.###}"; series.CanTrackerInterpolatePoints = false; model.Series.Add(series); } model.Series.Add(vSyncIndicators); double dis = xAxisMaximum - xAxisMinimum; dis = dis * 0.1; xAxisMaximum += dis; xAxisMinimum -= dis; LinearAxis xAxis = new LinearAxis(); xAxis.Minimum = xAxisMinimum; xAxis.Maximum = xAxisMaximum; xAxis.Position = AxisPosition.Bottom; xAxis.Title = "Timestamp of events"; xAxis.MinimumRange = 0.01; xAxis.MaximumRange = 10.0; LinearAxis yAxis = new LinearAxis(); yAxis.Minimum = 103; yAxis.Maximum = 110; yAxis.Position = AxisPosition.Left; yAxis.IsAxisVisible = false; yAxis.MinimumRange = 2.0; yAxis.MaximumRange = 10.0; model.Axes.Clear(); model.Axes.Add(xAxis); model.Axes.Add(yAxis); model.Title = "Frame events"; model.Subtitle = sessions[SelectedIndex].Filename; model.IsLegendVisible = false; Graph = model; displayedIndex = SelectedIndex; EnableFrameDetail = false; framedetailGraph = model; savedframedetailIndex = SelectedIndex; Type = GraphType.FrameDetail; NextOption = (frameRanges[displayedIndex].Item2 < (Sessions[SelectedIndex].frameStart.Count() - 1)); PrevOption = (frameRanges[SelectedIndex].Item1 != 0); SubType = " " + frameRanges[SelectedIndex].Item1 + " - " + frameRanges[SelectedIndex].Item2 + " "; AdditionalOption = "Frames: "; }
public void PlotSpectra(MSFeatureLight feature, IEnumerable<XYData> spectrum) { var series = new StemSeries { Color = OxyColors.Black }; var minimumMz = double.MaxValue; var maximumMz = double.MinValue; var maxAbundance = double.MinValue; if (spectrum.Count() < 1) return; foreach (var peak in spectrum) { minimumMz = Math.Min(peak.X, minimumMz); maximumMz = Math.Max(peak.X, maximumMz); maxAbundance = Math.Max(maxAbundance, peak.Y); series.Points.Add(new DataPoint(peak.X, peak.Y)); } var maxAbundanceTop = maxAbundance*.5; Model.Axes[0].AbsoluteMinimum = minimumMz; Model.Axes[0].AbsoluteMaximum = maximumMz; Model.Series.Add(series); // Add in the monoisotopic peak var colors = new ColorTypeIterator(); var chargeColor = colors.GetColor(feature.ChargeState); var msFeature = new StemSeries { Color = chargeColor }; msFeature.Points.Add(new DataPoint(feature.Mz, feature.Abundance)); Model.Series.Add(msFeature); // Add in the rest of the isotopes var alphaColor = OxyColor.FromAColor(100, OxyColors.Red); var charge = feature.ChargeState; var mz = feature.Mz; var abundance = Convert.ToDouble(feature.Abundance); var monoPeakAnnotation = new LineAnnotation { Type = LineAnnotationType.Vertical, X = mz, Color = alphaColor, TextColor = alphaColor, Text = string.Format("mono peak: {0} m/z", mz.ToString("F3")) }; Model.Annotations.Add(monoPeakAnnotation); var lastMz = mz; var spacing = 1.0/charge; while (mz < maximumMz && abundance > 1) { mz = mz + (1.0/charge); abundance *= .75; var peakAnnotation = new LineAnnotation { Type = LineAnnotationType.Vertical, X = mz, Color = alphaColor, TextColor = alphaColor, Text = string.Format("{0} m/z", mz.ToString("F3")) }; var spaceAnnotation = new LineAnnotation { Type = LineAnnotationType.Horizontal, Color = alphaColor, TextColor = alphaColor, TextHorizontalAlignment = HorizontalAlignment.Center, TextVerticalAlignment = VerticalAlignment.Top, TextPosition = new DataPoint(.5, 0), MinimumX = lastMz, MaximumX = mz, Text = string.Format("d={0}", spacing.ToString("F2")), Y = maxAbundance*.75 }; maxAbundance *= .75; lastMz = mz; Model.Annotations.Add(spaceAnnotation); Model.Annotations.Add(peakAnnotation); } if (feature.ParentFeature != null) { var features = feature.ParentFeature.Features; foreach (var subFeature in features) { var msms = subFeature.MSnSpectra.Where(x => x.PrecursorMz > minimumMz && x.PrecursorMz < maximumMz); foreach (var fragmentation in msms) { var spaceAnnotation = new LineAnnotation { Type = LineAnnotationType.Vertical, Color = OxyColors.Gray, TextColor = OxyColors.Gray, FontWeight = 3, TextVerticalAlignment = VerticalAlignment.Top, TextPosition = new DataPoint(1, 0), StrokeThickness = 2, Text = string.Format("msms {0} - scan {1}", fragmentation.PrecursorMz.ToString("F2"), fragmentation.Scan), X = fragmentation.PrecursorMz }; Model.Annotations.Add(spaceAnnotation); var lowerMz = new LineAnnotation { Type = LineAnnotationType.Horizontal, Color = OxyColors.LightGray, TextColor = OxyColors.LightGray, FontWeight = 3, TextVerticalAlignment = VerticalAlignment.Top, TextPosition = new DataPoint(1, 0), StrokeThickness = 2, Y = maxAbundanceTop, Text = string.Format("{0} m/z", MsmsDistanceLower.ToString("F2")), MinimumX = fragmentation.PrecursorMz - MsmsDistanceLower, MaximumX = fragmentation.PrecursorMz }; var upperMz = new LineAnnotation { Type = LineAnnotationType.Horizontal, Color = OxyColors.LightGray, TextColor = OxyColors.LightGray, FontWeight = 3, TextVerticalAlignment = VerticalAlignment.Top, TextPosition = new DataPoint(1, 0), StrokeThickness = 2, Text = string.Format("{0} m/z", MsmsDistanceUpper.ToString("F2")), Y = maxAbundanceTop, MinimumX = fragmentation.PrecursorMz, MaximumX = fragmentation.PrecursorMz + MsmsDistanceUpper }; Model.Annotations.Add(upperMz); Model.Annotations.Add(lowerMz); } } } }
public void PlotSpectra(MSFeatureLight feature, IEnumerable <XYData> spectrum) { var series = new StemSeries { Color = OxyColors.Black }; var minimumMz = double.MaxValue; var maximumMz = double.MinValue; var maxAbundance = double.MinValue; if (spectrum.Count() < 1) { return; } foreach (var peak in spectrum) { minimumMz = Math.Min(peak.X, minimumMz); maximumMz = Math.Max(peak.X, maximumMz); maxAbundance = Math.Max(maxAbundance, peak.Y); series.Points.Add(new DataPoint(peak.X, peak.Y)); } var maxAbundanceTop = maxAbundance * .5; Model.Axes[0].AbsoluteMinimum = minimumMz; Model.Axes[0].AbsoluteMaximum = maximumMz; Model.Series.Add(series); // Add in the monoisotopic peak var colors = new ColorTypeIterator(); var chargeColor = colors.GetColor(feature.ChargeState); var msFeature = new StemSeries { Color = chargeColor }; msFeature.Points.Add(new DataPoint(feature.Mz, feature.Abundance)); Model.Series.Add(msFeature); // Add in the rest of the isotopes var alphaColor = OxyColor.FromAColor(100, OxyColors.Red); var charge = feature.ChargeState; var mz = feature.Mz; var abundance = Convert.ToDouble(feature.Abundance); var monoPeakAnnotation = new LineAnnotation { Type = LineAnnotationType.Vertical, X = mz, Color = alphaColor, TextColor = alphaColor, Text = string.Format("mono peak: {0} m/z", mz.ToString("F3")) }; Model.Annotations.Add(monoPeakAnnotation); var lastMz = mz; var spacing = 1.0 / charge; while (mz < maximumMz && abundance > 1) { mz = mz + (1.0 / charge); abundance *= .75; var peakAnnotation = new LineAnnotation { Type = LineAnnotationType.Vertical, X = mz, Color = alphaColor, TextColor = alphaColor, Text = string.Format("{0} m/z", mz.ToString("F3")) }; var spaceAnnotation = new LineAnnotation { Type = LineAnnotationType.Horizontal, Color = alphaColor, TextColor = alphaColor, TextHorizontalAlignment = HorizontalAlignment.Center, TextVerticalAlignment = VerticalAlignment.Top, TextPosition = new DataPoint(.5, 0), MinimumX = lastMz, MaximumX = mz, Text = string.Format("d={0}", spacing.ToString("F2")), Y = maxAbundance * .75 }; maxAbundance *= .75; lastMz = mz; Model.Annotations.Add(spaceAnnotation); Model.Annotations.Add(peakAnnotation); } if (feature.GetParentFeature() != null) { var features = feature.GetParentFeature().Features; foreach (var subFeature in features) { var msms = subFeature.MSnSpectra.Where(x => x.PrecursorMz > minimumMz && x.PrecursorMz < maximumMz); foreach (var fragmentation in msms) { var spaceAnnotation = new LineAnnotation { Type = LineAnnotationType.Vertical, Color = OxyColors.Gray, TextColor = OxyColors.Gray, FontWeight = 3, TextVerticalAlignment = VerticalAlignment.Top, TextPosition = new DataPoint(1, 0), StrokeThickness = 2, Text = string.Format("msms {0} - scan {1}", fragmentation.PrecursorMz.ToString("F2"), fragmentation.Scan), X = fragmentation.PrecursorMz }; Model.Annotations.Add(spaceAnnotation); var lowerMz = new LineAnnotation { Type = LineAnnotationType.Horizontal, Color = OxyColors.LightGray, TextColor = OxyColors.LightGray, FontWeight = 3, TextVerticalAlignment = VerticalAlignment.Top, TextPosition = new DataPoint(1, 0), StrokeThickness = 2, Y = maxAbundanceTop, Text = string.Format("{0} m/z", MsmsDistanceLower.ToString("F2")), MinimumX = fragmentation.PrecursorMz - MsmsDistanceLower, MaximumX = fragmentation.PrecursorMz }; var upperMz = new LineAnnotation { Type = LineAnnotationType.Horizontal, Color = OxyColors.LightGray, TextColor = OxyColors.LightGray, FontWeight = 3, TextVerticalAlignment = VerticalAlignment.Top, TextPosition = new DataPoint(1, 0), StrokeThickness = 2, Text = string.Format("{0} m/z", MsmsDistanceUpper.ToString("F2")), Y = maxAbundanceTop, MinimumX = fragmentation.PrecursorMz, MaximumX = fragmentation.PrecursorMz + MsmsDistanceUpper }; Model.Annotations.Add(upperMz); Model.Annotations.Add(lowerMz); } } } }
private void refresh_plot() { PlotModel pm = plot1.Model; pm.Series.Clear(); pm.Axes.Clear(); var scatterSeries1 = new ScatterSeries { BinSize = 8, MarkerFill = OxyColors.Blue, MarkerSize = 2.0, MarkerStroke = OxyColors.Blue, MarkerStrokeThickness = 1.0, MarkerType = MarkerType.Circle }; var scatterSeries2 = new ScatterSeries { BinSize = 8, MarkerFill = OxyColors.Red, MarkerSize = 2.0, MarkerStroke = OxyColors.Red, MarkerStrokeThickness = 1.0, MarkerType = MarkerType.Circle }; var lineSeries1 = new LineSeries { Color = OxyColors.Blue, LineStyle = LineStyle.Solid, StrokeThickness = 1.0, Smooth = true }; var lineSeries2 = new LineSeries { Color = OxyColors.Red, LineStyle = LineStyle.Solid, StrokeThickness = 1.0, Smooth = true }; if (checkBoxLines.Checked) { lineSeries1.Smooth = false; lineSeries2.Smooth = false; } var stemSeries1 = new StemSeries { Color = OxyColors.Blue, StrokeThickness = 1.0, }; var stemSeries2 = new StemSeries { Color = OxyColors.Red, StrokeThickness = 1.0 }; if (comboBoxPlotType.Text.Contains("xCount")) { plot_xcounts_vs_time(scatterSeries1, stemSeries1, lineSeries1, scatterSeries2, stemSeries2, lineSeries2); pm.Series.Add(scatterSeries1); pm.Series.Add(scatterSeries2); if (!checkBoxLines.Checked) { plot_fit(scatterSeries1, lineSeries1); plot_fit(scatterSeries2, lineSeries2); } pm.Series.Add(lineSeries1); pm.Series.Add(lineSeries2); if (checkBoxStem.Checked) { pm.Series.Add(stemSeries1); pm.Series.Add(stemSeries2); } } else if (comboBoxPlotType.Text.Contains("yCount")) { plot_ycounts_vs_time(scatterSeries1, stemSeries1, lineSeries1, scatterSeries2, stemSeries2, lineSeries2); pm.Series.Add(scatterSeries1); pm.Series.Add(scatterSeries2); if (!checkBoxLines.Checked) { plot_fit(scatterSeries1, lineSeries1); plot_fit(scatterSeries2, lineSeries2); } pm.Series.Add(lineSeries1); pm.Series.Add(lineSeries2); if (checkBoxStem.Checked) { pm.Series.Add(stemSeries1); pm.Series.Add(stemSeries2); } } else if (comboBoxPlotType.Text.Contains("xSum")) { plot_xsum_vs_time(scatterSeries1, stemSeries1, lineSeries1, scatterSeries2, stemSeries2, lineSeries2); pm.Series.Add(scatterSeries1); pm.Series.Add(scatterSeries2); if (!checkBoxLines.Checked) { plot_fit(scatterSeries1, lineSeries1); plot_fit(scatterSeries2, lineSeries2); } pm.Series.Add(lineSeries1); pm.Series.Add(lineSeries2); if (checkBoxStem.Checked) { pm.Series.Add(stemSeries1); pm.Series.Add(stemSeries2); } } else if (comboBoxPlotType.Text.Contains("ySum")) { plot_ysum_vs_time(scatterSeries1, stemSeries1, lineSeries1, scatterSeries2, stemSeries2, lineSeries2); pm.Series.Add(scatterSeries1); pm.Series.Add(scatterSeries2); if (!checkBoxLines.Checked) { plot_fit(scatterSeries1, lineSeries1); plot_fit(scatterSeries2, lineSeries2); } pm.Series.Add(lineSeries1); pm.Series.Add(lineSeries2); if (checkBoxStem.Checked) { pm.Series.Add(stemSeries1); pm.Series.Add(stemSeries2); } } else if (comboBoxPlotType.Text.Contains("X vs. Y")) { plot_x_vs_y(scatterSeries1, lineSeries1, scatterSeries2, lineSeries2); pm.Series.Add(scatterSeries1); pm.Series.Add(scatterSeries2); if (checkBoxLines.Checked) { pm.Series.Add(lineSeries1); pm.Series.Add(lineSeries2); } } var linearAxis1 = new LinearAxis(); linearAxis1.AbsoluteMinimum = x_min - (x_max - x_min + 1) / 20.0; linearAxis1.AbsoluteMaximum = x_max + (x_max - x_min + 1) / 20.0; linearAxis1.MajorGridlineColor = OxyColor.FromArgb(40, 0, 0, 139); linearAxis1.MajorGridlineStyle = LineStyle.Solid; linearAxis1.MinorGridlineColor = OxyColor.FromArgb(20, 0, 0, 139); linearAxis1.MinorGridlineStyle = LineStyle.Solid; linearAxis1.Position = AxisPosition.Bottom; linearAxis1.Title = xlabel; pm.Axes.Add(linearAxis1); var linearAxis2 = new LinearAxis(); linearAxis2.AbsoluteMinimum = y_min - (y_max - y_min + 1) / 20.0; linearAxis2.AbsoluteMaximum = y_max + (y_max - y_min + 1) / 20.0; linearAxis2.MajorGridlineColor = OxyColor.FromArgb(40, 0, 0, 139); linearAxis2.MajorGridlineStyle = LineStyle.Solid; linearAxis2.MinorGridlineColor = OxyColor.FromArgb(20, 0, 0, 139); linearAxis2.MinorGridlineStyle = LineStyle.Solid; linearAxis2.Title = ylabel; pm.Axes.Add(linearAxis2); plot1.RefreshPlot(true); }
public void AddRolls(DiceRoll roll, string title, OxyColor?c = null, bool show_expected = false, bool stem = true, MarkerType marker_type = MarkerType.Cross) { OxyColor colour; if (c == null) { colour = NextColour(); } else { colour = c.Value; } var points = new List <DataPoint> (); for (int i = roll.Min(); i <= roll.Max(); i++) { if (roll.rolls.ContainsKey(i)) { points.Add(new DataPoint(i, (double)roll.rolls[i])); } else if (!stem) { points.Add(new DataPoint(i, 0)); } } if (show_expected) { LineAnnotation Line = new LineAnnotation() { StrokeThickness = 2, Color = colour, Type = LineAnnotationType.Vertical, Text = "Expected", TextColor = colour, X = (double)roll.Expected(), //Y = 0.0f }; Model.Annotations.Add(Line); } if (stem) { var series = new StemSeries { MarkerStroke = colour, MarkerSize = 3, MarkerFill = colour, MarkerType = marker_type, StrokeThickness = 0, //Smooth = true, Color = colour, Title = title }; series.MarkerStroke = series.Color; series.Points.AddRange(points); Model.Series.Add(series); } else { var series = new LineSeries { MarkerType = marker_type, MarkerSize = 7, StrokeThickness = 0, //Smooth = true, Color = colour, Title = title }; series.Points.AddRange(points); Model.Series.Add(series); } }
private PlotModel GetPlotModel(PrSm id) { var lcms = id.LcMs; var fragSequence = id.GetFragmentationSequence(); var msLevel = lcms.GetMsLevel(id.Scan); var fragments = msLevel == 2 ? fragSequence.GetFragmentLabels(ionTypes.Where(ionType => ionType.Charge <= id.Charge).ToList()) : fragSequence.GetChargePrecursorLabels(); var spectrum = lcms.GetSpectrum(id.Scan, true); // Set up plot var plotModel = new PlotModel { Title = msLevel == 2 ? string.Format("MS/MS Scan {0}", id.Scan) : string.Format("MS Scan {0}", id.Scan), IsLegendVisible = false, }; // Add axes var xaxis = new LinearAxis { Title = "M/Z", Position = AxisPosition.Bottom }; var yaxis = new LinearAxis { Title = "Intensity", Position = AxisPosition.Left, Minimum = 0 }; plotModel.Axes.Add(xaxis); plotModel.Axes.Add(yaxis); // Add spectrum peaks var spectrumPeaks = spectrum.Peaks.Select(peak => new PeakDataPoint(peak.Mz, peak.Intensity, 0.0, 0.0, string.Empty)); var spectrumStemSeries = new StemSeries { ItemsSource = spectrumPeaks, Color = OxyColors.Black, StrokeThickness = 0.5, }; plotModel.Series.Add(spectrumStemSeries); // Add ion highlights var colors = new IonColorDictionary(id.Charge); foreach (var fragment in fragments) { var points = fragment.GetPeaks(spectrum, false, false); if (points.Count == 0 || points[0].Error.Equals(double.NaN)) { continue; } var firstPoint = points[0]; var color = firstPoint.IonType != null?colors.GetColor(firstPoint.IonType.BaseIonType, firstPoint.IonType.Charge) : colors.GetColor(firstPoint.Index); var ionSeries = new PeakPointSeries { Color = color, StrokeThickness = 1.5, ItemsSource = points, Title = points[0].Title, }; // Create ion name annotation var annotation = new TextAnnotation { Text = points[0].Title, TextColor = color, FontWeight = FontWeights.Bold, Layer = AnnotationLayer.AboveSeries, FontSize = 12, Background = OxyColors.White, Padding = new OxyThickness(0.1), TextPosition = new DataPoint(points[0].X, points[0].Y), StrokeThickness = 0 }; plotModel.Series.Add(ionSeries); plotModel.Annotations.Add(annotation); } return(plotModel); }
private PlotModel CreateMsMsPlot(List <MsMsSearchResult> searchResultList, ProductSpectrum productSpectrum) { var spectrumSearchResult = CurrentSpectrumSearchResult; var lipidTarget = CurrentLipidTarget; var commonName = lipidTarget.StrippedDisplay; var parentScan = spectrumSearchResult.PrecursorSpectrum?.ScanNum ?? 0; var peakList = productSpectrum.Peaks; var fragmentationType = productSpectrum.ActivationMethod == ActivationMethod.CID ? FragmentationType.CID : FragmentationType.HCD; if (!peakList.Any()) { return(new PlotModel()); } var plotTitle = commonName + "\nMS/MS Spectrum - " + productSpectrum.ActivationMethod + " - " + productSpectrum.ScanNum + " // Precursor Scan - " + parentScan + " (" + productSpectrum.IsolationWindow.IsolationWindowTargetMz.ToString("0.0000") + " m/z)"; var plotModel = new PlotModel { Title = plotTitle, TitleFontSize = 14, Padding = new OxyThickness(0), PlotMargins = new OxyThickness(0) }; var mzPeakSeries = new StemSeries { Color = OxyColors.Black, StrokeThickness = 0.5, Title = "Peaks" }; var annotatedPeakSeries = new StemSeries { Color = OxyColors.Green, StrokeThickness = 2, Title = "Matched Ions" }; var diagnosticPeakSeries = new StemSeries { Color = OxyColors.Red, StrokeThickness = 2, Title = "Diagnostic Ion" }; plotModel.IsLegendVisible = true; plotModel.LegendPosition = LegendPosition.TopRight; plotModel.LegendPlacement = LegendPlacement.Inside; plotModel.LegendMargin = 0; plotModel.LegendFontSize = 10; var minMz = double.MaxValue; var maxMz = double.MinValue; var maxIntensity = double.MinValue; var secondMaxIntensity = double.MinValue; foreach (var msPeak in peakList) { var mz = msPeak.Mz; var intensity = msPeak.Intensity; if (mz < minMz) { minMz = mz; } if (mz > maxMz) { maxMz = mz; } if (intensity > maxIntensity) { secondMaxIntensity = maxIntensity; maxIntensity = intensity; } else if (intensity > secondMaxIntensity) { secondMaxIntensity = intensity; } var dataPoint = new DataPoint(mz, intensity); var isDiagnostic = false; var matchedPeaks = searchResultList.Where(x => x.ObservedPeak.Equals(msPeak)).ToList(); foreach (var matchedSearchResult in matchedPeaks) { var annotation = new MsMsAnnotation(fragmentationType) { Text = matchedSearchResult.TheoreticalPeak.DescriptionForUi, TextColor = OxyColors.Blue, TextPosition = dataPoint, TextVerticalAlignment = VerticalAlignment.Middle, TextHorizontalAlignment = HorizontalAlignment.Left, TextRotation = -90, StrokeThickness = 0, Offset = new ScreenVector(0, -5), Selectable = true }; plotModel.Annotations.Add(annotation); MsMsAnnotationList.Add(annotation); if (!isDiagnostic) { isDiagnostic = matchedSearchResult.TheoreticalPeak.IsDiagnostic; } } if (isDiagnostic) { diagnosticPeakSeries.Points.Add(dataPoint); } else if (matchedPeaks.Any()) { annotatedPeakSeries.Points.Add(dataPoint); } else { mzPeakSeries.Points.Add(dataPoint); } } plotModel.Series.Add(mzPeakSeries); plotModel.Series.Add(annotatedPeakSeries); plotModel.Series.Add(diagnosticPeakSeries); var yAxis = new LinearAxis { Position = AxisPosition.Left, Title = "Intensity", Minimum = 0, AbsoluteMinimum = 0 }; //yAxis.Maximum = maxIntensity + (maxIntensity * .05); //yAxis.AbsoluteMaximum = maxIntensity + (maxIntensity * .05); if (secondMaxIntensity > 0) { yAxis.Maximum = secondMaxIntensity + secondMaxIntensity * .25; yAxis.AbsoluteMaximum = maxIntensity + maxIntensity * .25; yAxis.MinorTickSize = MINOR_TICK_SIZE; yAxis.MajorStep = (secondMaxIntensity + secondMaxIntensity * .25) / 5.0; yAxis.StringFormat = "0.0E00"; } else if (maxIntensity > 0) { yAxis.Maximum = maxIntensity + maxIntensity * .25; yAxis.AbsoluteMaximum = maxIntensity + maxIntensity * .25; yAxis.MinorTickSize = MINOR_TICK_SIZE; yAxis.MajorStep = (maxIntensity + maxIntensity * .25) / 5.0; yAxis.StringFormat = "0.0E00"; } else { yAxis.Maximum = 1; yAxis.AbsoluteMaximum = 1; yAxis.MinorTickSize = 0; yAxis.MajorStep = 1; yAxis.StringFormat = "0.0"; } yAxis.AxisChanged += OnYAxisChange; var xAxis = new LinearAxis { Position = AxisPosition.Bottom, Title = "m/z", Minimum = minMz - 20, AbsoluteMinimum = minMz - 20, Maximum = maxMz + 20, AbsoluteMaximum = maxMz + 20 }; plotModel.Axes.Add(yAxis); plotModel.Axes.Add(xAxis); return(plotModel); }
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; }
/// <summary> /// Creates a plot for the given peaks list /// </summary> /// <param name="peaksX"></param> /// <param name="peaksY"></param> /// <param name="tolerance"></param> /// <returns></returns> private static PlotModel CreatePlot(IReadOnlyList <XYData> peaksX, IReadOnlyList <XYData> peaksY, double tolerance) { var plotModel1 = new PlotModel { LegendBorderThickness = 0, LegendOrientation = LegendOrientation.Horizontal, LegendPlacement = LegendPlacement.Outside, LegendPosition = LegendPosition.BottomCenter, Title = "MS/MS Spectra" }; var categoryAxis1 = new LinearAxis { MinorStep = tolerance }; plotModel1.Axes.Add(categoryAxis1); var linearAxis1 = new LinearAxis { MaximumPadding = 0.06, MinimumPadding = 0.06 }; plotModel1.Axes.Add(linearAxis1); var xseries = new StemSeries(); for (var j = 0; j < peaksY.Count; j++) { var peakX = peaksX[j]; var peakY = peaksY[j]; double value = 0; if (peakX.Y > 0 && peakY.Y > 0) { value = 1; } xseries.Points.Add(new DataPoint(peakX.X, value)); } xseries.Color = OxyColor.FromAColor(100, OxyColors.Green); //plotModel1.Series.Add(xseries); var series = new StemSeries { Title = "Spectra X" }; var max = peaksX.Select(datum => datum.Y).Concat(new double[] { 0 }).Max(); foreach (var datum in peaksX) { series.Points.Add(new DataPoint(datum.X, datum.Y / max)); } plotModel1.Series.Add(series); max = peaksY.Select(datum => datum.Y).Concat(new[] { max }).Max(); var series2 = new StemSeries { Title = "Spectra Y" }; foreach (var datum in peaksY) { series2.Points.Add(new DataPoint(datum.X, (datum.Y * -1) / max)); } plotModel1.Series.Add(series2); return(plotModel1); }
/// <summary> /// Creates a plot for the given peaks list /// </summary> /// <param name="peaksX"></param> /// <param name="peaksY"></param> /// <param name="tolerance"></param> /// <returns></returns> private PlotModel CreatePlot(List<XYData> peaksX, List<XYData> peaksY, double tolerance) { var plotModel1 = new PlotModel(); plotModel1.LegendBorderThickness = 0; plotModel1.LegendOrientation = LegendOrientation.Horizontal; plotModel1.LegendPlacement = LegendPlacement.Outside; plotModel1.LegendPosition = LegendPosition.BottomCenter; plotModel1.Title = "MS/MS Spectra"; var categoryAxis1 = new LinearAxis(); categoryAxis1.MinorStep = tolerance; plotModel1.Axes.Add(categoryAxis1); var linearAxis1 = new LinearAxis(); linearAxis1.MaximumPadding = 0.06; linearAxis1.MinimumPadding = 0.06; plotModel1.Axes.Add(linearAxis1); var xseries = new StemSeries(); for (var j = 0; j < peaksY.Count; j++) { var peakX = peaksX[j]; var peakY = peaksY[j]; double value = 0; if (peakX.Y > 0 && peakY.Y > 0) { value = 1; } xseries.Points.Add(new DataPoint(peakX.X, value)); } xseries.Color = OxyColors.Green; //plotModel1.Series.Add(xseries); var series = new StemSeries(); series.Title = "Spectra X"; double max = 0; foreach (var datum in peaksX) { max = Math.Max(max, datum.Y); } foreach (var datum in peaksX) { series.Points.Add(new DataPoint(datum.X, datum.Y/max)); } plotModel1.Series.Add(series); foreach (var datum in peaksY) { max = Math.Max(max, datum.Y); } var series2 = new StemSeries(); series2.Title = "Spectra Y"; foreach (var datum in peaksY) { series2.Points.Add(new DataPoint(datum.X, (datum.Y*-1)/max)); } plotModel1.Series.Add(series2); return plotModel1; }
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; }