Esempio n. 1
0
        void Page_Loaded(object sender, RoutedEventArgs e)
        {
            #region Data preparation
            const int N = 200;

            int[] thiknesses = new int[10];

            for (int i = 0; i < 10; i++)
            {
                thiknesses[i] = i + 1;
            }

            Point[] points = new Point[N];
            double  step   = 10 / (double)N;

            for (int i = 0; i < N; i++)
            {
                points[i].X = -5 + i * step;
                points[i].Y = Math.Exp(points[i].X);
            }

            EnumerableDataSource <Point> dataSource = points.AsDataSource <Point>();
            dataSource.SetXYMapping(point => point);
            #endregion

            graph = new LineGraph(dataSource, "Graph Description");
            graph.LineThickness = 3;
            graph.LineColor     = Colors.Red;


            MainPlotter.Children.Add(graph);
            MainPlotter.FitToView();

            TextBoxDescription.Text = graph.Description;
        }
Esempio n. 2
0
		private void Window1_Loaded(object sender, RoutedEventArgs e)
		{
			//plotter.Viewport.Visible = new DataRect(-1, -1.1, 200, 2.2);

			const int count = 14000;
			Point[] pts = new Point[count];

			for (int i = 0; i < count; i++)
			{
				double x = i / 20.0 - 1000;
				pts[i] = new Point(x, Math.Sin(x));
			}

#if !old
			var ds = pts.AsDataSource();

			LineChart chart = new LineChart { DataSource = ds };
			//chart.Filters.Clear();

			//InclinationFilter filter = new InclinationFilter();
			//BindingOperations.SetBinding(filter, InclinationFilter.CriticalAngleProperty, new Binding { Path = new PropertyPath("Value"), Source = slider });
			//chart.Filters.Add(filter);
			plotter.Children.Add(chart);

			//plotter.Children.Add(new LineChart { DataSource = new FunctionalDataSource { Function = x => Math.Atan(x) } });
			//plotter.Children.Add(new LineChart { DataSource = new FunctionalDataSource { Function = x => Math.Tan(x) } });
#else
			var ds2 = new Microsoft.Research.DynamicDataDisplay.DataSources.RawDataSource(pts);
			lineGraph = plotter.AddLineGraph(ds2);
#endif

			((NumericAxis)plotter.MainHorizontalAxis).TicksProvider = new CustomBaseNumericTicksProvider(Math.PI);
			((NumericAxis)plotter.MainHorizontalAxis).LabelProvider = new CustomBaseNumericLabelProvider(Math.PI, "π");
		}
Esempio n. 3
0
        void Page_Loaded(object sender, RoutedEventArgs e)
        {
            #region Data preparation
            const int N = 200;

            int[] thiknesses = new int[10];

            for(int i=0;i<10;i++)
                thiknesses[i] = i+1;

            Point[] points = new Point[N];
            double step = 10 / (double)N;

            for(int i=0;i<N;i++) {
                points[i].X = -5 + i*step;
                points[i].Y = Math.Exp(points[i].X);
            }

            EnumerableDataSource<Point> dataSource = points.AsDataSource<Point>();
            dataSource.SetXYMapping(point => point);
            #endregion

            graph = new LineGraphWithPoints(dataSource, "Graph Description");
            graph.LineThickness = 3;
            graph.LineColor = Colors.Red;

            
            MainPlotter.Children.Add(graph);
            MainPlotter.FitToView();

            TextBoxDescription.Text = graph.Description;
            if (MainPlotter.Legend != null)
                TextBoxDescriptionLength.Text = MainPlotter.Legend.AllowedDescriptionLength.ToString();
        }
Esempio n. 4
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();
        }
Esempio n. 5
0
        private void addRandomPolynomial()
        {
            int[] multipliers = new int[5];
            Point[] points = new Point[500];

            for (int i = 0; i < multipliers.Length; i++)
                multipliers[i] = (int)((random.NextDouble() - 0.5) * 200);

            double step = (double)(10) / points.Length;
            for (int i = 0; i < points.Length; i++)
            {
                points[i].X = -5 + (step * i);
                points[i].Y = Math.Pow(points[i].X, 5) +
                    multipliers[0] * Math.Pow(points[i].X, 4) +
                    multipliers[1] * Math.Pow(points[i].X, 3) +
                    multipliers[2] * Math.Pow(points[i].X, 2) +
                    multipliers[3] * points[i].X +
                    multipliers[4];
            }

            var dataSource = points.AsDataSource<Point>();
            dataSource.SetXYMapping(point => point);


            LineGraph polinom = new LineGraph(dataSource,
                multipliers[0]+" "+multipliers[1]+" "+multipliers[2]+" "+multipliers[3]+" "+multipliers[4]);
            
            mainPlotter.Children.Add(polinom);
        }
Esempio n. 6
0
        private void addRandomPolynomial()
        {
            int[]   multipliers = new int[5];
            Point[] points      = new Point[500];

            for (int i = 0; i < multipliers.Length; i++)
            {
                multipliers[i] = (int)((random.NextDouble() - 0.5) * 200);
            }

            double step = (double)(10) / points.Length;

            for (int i = 0; i < points.Length; i++)
            {
                points[i].X = -5 + (step * i);
                points[i].Y = Math.Pow(points[i].X, 5) +
                              multipliers[0] * Math.Pow(points[i].X, 4) +
                              multipliers[1] * Math.Pow(points[i].X, 3) +
                              multipliers[2] * Math.Pow(points[i].X, 2) +
                              multipliers[3] * points[i].X +
                              multipliers[4];
            }

            var dataSource = points.AsDataSource <Point>();

            dataSource.SetXYMapping(point => point);


            LineGraph polinom = new LineGraph(dataSource,
                                              multipliers[0] + " " + multipliers[1] + " " + multipliers[2] + " " + multipliers[3] + " " + multipliers[4]);

            mainPlotter.Children.Add(polinom);
        }
Esempio n. 7
0
        private void Window1_Loaded(object sender, RoutedEventArgs e)
        {
            //plotter.Viewport.Visible = new DataRect(-1, -1.1, 200, 2.2);

            const int count = 14000;

            Point[] pts = new Point[count];

            for (int i = 0; i < count; i++)
            {
                double x = i / 20.0 - 1000;
                pts[i] = new Point(x, Math.Sin(x));
            }

#if !old
            var ds = pts.AsDataSource();

            LineChart chart = new LineChart {
                DataSource = ds
            };
            //chart.Filters.Clear();

            //InclinationFilter filter = new InclinationFilter();
            //BindingOperations.SetBinding(filter, InclinationFilter.CriticalAngleProperty, new Binding { Path = new PropertyPath("Value"), Source = slider });
            //chart.Filters.Add(filter);
            plotter.Children.Add(chart);

            //plotter.Children.Add(new LineChart { DataSource = new FunctionalDataSource { Function = x => Math.Atan(x) } });
            //plotter.Children.Add(new LineChart { DataSource = new FunctionalDataSource { Function = x => Math.Tan(x) } });
#else
            var ds2 = new Microsoft.Research.DynamicDataDisplay.DataSources.RawDataSource(pts);
            lineGraph = plotter.AddLineGraph(ds2);
#endif

            ((NumericAxis)plotter.MainHorizontalAxis).TicksProvider = new CustomBaseNumericTicksProvider(Math.PI);
            ((NumericAxis)plotter.MainHorizontalAxis).LabelProvider = new CustomBaseNumericLabelProvider(Math.PI, "π");
        }
Esempio n. 8
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();
        }