void MainWindow_Loaded(object sender, RoutedEventArgs e) { //lineChart.ItemsSource = new Func<double, double>(i => Math.Sin(i * 10)); //plotter.MainHorizontalAxis = null; //plotter.Children.Remove(plotter.MainHorizontalAxis); var axis = new HorizontalAxis(); plotter.Children.Add(axis); CustomBaseNumericTicksProvider ticksProvider = new CustomBaseNumericTicksProvider(Math.PI); CustomBaseNumericLabelProvider labelProvider = new CustomBaseNumericLabelProvider(Math.PI, "π"); axis.LabelProvider = labelProvider; axis.TicksProvider = ticksProvider; for (int i = 0; i < count; i++) { data.Add(new Point(i, Math.Sin(i / 10))); } LineChart chart = new LineChart { ItemsSource = data, StrokeThickness = 3 }; plotter.Children.Add(chart); List<double> xs = Enumerable.Range(0, count).Select(i => (double)i).ToList(); List<double> ys = Enumerable.Range(0, count).Select(i => Math.Sin(i / 10.0)).ToList(); xAndYSeqChart.DataSource = DataSource.Create(xs, ys); }
/// <summary> /// Adds the line chart with specified items source to plotter. /// </summary> /// <param name="plotter">The plotter.</param> /// <param name="data">The data.</param> /// <returns>An instance of LineChart.</returns> public static LineChart AddLineChart(this Plotter2D plotter, object data) { if (plotter == null) throw new ArgumentNullException("plotter"); if (data == null) throw new ArgumentNullException("data"); LineChart chart = new LineChart { ItemsSource = data }; plotter.Children.Add(chart); return chart; }
public LineChartTest() { chart = new LineChart(); chart.DataSource = new TestDataSource(); ChartPlotter plotter = new ChartPlotter(); plotter.PerformLoad(); plotter.Children.Add(chart); PrivateObject privateObject = new PrivateObject(chart); LineChart_Accessor target = new LineChart_Accessor(privateObject); canvas = target.canvas; paths = canvas.Children.Cast<Path>(); }
/// <summary> /// Adds the specified lap to the chart plotter control. /// Color will be determined by the currently selected LapColor /// Altitude is dashed and speed is a solid line /// plotter plots Altitude while innerPlotter plots Speed/Velocity /// </summary> /// <param name="lap"></param> void addLapToPlotter(LapInfo lap) { double[] xPoints = new double[lap.Altitude.Count]; for (int i = 0; i < lap.Altitude.Count; i++) { xPoints[i] = i; } Brush lapColor = new SolidColorBrush(lap.LapColor); // look at checkboxes to see if user wants altitude, speed if (checkBoxAltitude.IsChecked == true) { var altitudeDS = DataSource.Create(xPoints, lap.Altitude); LineChart chart = new LineChart(); chart.DataSource = altitudeDS; chart.Stroke = lapColor; chart.StrokeThickness = 2; chart.Description = "Altitude"; chart.StrokeDashArray = new DoubleCollection(new double[] { 1, 1 }); chart.Tag = lap; // chart tag holds the corresponding lap object. used for chart removal innerAltitudePlotter.AddChild(chart); } if (checkBoxSpeed.IsChecked == true) { var speedDS = DataSource.Create(xPoints, lap.Velocity); LineChart chart = new LineChart(); chart.DataSource = speedDS; chart.Stroke = lapColor; chart.StrokeThickness = 2; chart.Description = "Velocity"; chart.Tag = lap; // chart tag holds the corresponding lap object. used for chart removal innerSpeedPlotter.Children.Add(chart); } }