private void AddData(LineChartControlLib myLineChart) { myLineChart.DataCollection.DataList.Clear(); DataSeries ds=new DataSeries { LineColor = Brushes.Blue, LineThickness = 1, SeriesName = "Sine" }; ds.Symbols = new CircleSymbols { BorderColor = ds.LineColor, SymbolSize = 6 }; for (int i = 0; i < 15; i++) { double x = i/2.0; double y = Math.Sin(x); ds.LineSeries.Points.Add(new Point(x,y)); } myLineChart.DataCollection.DataList.Add(ds); ds=new DataSeries { LineColor = Brushes.Red, SeriesName = "Cosine" }; ds.Symbols = new OpenDiamondSymbols { BorderColor = ds.LineColor, SymbolSize = 6 }; for (int i = 0; i < 15; i++) { double x = i / 2.0; double y = Math.Cos(x); ds.LineSeries.Points.Add(new Point(x, y)); } myLineChart.DataCollection.DataList.Add(ds); myLineChart.IsLegend = true; myLineChart.LegendPosition = LegendPosition.NorthEast; }
private static void OnPropetyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { LineChartControlLib lib = sender as LineChartControlLib; if (lib == null) { return; } if (e.Property == XminProperty) { lib.Xmin = (double)e.NewValue; } else if (e.Property == XmaxProperty) { lib.Xmax = (double)e.NewValue; } else if (e.Property == YminProperty) { lib.Ymin = (double)e.NewValue; } else if (e.Property == YmaxProperty) { lib.Ymax = (double)e.NewValue; } else if (e.Property == XTickProperty) { lib.XTick = (double)e.NewValue; } else if (e.Property == YTickProperty) { lib.YTick = (double)e.NewValue; } else if (e.Property == LinePatternProperty) { lib.LinePattern = (LinePattern)e.NewValue; } else if (e.Property == GridLineColorProperty) { lib.GridLineColor = (Brush)e.NewValue; } else if (e.Property == TitleProperty) { lib.Title = (string)e.NewValue; } else if (e.Property == XLabelProperty) { lib.XLabel = (string)e.NewValue; } else if (e.Property == YLabelProperty) { lib.YLabel = (string)e.NewValue; } else if (e.Property == IsXGridProperty) { lib.IsXGrid = (bool)e.NewValue; } else if (e.Property == IsYGridProperty) { lib.IsYGrid = (bool)e.NewValue; } else if (e.Property == IsLegendProperty) { lib.IsLegend = (bool)e.NewValue; } else if (e.Property == LegendPositionProperty) { lib.LegendPosition = (LegendPosition)e.NewValue; } }