wpf oxyPlot 峰值画线标注 | 您所在的位置:网站首页 › word如何划线标注 › wpf oxyPlot 峰值画线标注 |
public ObservableCollection dpList { get; set; } = new ObservableCollection(); public ObservableCollection ReferenceDpList { get; set; } = new ObservableCollection(); void CallbackFunction(IntPtr tick, int length) { try { if (length X = 190; } else { X = Convert.ToDouble((X + 0.2).ToString("N2")); //保留2位小数 } i += 2; } Thread.Sleep(500); PlotModel plotModel = new PlotModel { PlotType = PlotType.Cartesian, PlotAreaBorderThickness = new OxyThickness(1, 0, 0, 1), }; var l = new Legend { LegendPosition = LegendPosition.TopLeft, LegendOrientation = LegendOrientation.Horizontal, LegendPlacement = LegendPlacement.Outside }; plotModel.Legends.Add(l); var linearAxis1 = new OxyPlot.Axes.LinearAxis() { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Position = OxyPlot.Axes.AxisPosition.Left, Title = Util.FindKey("Result_Absorbance"), Minimum = dList.Min(), Maximum = dList.Max() + (dList.Max() - dList.Min()) / 25, AbsoluteMinimum = dList.Min(), AbsoluteMaximum = dList.Max() + (dList.Max() - dList.Min()) / 25, MajorStep = (dList.Max() - dList.Min()) / 5, IsZoomEnabled = false,//坐标轴缩放关闭 IsPanEnabled = false,//图表缩放功能关闭 }; plotModel.Axes.Add(linearAxis1); var linearAxis2 = new OxyPlot.Axes.LinearAxis() { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Position = OxyPlot.Axes.AxisPosition.Bottom, Minimum = 190, Maximum = 1100.2, AbsoluteMaximum = 1100.2, AbsoluteMinimum = 190, MajorStep = (1100 - 190) / 5, IsZoomEnabled = false,//坐标轴缩放关闭 IsPanEnabled = false,//图表缩放功能关闭 }; plotModel.Axes.Add(linearAxis2); if (dpList?.Count > 0) { var series3 = new LineSeries { MarkerType = MarkerType.None, CanTrackerInterpolatePoints = false, Title = Util.FindKey("Maintain_LightIntensity"), }; List P_229 = new List(); List P_484 = new List(); List P_882 = new List(); foreach (var item in dpList) { if (item.X >= 219 && item.X P_484.Add(item); } else if (item.X >= 872 && item.X double y = P_229.Max(a => a.Y); double x = P_229.FirstOrDefault(b => b.Y == y).X; LineAnnotation annoHorizontal = new LineAnnotation(); annoHorizontal.Type = LineAnnotationType.Vertical; annoHorizontal.X = x; annoHorizontal.Text = "X:" + x + "\tY:" + y; annoHorizontal.TextLinePosition = 0.01; annoHorizontal.TextOrientation = AnnotationTextOrientation.Horizontal; annoHorizontal.TextHorizontalAlignment = OxyPlot.HorizontalAlignment.Left; plotModel.Annotations.Add(annoHorizontal); } if (P_484?.Count > 0) { double y = P_484.Max(a => a.Y); double x = P_484.FirstOrDefault(b => b.Y == y).X; LineAnnotation annoHorizontal = new LineAnnotation(); annoHorizontal.Type = LineAnnotationType.Vertical; annoHorizontal.X = x; annoHorizontal.Text = "X:" + x + "\tY:" + y; annoHorizontal.TextLinePosition = 0.01; annoHorizontal.TextOrientation = AnnotationTextOrientation.Horizontal; annoHorizontal.TextHorizontalAlignment = OxyPlot.HorizontalAlignment.Left; plotModel.Annotations.Add(annoHorizontal); } if (P_882?.Count > 0) { double y = P_882.Max(a => a.Y); double x = P_882.FirstOrDefault(b => b.Y == y).X; LineAnnotation annoHorizontal = new LineAnnotation(); annoHorizontal.Type = LineAnnotationType.Vertical; annoHorizontal.X = x; annoHorizontal.Text = "X:" + x + "\tY:" + y; annoHorizontal.TextLinePosition = 0.01; annoHorizontal.TextOrientation = AnnotationTextOrientation.Horizontal; annoHorizontal.TextHorizontalAlignment = OxyPlot.HorizontalAlignment.Left; plotModel.Annotations.Add(annoHorizontal); } plotModel.Series.Add(series3);//将线添加到图标的容器中 } if (ReferenceDpList?.Count > 0) { var series4 = new LineSeries { MarkerType = MarkerType.None, CanTrackerInterpolatePoints = false, Title = Util.FindKey("Maintain_Reference"), }; foreach (var item in ReferenceDpList) { series4.Points.Add(new DataPoint(item.X, item.Y)); } plotModel.Series.Add(series4);//将线添加到图标的容器中 } System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { UcSettingsContentView.view.pv.Model = plotModel; if (WaveLength > 0) { var model = dpList.FirstOrDefault(x => x.X == WaveLength); ABS = model.Y.ToString(); } WeakReferenceMessenger.Default.Send("Close"); })); } catch (Exception ex) { WeakReferenceMessenger.Default.Send("Close"); LogUtil.LogError(ex); } } |
今日新闻 |
推荐新闻 |
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 |