public void AddToPlotdB(IEnumerable <double> x, IEnumerable <double> y, string title, int index) { //modifying the series collection will animate and update the chart ChartValues <ObservablePoint> nove = new ChartValues <ObservablePoint>(); ObservablePoint[] points = new ObservablePoint[x.Count()]; for (var i = 0; i < x.Count(); ++i) { points[i] = new ObservablePoint { X = x.ElementAt(i), Y = 20 * Math.Log10(y.ElementAt(i)) }; } nove.AddRange(points); if (SeriesCollection.Count < index + 1) { SeriesCollection.Add(new LineSeries()); } SeriesCollection.CurrentSeriesIndex = index; if (index == 0 && SeriesCollection.Count > 1) { SeriesCollection.RemoveAt(1); } SeriesCollection[index] = (new LineSeries { Title = title, Values = nove.AsGearedValues().WithQuality(Quality.Medium), LineSmoothness = 0, //0: straight lines, 1: really smooth lines //PointGeometry = Geometry.Parse("m 25 70.36218 20 -28 -20 22 -8 -6 z"), PointGeometry = DefaultGeometries.Circle, PointGeometrySize = 1, Fill = Brushes.Transparent }); }
/// <summary> /// 添加曲线 /// </summary> /// <param name="curve">曲线</param> /// <param name="name">曲线名</param> public void Add(Curve curve, string name) { ChartValues <ObservablePoint> values = new ChartValues <ObservablePoint>(); Point[] data = curve.GetData(); for (int i = 0; i < data.Length; i++) { values.Add(new ObservablePoint(data[i].X, data[i].Y)); } chart.Series.Add(new GLineSeries { Title = name, Values = values.AsGearedValues().WithQuality(Quality.Low), Fill = Brushes.Transparent, LineSmoothness = 0, //0对应纯直线,若为1则是插件自动生成的顺滑曲线 StrokeThickness = .5, PointGeometry = null }); }