public static LineGraph AddLineGraph(this Plotter2D plotter, IPointDataSource pointSource, Pen linePen, Description description) { if (pointSource == null) { throw new ArgumentNullException("pointSource"); } if (linePen == null) { throw new ArgumentNullException("linePen"); } LineGraph graph = new LineGraph { DataSource = pointSource, LinePen = linePen }; if (description != null) { NewLegend.SetDescription(graph, description.Brief); graph.Description = description; } // graph.Filters.Add(new InclinationFilter()); graph.Filters.Add(new FrequencyFilter()); plotter.Children.Add(graph); return(graph); }
private void Page_Loaded(object sender, RoutedEventArgs e) { plotter.AddLineGraph(DataSourceHelper.CreateDataSource(x => x != 0 ? 10 * Math.Sin(x) / x : 1)); var line = plotter.AddLineGraph(DataSourceHelper.CreateDataSource(x => Math.Sqrt(x))); // this will set different look to line chart's legend item - text from the left and line segment from the right NewLegend.SetLegendItemsBuilder(line, new LegendItemsBuilder(CreateDifferentlyLookingLegendItem)); // creating and adding to plotter line chart's description editor StackPanel textEditingPanel = new StackPanel { Orientation = Orientation.Horizontal, Background = Brushes.LightGray }; TextBlock label = new TextBlock { Text = "Chart's legend description:", Margin = new Thickness(5, 10, 0, 10), VerticalAlignment = VerticalAlignment.Center }; TextBox editor = new TextBox { DataContext = line, Margin = new Thickness(5, 10, 5, 10) }; editor.SetBinding(TextBox.TextProperty, new Binding { Path = new PropertyPath("(0)", NewLegend.DescriptionProperty), Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }); textEditingPanel.Children.Add(label); textEditingPanel.Children.Add(editor); plotter.Children.Add(textEditingPanel); }
/// <summary> /// Adds one dimensional graph. /// </summary> /// <param name="pointSource">The point source.</param> /// <param name="description">The description.</param> /// <returns></returns> public static LineGraph AddLineGraph(this Plotter2D plotter, IPointDataSource pointSource, string description) { LineGraph graph = AddLineGraph(plotter, pointSource); graph.Description = new PenDescription(description); NewLegend.SetDescription(graph, description); return(graph); }
public static LineAndMarker <ElementMarkerPointsGraph> AddLineGraph(this Plotter2D plotter, IPointDataSource pointSource, Pen linePen, ElementPointMarker marker, Description description) { if (pointSource == null) { throw new ArgumentNullException("pointSource"); } var res = new LineAndMarker <ElementMarkerPointsGraph>(); if (linePen != null) // We are requested to draw line graphs { LineGraph graph = new LineGraph { DataSource = pointSource, LinePen = linePen }; if (description != null) { NewLegend.SetDescription(graph, description.Brief); graph.Description = description; } if (marker == null) { // Add inclination filter only to graphs without markers // graph.Filters.Add(new InclinationFilter()); } graph.Filters.Add(new FrequencyFilter()); res.LineGraph = graph; plotter.Children.Add(graph); } if (marker != null) // We are requested to draw marker graphs { ElementMarkerPointsGraph markerGraph = new ElementMarkerPointsGraph { DataSource = pointSource, Marker = marker }; res.MarkerGraph = markerGraph; plotter.Children.Add(markerGraph); } return(res); }
private static IEnumerable <FrameworkElement> DefaultLegendItemsBuilder(IPlotterElement plotterElement) { LineGraph lineGraph = (LineGraph)plotterElement; Line line = new Line { X1 = 0, Y1 = 10, X2 = 20, Y2 = 0, Stretch = Stretch.Fill, DataContext = lineGraph }; line.SetBinding(Line.StrokeProperty, "Stroke"); line.SetBinding(Line.StrokeThicknessProperty, "StrokeThickness"); NewLegend.SetVisualContent(lineGraph, line); var legendItem = LegendItemsHelper.BuildDefaultLegendItem(lineGraph); yield return(legendItem); }