Exemplo n.º 1
0
        void Page_Loaded(object sender, RoutedEventArgs e)
        {
            const int N = 200;
            
            double step = Math.PI * 2 / N;

            #region CompositeDataSource
            double[] x = new double[N];
            double[] y = new double[N];
            
            for (int i = 0; i < N; i++)
            {
                x[i] = i *step;
                y[i] = Math.Sin(x[i]);
            }

            var xDataSource = x.AsXDataSource();
            var yDataSource = y.AsYDataSource();

            CompositeDataSource compositeDataSource = xDataSource.Join(yDataSource);

            sin = new LineGraph(compositeDataSource, "sin(x)");

            PlotterMain.Children.Add(sin);
            #endregion

            #region RawDataSource
            Point[] points = new Point[N];

            for (int i = 0; i < N; i++) { 
                points[i] = new Point(i*step, (0.7 * Math.Cos(x[i] * 3) + 3) + (1.5 * Math.Sin(x[i] / 2 + 4)));
            }

            RawDataSource rawDataSource = points.AsDataSource();
            
            cos = new LineGraph(rawDataSource, "(0.7 * Cos(3x)+3)+(1.5*Sin(x/2+4))");
            
            PlotterMain.Children.Add(cos);
            #endregion

            #region EnumerableDataSource and Custom Graph Settings
            
            MyClass[] myObjects = new MyClass[N];
            for (int i = 0; i < N; i++)
                myObjects[i] = new MyClass() { A = 0.1 + i * step };

            EnumerableDataSource<MyClass> enumDataSource = myObjects.AsDataSource<MyClass>();
            enumDataSource.SetXYMapping(o => new Point(o.A,o.B));

            LineGraphSettings settings = new LineGraphSettings();
            settings.LineColor = Colors.Magenta;
            settings.LineThickness = Math.PI;
            settings.Description = "Log10";
            log = new LineGraph(enumDataSource, settings);
            PlotterMain.Children.Add(log);

            #endregion

            PlotterMain.FitToView();
        }
Exemplo n.º 2
0
        public LineGraph()
        {
            if (Settings == null)
            {
                Settings = new LineGraphSettings();
            }
            filters.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(filters_CollectionChanged);
            path            = new Path();
            geom            = new PathGeometry();
            figures         = new PathFigureCollection();
            figure          = new PathFigure();
            segments        = new PathSegmentCollection();
            figure.Segments = segments;
            figures.Add(figure);
            geom.Figures         = figures;
            path.Data            = geom;
            path.StrokeLineJoin  = PenLineJoin.Round;
            path.StrokeThickness = settings.LineThickness;


            path.SetBinding(Path.StrokeProperty, new System.Windows.Data.Binding()
            {
                Source = this, Path = new PropertyPath("LineColor")
            });
            Filters.Add(new Microsoft.Research.DynamicDataDisplay.Filters.FrequencyFilter());
        }
Exemplo n.º 3
0
 /// <summary>
 /// Create a linegraph using specific datasource and description
 /// </summary>
 /// <param name="pointSource">Data source</param>
 /// <param name="description">Description shown in legend</param>
 public LineGraph(IPointDataSource pointSource, string description)
     : this()
 {
     DataSource = pointSource;
     Settings   = new LineGraphSettings()
     {
         Description = description
     };
 }
Exemplo n.º 4
0
 /// <summary>
 /// Create a linegraph using specific datasource and settings
 /// </summary>
 /// <param name="pointSource">Data source</param>
 /// <param name="settings">Graph visual settings</param>
 public LineGraph(IPointDataSource pointSource, LineGraphSettings settings)
     : this()
 {
     this.Settings = settings;
     DataSource    = pointSource;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Create a linegraph using specific datasource and settings
 /// </summary>
 /// <param name="pointSource">Data source</param>
 /// <param name="settings">Graph visual settings</param>
 public LineGraph(IPointDataSource pointSource,LineGraphSettings settings)
     : this()
 {
     this.Settings = settings;
     DataSource = pointSource;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Create a linegraph using specific datasource and description
 /// </summary>
 /// <param name="pointSource">Data source</param>
 /// <param name="description">Description shown in legend</param>
 public LineGraph(IPointDataSource pointSource,string description)
     : this()
 {
     DataSource = pointSource;
     Settings = new LineGraphSettings() { Description = description};
 }
Exemplo n.º 7
0
        public LineGraph() {
            if(Settings == null)
                Settings = new LineGraphSettings();
            filters.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(filters_CollectionChanged);
            path = new Path();
            geom = new PathGeometry();
            figures = new PathFigureCollection();
            figure = new PathFigure();
            segments = new PathSegmentCollection();
            figure.Segments = segments;
            figures.Add(figure);
            geom.Figures = figures;
            path.Data = geom;
            path.StrokeLineJoin = PenLineJoin.Round;
            path.StrokeThickness = settings.LineThickness;

        
            path.SetBinding(Path.StrokeProperty, new System.Windows.Data.Binding() { Source = this, Path = new PropertyPath("LineColor") });
            Filters.Add(new Microsoft.Research.DynamicDataDisplay.Filters.FrequencyFilter());
        }