public void AddLines(ChartStyle cs) { int j = 0; foreach (DataSeries ds in DataList) { if (ds.SeriesName == "Default Name") { ds.SeriesName = "DataSeries" + j.ToString(); } ds.AddLinePattern(); for (int i = 0; i < ds.LineSeries.Points.Count; i++) { ds.LineSeries.Points[i] = cs.NormalizePoint(ds.LineSeries.Points[i]); ds.Symbols.AddSymbol(cs.ChartCanvas, ds.LineSeries.Points[i]); } cs.ChartCanvas.Children.Add(ds.LineSeries); j++; } }
private void AddChart() { cs = new ChartStyle(); cs.ChartCanvas = chartCanvas; dc = new DataCollection(); cs.Xmin = 0; cs.Xmax = 7; cs.Ymin = -1.1; cs.Ymax = 1.1; // Draw Sine curve: ds = new DataSeries(); ds.LineColor = Brushes.Blue; ds.LineThickness = 2; for (int i = 0; i < 50; i++) { double x = i / 5.0; double y = Math.Sin(x); ds.LineSeries.Points.Add(new Point(x, y)); } dc.DataList.Add(ds); // Draw cosine curve: ds = new DataSeries(); ds.LineColor = Brushes.Red; ds.LinePattern = DataSeries.LinePatternEnum.DashDot; ds.LineThickness = 2; for (int i = 0; i < 50; i++) { double x = i / 5.0; double y = Math.Cos(x); ds.LineSeries.Points.Add(new Point(x, y)); } dc.DataList.Add(ds); dc.AddLines(cs); }