Пример #1
0
		private void MainWindow_Loaded(object sender, RoutedEventArgs e)
		{
			// Prepare data in arrays
			const int N = 100;
			double[] x = new double[N];
			double[] y = new double[N];

			for (int i = 0; i < N; i++)
			{
				x[i] = i * 0.1;
				y[i] = Math.Cos(x[i]);
			}

			// Add data sources:
			var yDataSource = new EnumerableDataSource<double>(y);
			yDataSource.SetYMapping(Y => Y);
			yDataSource.AddMapping(ShapeElementPointMarker.ToolTipTextProperty,
				Y => string.Format("Value is {0}", Y));

			var xDataSource = new EnumerableDataSource<double>(x);
			xDataSource.SetXMapping(X => X);

			CompositeDataSource compositeDataSource = new CompositeDataSource(xDataSource, yDataSource);

			plotter.Viewport.Restrictions.Add(new PhysicalProportionsRestriction { ProportionRatio = 1 });

			// adding graph to plotter
			plotter.AddLineGraph(compositeDataSource,
				new Pen(Brushes.Goldenrod, 3),
				new SampleMarker(),
				new PenDescription("Cosine"));
		}
Пример #2
0
		void Window1_Loaded(object sender, RoutedEventArgs e)
		{
			plotter.DataTransform = new Log10Transform();

			double[] xArray = new double[] { 15, 14, 16, 48, 50, 51 };
			double[] yArray = new double[] { 60, 63, 64, 124, 131, 144 };

			var xds = xArray.AsXDataSource();
			var yds = yArray.AsYDataSource();
			var ds = new CompositeDataSource(xds, yds);

			plotter.AddLineGraph(ds);


			// You can try to uncomment the following code
			/*
			HorizontalAxis xAxis = new HorizontalAxis
			{
				TicksProvider = new LogarithmNumericTicksProvider(10),
				LabelProvider = new UnroundingLabelProvider()
			};
			plotter.MainHorizontalAxis = xAxis;

			VerticalAxis yAxis = new VerticalAxis
			{
				TicksProvider = new LogarithmNumericTicksProvider(10),
				LabelProvider = new UnroundingLabelProvider()
			};
			plotter.MainVerticalAxis = yAxis;
			*/
		}
Пример #3
0
        private void showprogress()
        {
            DBProgressConnect DBProgressConnect_Inst = new DBProgressConnect();
            DataTable ProgressData = new DataTable();
            ProgressData = DBProgressConnect_Inst.Read(globaldata.current_user);
            datagrid1.ItemsSource = ProgressData.DefaultView;
            int data_count = DBProgressConnect_Inst.Count(globaldata.current_user);
            DateTime[] dates = new DateTime[data_count];
            double[] scores = new double[data_count];

            for (int i = 0; i < data_count; i++)
            {
                dates[i] = Convert.ToDateTime(ProgressData.Rows[i][1]);
                scores[i] = Convert.ToDouble(ProgressData.Rows[i][2]);
            }

            var datesDataSource = new EnumerableDataSource<DateTime>(dates);
            datesDataSource.SetXMapping(x => dateAxis.ConvertToDouble(x));

            var scoreDataSource = new EnumerableDataSource<double>(scores);
            scoreDataSource.SetYMapping(y => y);

            CompositeDataSource compositeDataSource1 = new CompositeDataSource(datesDataSource, scoreDataSource);

            Plotter.AddLineGraph(compositeDataSource1, new Pen(Brushes.Blue, 2), new CirclePointMarker { Size = 10.0, Fill = Brushes.Red }, new PenDescription("Time vs. Score for "+globaldata.current_user+""));

            Plotter.Viewport.FitToView();
        }
Пример #4
0
		public Window1()
		{
			InitializeComponent();

			Content = plot;

			plot.MainHorizontalAxis = axis;

			const int N = 10;

			double[] x = new double[N];
			double[] y = new double[N];
			DateTime[] date = new DateTime[N];

			for (int i = 0; i < N; i++)
			{
				x[i] = i * 0.1;
				y[i] = Math.Sin(x[i]);
				date[i] = DateTime.Now.AddMinutes(-N + i);
			}

			EnumerableDataSource<double> xs = new EnumerableDataSource<double>(x);
			xs.SetYMapping(_x => _x);
			EnumerableDataSource<DateTime> ys = new EnumerableDataSource<DateTime>(date);
			ys.SetXMapping(axis.ConvertToDouble);

			CompositeDataSource ds = new CompositeDataSource(xs, ys);

			plot.AddLineGraph(ds);
		}
        private void CreateHistograms()
        {
            EnumerableDataSource<int> x = new EnumerableDataSource<int>(Enumerable.Range(0, 256).ToArray());
            x.SetXMapping(_x => _x);

            Func<int, double> mapping;
            if (check.IsChecked.GetValueOrDefault())
                mapping = logMapping;
            else
                mapping = linearMapping;

            red = new EnumerableDataSource<int>(reds);
            red.SetYMapping(mapping);
            green = new EnumerableDataSource<int>(greens);
            green.SetYMapping(mapping);
            blue = new EnumerableDataSource<int>(blues);
            blue.SetYMapping(mapping);

            CompositeDataSource rDS = new CompositeDataSource(x, red);
            CompositeDataSource gDS = new CompositeDataSource(x, green);
            CompositeDataSource bDS = new CompositeDataSource(x, blue);

            plotter.RemoveUserElements();
            plotter.AddLineGraph(rDS, Colors.Red, 1, "Red").FilteringEnabled = false;
            plotter.AddLineGraph(gDS, Colors.Green, 1, "Green").FilteringEnabled = false;
            plotter.AddLineGraph(bDS, Colors.Blue, 1, "Blue").FilteringEnabled = false;
        }
Пример #6
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Prepare data in arrays
            const int N = 100;
            double[] x = new double[N];
            double[] cs = new double[N];
            double[] sn = new double[N];

            for (int i = 0; i < N; i++)
            {
                x[i] = i * 0.1;
                cs[i] = Math.Sin(x[i]);
                sn[i] = Math.Cos(x[i]);
            }

            // Add data sources:
            // 3 partial data sources, containing each of arrays
            var snDataSource = new EnumerableDataSource<double>(sn);
            snDataSource.SetYMapping(y => y);

            var xDataSource = new EnumerableDataSource<double>(x);
            xDataSource.SetXMapping(lx => lx);

            var csDataSource = new EnumerableDataSource<double>(cs);
            csDataSource.SetYMapping(y => y);

            var csqDataSource = new EnumerableDataSource<double>(cs);
            csqDataSource.SetYMapping(y => y * y);


            // 2 composite data sources and 2 charts respectively:
            // creating composite data source
            CompositeDataSource compositeDataSource1 = new CompositeDataSource(xDataSource, snDataSource);
            // adding graph to plotter
            plotter.AddLineGraph(compositeDataSource1,
                new Pen(Brushes.DarkGoldenrod, 3),
                new CirclePointMarker { Size = 10, Fill = Brushes.Red },
                new PenDescription("Sin"));

            // creating composite data source for cs values
            CompositeDataSource compositeDataSource2 = new CompositeDataSource(xDataSource, csDataSource);
            // Adding second graph to plotter
            plotter.AddLineGraph(compositeDataSource2,
                new Pen(Brushes.Blue, 3),
                new TrianglePointMarker { Size = 20, Fill = Brushes.Blue },
                new PenDescription("Cos"));

            // creating composite data source for cs^2 values
            CompositeDataSource compositeDataSource3 = new CompositeDataSource(xDataSource, csqDataSource);
            // Adding thirs graph to plotter
            Pen dashed = new Pen(Brushes.Magenta, 3);
            dashed.DashStyle = DashStyles.Dot;
            plotter.AddLineGraph(compositeDataSource3,
                dashed,
                new PenDescription("Cos^2"));

            // Force evertyhing plotted to be visible
            plotter.FitToView();
        }
Пример #7
0
        private void create(float[] sensor, string sensorName, Brush brush, EnumerableDataSource<DateTime> datesDataSource)
        {
            var numbersensordatasource = new EnumerableDataSource<float>(sensor);
            numbersensordatasource.SetYMapping(y => y);

            var compositeSensor1DataSource = new
            CompositeDataSource(datesDataSource, numbersensordatasource);

            plotter.AddLineGraph(compositeSensor1DataSource,
              new Pen(brush, 2),
              new CirclePointMarker { Size = 10.0, Fill = brush },
              new PenDescription(sensorName));
        }
Пример #8
0
		private void MainWindow_Loaded(object sender, RoutedEventArgs e)
		{
			// Prepare data in arrays
			const int N = 100;
			double[] x = new double[N];
			double[] y = new double[N];

			for (int i = 0; i < N; i++)
			{
				x[i] = i * 0.1;
				y[i] = Math.Cos(x[i]);
			}

			// Add data sources:
			var yDataSource = new EnumerableDataSource<double>(y);
			yDataSource.SetYMapping(Y => Y);
			yDataSource.AddMapping(ShapeElementPointMarker.ToolTipTextProperty,
				Y => string.Format("Value is {0}", Y));

			var xDataSource = new EnumerableDataSource<double>(x);
			xDataSource.SetXMapping(X => X);


			CompositeDataSource compositeDataSource = new CompositeDataSource(xDataSource, yDataSource);

			Matrix m = Matrix.Identity;
			m.RotateAt(45, 10, 10);
			line = new LineGraph
			{
				Stroke = Brushes.Green,
				StrokeThickness = 2,
				DataTransform =
					//new MatrixDataTransform(m) 
				new RotateDataTransform(45.0.DegreesToRadians())
			};
			line.DataSource = compositeDataSource;
			line.AddToPlotter(plotter);

			plotter.Viewport.Constraints.Add(new PhysicalProportionsConstraint { ProportionRatio = 1 });


			// adding graph to plotter
			plotter.AddLineGraph(compositeDataSource,
				new Pen(Brushes.Goldenrod, 3),
				new SampleMarker(),
				new PenDescription("Cosine"));

			//plotter.Viewport.FitToViewRestrictions.Add(new FollowDataWidthRestriction { Width = 1 });

			plotter.PreviewKeyDown += plotter_KeyDown;
		}
		public AnimatedDataSource()
		{
			// randomize start phase
			phase = rnd.NextDouble() * 3;

			// create data source
			xDS = new EnumerableDataSource<double>(x);
			xDS.SetXMapping(X => X);
			EnumerableDataSource<double> yDS = new EnumerableDataSource<double>(y);
			yDS.SetYMapping(Y => Y);
			Update();

			ds = new CompositeDataSource(xDS, yDS);
		}
Пример #10
0
        public void DrawThis(IEnumerable<int> value, IEnumerable<int> time, Brush penBrush, Brush circlePoints)
        {
            var timesDataSource = new EnumerableDataSource<int>(value);
            timesDataSource.SetXMapping(x => timeAxis.ConvertToDouble(x));

            var xPointsDataSource = new EnumerableDataSource<int>(time);
            xPointsDataSource.SetYMapping(y => Convert.ToInt32(y));

            var compositeDataSource = new CompositeDataSource(xPointsDataSource, timesDataSource);

            plotter.AddLineGraph(compositeDataSource,
                                 new Pen(penBrush, 2),
                                 new CirclePointMarker {Size = 8.0, Fill = circlePoints},
                                 new PenDescription(""));

            plotter.Viewport.FitToView();
        }
        public MainWindow()
        {
            InitializeComponent();
            FillTestData();

            y_valuesDataSource = new ObservableDataSource<int>(y_values);
            y_valuesDataSource.SetYMapping(y => y);

            x_valuesDataSource = new ObservableDataSource<int>(x_values);
            x_valuesDataSource.SetXMapping(x => x);

            var compositeDataSource = new CompositeDataSource(x_valuesDataSource, y_valuesDataSource);

            //chartPlotter.AddLineGraph(compositeDataSource);

            //chartPlotter.Viewport.FlowDirection = FlowDirection.RightToLeft;
            //chartPlotter.Viewport.FitToView();
        }
Пример #12
0
		void Window1_Loaded(object sender, RoutedEventArgs e)
		{
			plotter.Children.Add(new HorizontalLine { Value = 0, Stroke = Brushes.DarkGreen.MakeTransparent(0.2) });
			plotter.Children.Add(new VerticalLine { Value = 0, Stroke = Brushes.DarkGreen.MakeTransparent(0.2) });

#if old
			var xs = Enumerable.Range(0, 500).Select(i => (i - 250) * 0.02);
			var sineYDS = xs.Select(x => Math.Sin(x)).AsYDataSource();
			var atanYDS = xs.Select(x => Math.Atan(x)).AsYDataSource();

			var sineDS = new CompositeDataSource(xs.AsXDataSource(), sineYDS);
			var atanDS = new CompositeDataSource(xs.AsXDataSource(), atanYDS);

			var sineChart = plotter.AddLineGraph(sineDS);
			var atanChart = plotter.AddLineGraph(atanDS);

			//sineChart.Filters.Clear();
			//atanChart.Filters.Clear();
#else
			var xs = Enumerable.Range(0, 500).Select(i => (i - 250) * 0.02);
			var sineDS = xs.Select(x => new Point(x, Math.Sin(x))).AsDataSource();
			var atanDS = xs.Select(x => new Point(x, Math.Atan(x))).AsDataSource();
			var sincDS = Enumerable.Range(-5000, 10001).Select(i =>
			{
				double x = Math.PI * i / 1000;
				double y;
				if (i == 0)
					y = 100;
				else
					y = Math.Sin(x * 100);
				return new Point(x, y);
			}).AsDataSource();

			LineChart sincChart = new LineChart { Stroke = ColorHelper.RandomBrush, DataSource = sincDS };
			//plotter.Children.Add(sincChart);


			LineChart sineChart = new LineChart { Stroke = ColorHelper.RandomBrush, DataSource = sineDS };
			plotter.Children.Add(sineChart);
			LineChart atanChart = new LineChart { Stroke = ColorHelper.RandomBrush, DataSource = atanDS };
			plotter.Children.Add(atanChart);
#endif
		}
Пример #13
0
		private void ProcessImage(BitmapImage bmp)
		{
			byte[] pixels = new byte[bmp.PixelWidth * bmp.PixelHeight * 4];
			bmp.CopyPixels(pixels, bmp.PixelWidth * 4, 0);

			for (int i = 0; i < pixels.Length; )
			{
				//BGRA
				blues[pixels[i++]]++;
				greens[pixels[i++]]++;
				reds[pixels[i++]]++;
				i++;
			}

			EnumerableDataSource<int> x = new EnumerableDataSource<int>(Enumerable.Range(0, 256).ToArray());
			x.SetXMapping(_x => _x);

			Func<int, double> mapping;
			if (check.IsChecked.GetValueOrDefault())
				mapping = logMapping;
			else
				mapping = linearMapping;

			red = new EnumerableDataSource<int>(reds);
			red.SetYMapping(mapping);
			green = new EnumerableDataSource<int>(greens);
			green.SetYMapping(mapping);
			blue = new EnumerableDataSource<int>(blues);
			blue.SetYMapping(mapping);

			CompositeDataSource rDS = new CompositeDataSource(x, red);
			CompositeDataSource gDS = new CompositeDataSource(x, green);
			CompositeDataSource bDS = new CompositeDataSource(x, blue);

			plotter.RemoveUserElements();
			plotter.AddLineGraph(rDS, Colors.Red, 1, "Red").FilteringEnabled = false;
			plotter.AddLineGraph(gDS, Colors.Green, 1, "Green").FilteringEnabled = false;
			plotter.AddLineGraph(bDS, Colors.Blue, 1, "Blue").FilteringEnabled = false;
		}
Пример #14
0
		public PolarWindow()
		{
			InitializeComponent();

			grid.Children.Add(plotter);

			const int N = 100;
			var rs = Enumerable.Range(0, N).Select(i => (double)1);
			var phis = Enumerable.Range(0, N).Select(i => (i * (360.0 / (N - 1)).DegreesToRadians()));

			EnumerableDataSource<double> xs = new EnumerableDataSource<double>(rs);
			xs.SetXMapping(x => x);
			EnumerableDataSource<double> ys = new EnumerableDataSource<double>(phis);
			ys.SetYMapping(y => y);
			CompositeDataSource ds = new CompositeDataSource(xs, ys);

			LineGraph line = new LineGraph();
			line.DataTransform = new CompositeDataTransform(new PolarToRectTransform(), new RotateDataTransform(0.5, new Point(3, 0)));
			line.Stroke = Brushes.Blue;
			line.StrokeThickness = 1;
			line.DataSource = ds;
			plotter.Children.Add(line);
		}
Пример #15
0
        public void DrawThis(IEnumerable<Point> values, Brush penBrush, Brush circlePoints, string chartDescription)
        {
            if (values != null)
            {
                var time = new int[values.Count()];
                var value = new int[values.Count()];

                for (int i = 0; i < values.Count(); i++)
                {
                    if (values != null)
                    {
                        time[i] = (int) values.ToArray()[i].X;
                        value[i] = (int) values.ToArray()[i].Y;
                    }
                }

                var timesDataSource = new EnumerableDataSource<int>(time);
                timesDataSource.SetXMapping(x => timeAxis.ConvertToDouble(x));

                var xPointsDataSource = new EnumerableDataSource<int>(value);
                xPointsDataSource.SetYMapping(y => Convert.ToInt32(y));

                var compositeDataSource = new CompositeDataSource(xPointsDataSource, timesDataSource);

                plotter.AddLineGraph(compositeDataSource,
                                     new Pen(penBrush, 2),
                                     new CirclePointMarker {Size = 8.0, Fill = circlePoints},
                                     new PenDescription(chartDescription));

                plotter.Viewport.FitToView();
            }
            else
            {
                throw new ArgumentNullException();
            }
        }
        private void PlotNonlinearity(Nonlinearity nonlinearity, string distributionName, Color color, double lineThickness)
        {
            if (nonlinearity == null)
                return;

            var curve = nonlinearity.FiringRateCurve;

            // Prepare data in arrays.
            var x = new double[curve.GetLength(0)];
            var y = new double[curve.GetLength(0)];

            for (var index = 0; index < curve.GetLength(0); index++)
            {
                x[index] = curve[index, 0];
                y[index] = curve[index, 1];
            }

            // Add data sources.
            var yDataSource = new EnumerableDataSource<double>(y);
            yDataSource.SetYMapping(Y => Y);
            yDataSource.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, Y => string.Format("Normal Value \n\n{0}", Y));

            var xDataSource = new EnumerableDataSource<double>(x);
            xDataSource.SetXMapping(X => X);

            var compositeDataSource = new CompositeDataSource(xDataSource, yDataSource);

            // MatchValuePlotter.Viewport.Restrictions.Add(new PhysicalProportionsRestriction { ProportionRatio = 500000 });
            var graph = ChartPlotter.AddLineGraph(compositeDataSource, color, lineThickness, distributionName);

            // Cache for later usage (e.g. change visibility).
            if (graph != null)
                _histogramGraphs.Add(graph);
        }
        private void PlotHistogram(Histogram histogram, string histogramName, Color color)
        {
            if (histogram == null)
                return;

            // Prepare data in arrays.
            var pointIndex = 0;
            var dataPointCount = 4 * histogram.BucketCount;
            var x = new double[dataPointCount];
            var y = new double[dataPointCount];

            foreach (var bucket in histogram.Buckets())
            {
                //var yValue = bucket.Count;
                var yValue = bucket.RelativeCount(histogram);

                // lower left point of the histogram bar
                x[pointIndex] = bucket.LowerBound;
                y[pointIndex] = 0;

                // upper left point of the histogram bar
                x[pointIndex + 1] = bucket.LowerBound;
                y[pointIndex + 1] = yValue;

                // upper right point of the histogram bar
                x[pointIndex + 2] = bucket.UpperBound;
                y[pointIndex + 2] = yValue;

                // lower right point of the histogram bar
                x[pointIndex + 3] = bucket.UpperBound;
                y[pointIndex + 3] = 0;

                pointIndex += 4;
            }

            // Add data sources.
            var yDataSource = new EnumerableDataSource<double>(y);
            yDataSource.SetYMapping(Y => Y);
            yDataSource.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, Y => string.Format("Match Value \n\n{0}", Y));

            var xDataSource = new EnumerableDataSource<double>(x);
            xDataSource.SetXMapping(X => X);

            var compositeDataSource = new CompositeDataSource(xDataSource, yDataSource);

            // MatchValuePlotter.Viewport.Restrictions.Add(new PhysicalProportionsRestriction { ProportionRatio = 500000 });
            var graph = ChartPlotter.AddLineGraph(compositeDataSource, color, 1, histogramName);

            // Cache for later usage (e.g. change visibility).
            if (graph != null)
                _histogramGraphs.Add(graph);
        }
        private LineAndMarker<ElementMarkerPointsGraph> PlotEigenvalues(int cell, Brush brush)
        {
            double[] eigenValues;
            double[][] eigenVectors;

            var stc = SpikeTriggeredAnalysis.CalculateSTC(_stimuli, new double[][][] { _spikes[cell - 1] }, RoundStrategy.Round);
            SpikeTriggeredAnalysis.CalculateEigenValues(stc, out eigenValues, out eigenVectors);

            // Prepare data in arrays
            var N = eigenValues.Length;
            var x = new double[N];
            var y = new double[N];

            for (var index = 0; index < N; index++)
            {
                x[index] = index;
                y[index] = eigenValues[index];
            }

            // Add data sources:
            var yDataSource = new EnumerableDataSource<double>(y);
            yDataSource.SetYMapping(Y => Y);
            yDataSource.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, Y => string.Format("Cell {0} - Eigenvalue \n\n{1}", cell, Y));

            var xDataSource = new EnumerableDataSource<double>(x);
            xDataSource.SetXMapping(X => X);

            var compositeDataSource = new CompositeDataSource(xDataSource, yDataSource);

            EigenvaluePlotter.Viewport.Restrictions.Add(new PhysicalProportionsRestriction { ProportionRatio = 30 });
            var graph = EigenvaluePlotter.AddLineGraph(compositeDataSource, new Pen(brush, 1), new SampleMarker() { Brush = brush }, new PenDescription(string.Format("Eigenvalues of Cell {0}", cell)));

            return graph;
        }
        public void RunSimulation()
        {
            _environment.RunSimulation();

            int arraySize = _environment.TimeValues.GetLength(0);
            int graphSize = 100;

            double remain = ((double)(arraySize - 1) % (double)(graphSize - 1)) / (double)arraySize;

            while ((remain > 0.1) && (graphSize > 50))
            {
                graphSize--;
                remain = ((double)(arraySize - 1) % (double)(graphSize - 1)) / (double)arraySize;
            }

            int step = (arraySize - 1) / (graphSize - 1);

            double[] timeValues = new double[graphSize];
            double[] w1_Values = new double[graphSize];
            double[] w2_Values = new double[graphSize];
            double[] w3_Values = new double[graphSize];
            double[] w4_Values = new double[graphSize];
            double[] rollValues = new double[graphSize];
            double[] pitchValues = new double[graphSize];
            double[] yawValues = new double[graphSize];
            double[] xValues = new double[graphSize];
            double[] yValues = new double[graphSize];
            double[] zValues = new double[graphSize];

            for (int i = 0, j = 0; i < graphSize; i++, j += step)
            {
                timeValues[i] = _environment.TimeValues[j];
                w1_Values[i] = _environment.RPM1Values[j];
                w2_Values[i] = _environment.RPM2Values[j];
                w3_Values[i] = _environment.RPM3Values[j];
                w4_Values[i] = _environment.RPM4Values[j];
                if (double.IsNaN(_environment.RollValues[j]))
                {
                    rollValues[i] = 0;
                }
                else
                {
                    rollValues[i] = _environment.RollValues[j];
                }

                if (double.IsNaN(_environment.PitchValues[j]))
                {
                    pitchValues[i] = 0;
                }
                else
                {
                    pitchValues[i] = _environment.PitchValues[j];
                }

                if (double.IsNaN(_environment.YawValues[j]))
                {
                    yawValues[i] = 0;
                }
                else
                {
                    yawValues[i] = _environment.YawValues[j];
                }

                if (double.IsNaN(_environment.XValues[j]))
                {
                    xValues[i] = 0;
                }
                else
                {
                    xValues[i] = _environment.XValues[j];
                }

                if (double.IsNaN(_environment.YValues[j]))
                {
                    yValues[i] = 0;
                }
                else
                {
                    yValues[i] = _environment.YValues[j];
                }

                if (double.IsNaN(_environment.ZValues[j]))
                {
                    zValues[i] = 0;
                }
                else
                {
                    zValues[i] = _environment.ZValues[j];
                }
            }
            EnumerableDataSource<double> timeDS = new EnumerableDataSource<double>(timeValues);
            timeDS.SetXMapping(e => e);
            EnumerableDataSource<double> w1_DS = new EnumerableDataSource<double>(w1_Values);
            w1_DS.SetYMapping(e => e);
            EnumerableDataSource<double> w2_DS = new EnumerableDataSource<double>(w2_Values);
            w2_DS.SetYMapping(e => e);
            EnumerableDataSource<double> w3_DS = new EnumerableDataSource<double>(w3_Values);
            w3_DS.SetYMapping(e => e);
            EnumerableDataSource<double> w4_DS = new EnumerableDataSource<double>(w4_Values);
            w4_DS.SetYMapping(e => e);
            EnumerableDataSource<double> rollDS = new EnumerableDataSource<double>(rollValues);
            rollDS.SetYMapping(e => e);
            EnumerableDataSource<double> pitchDS = new EnumerableDataSource<double>(pitchValues);
            pitchDS.SetYMapping(e => e);
            EnumerableDataSource<double> yawDS = new EnumerableDataSource<double>(yawValues);
            yawDS.SetYMapping(e => e);
            EnumerableDataSource<double> xDS = new EnumerableDataSource<double>(xValues);
            xDS.SetYMapping(e => e);
            EnumerableDataSource<double> yDS = new EnumerableDataSource<double>(yValues);
            yDS.SetYMapping(e => e);
            EnumerableDataSource<double> zDS = new EnumerableDataSource<double>(zValues);
            zDS.SetYMapping(e => e);

            _firstMotorSpeed = new CompositeDataSource(timeDS, w1_DS);
            _secondMotorSpeed = new CompositeDataSource(timeDS, w2_DS);
            _thirdMotorSpeed = new CompositeDataSource(timeDS, w3_DS);
            _fourthMotorSpeed = new CompositeDataSource(timeDS, w4_DS);
            _roll = new CompositeDataSource(timeDS, rollDS);
            _pitch = new CompositeDataSource(timeDS, pitchDS);
            _yaw = new CompositeDataSource(timeDS, yawDS);
            _xCoordinate = new CompositeDataSource(timeDS, xDS);
            _yCoordinate = new CompositeDataSource(timeDS, yDS);
            _zCoordinate = new CompositeDataSource(timeDS, zDS);
            OnPropertyChanged("FirstMotorSpeed");
            OnPropertyChanged("SecondMotorSpeed");
            OnPropertyChanged("ThirdMotorSpeed");
            OnPropertyChanged("FourthMotorSpeed");
            OnPropertyChanged("XCoordinate");
            OnPropertyChanged("YCoordinate");
            OnPropertyChanged("ZCoordinate");
            OnPropertyChanged("Roll");
            OnPropertyChanged("Pitch");
            OnPropertyChanged("Yaw");
        }
Пример #20
0
        private void DrawingPlot(ChartPlotter plotter, List<double> x, List<double> y, string legend, SolidColorBrush color)
        {
            var xAxis = x.ToArray();
              var yAxis = y.ToArray();

              EnumerableDataSource<double> xs = new EnumerableDataSource<double>(xAxis);
              EnumerableDataSource<double> ys = new EnumerableDataSource<double>(yAxis);

              xs.SetXMapping(_x => _x);
              ys.SetYMapping(_y => _y);
              CompositeDataSource ds = new CompositeDataSource(xs, ys);

              u_x = new LineGraph(ds);
              u_x.LinePen = new Pen(color, 2);
              u_x.Description = new PenDescription(legend);

              plotter.Children.Add(u_x);
        }
Пример #21
0
        public MainWindow()
        {
            InitializeComponent();
            this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            int waveInDevices = WaveIn.DeviceCount;
            for (int waveInDevice = 0; waveInDevice < waveInDevices; waveInDevice++)
            {
                WaveInCapabilities deviceInfo = WaveIn.GetCapabilities(waveInDevice);
                Console.WriteLine("Device {0}: {1}, {2} channels",
                    waveInDevice, deviceInfo.ProductName, deviceInfo.Channels);
            }

            waveIn = new WaveIn();
            waveIn.BufferMilliseconds = 47*buffersize/2048;
            waveIn.DeviceNumber = 0;
            waveIn.WaveFormat = new WaveFormat(44100, 32, 1);
            waveIn.DataAvailable += waveIn_DataAvailable;

            try
            {
                waveIn.StartRecording();
            }
            catch(NAudio.MmException e)
            {
                Console.WriteLine(e.ToString() + "\nPlug in a microphone!");
            }

            bin = new int[buffersize * 2];
            sampledata = new float[buffersize * 2];
            priori = new double[buffersize * 2];

            channelLabel = new int[1];
            channelLabel[0] = 1;
            velocity = new int[1];
            velocity[0] = 0;
            for (int i = 0; i < buffersize * 2; i++)
            {
                bin[i] = i;
                sampledata[i] = 0;
                priori[i] = 0;

            }

            chart1.Viewport.Visible = new DataRect(0, -1.0, buffersize * 2, 2.0);
            chart2.Viewport.Visible = new DataRect(1620, 0, 280, 110);

            bins = new EnumerableDataSource<int>(bin);
            bins.SetXMapping(x => x);

            rawIn = new EnumerableDataSource<float>(sampledata);
            rawIn.SetYMapping(y => y);

            CompositeDataSource comp1 = new CompositeDataSource(bins, rawIn);
            chart1.AddLineGraph(comp1);

            CompositeDataSource comp2 = new CompositeDataSource(bins, rawIn);
            chart2.AddLineGraph(comp2);
        }
        private void UpdateGraphData(ArrayList list)
        {
            var TimeStampSource = new EnumerableDataSource<float>(TSList);
            var YDataSource = new EnumerableDataSource<float>(list);

            TimeStampSource.SetXMapping(x => x);
            YDataSource.SetYMapping(y => y);
            CompositeDataSource TimeDataSource = new CompositeDataSource(TimeStampSource, YDataSource);
            Plotter.AddLineGraph(TimeDataSource, new System.Windows.Media.Pen(System.Windows.Media.Brushes.Green, 2), new TrianglePointMarker { Size = 10.0, Pen = new System.Windows.Media.Pen(System.Windows.Media.Brushes.Black, 2.0), Fill = System.Windows.Media.Brushes.GreenYellow },
            new Microsoft.Research.DynamicDataDisplay.PenDescription("GSR data"));
            Plotter.Viewport.FitToView();
            Plotter.Children.Add(mouseTrack);
            mouseTrack.ShowHorizontalLine = false;
            mouseTrack.ShowVerticalLine = false;
        }
Пример #23
0
        private void DrawChart()
        {
            var xpoints = new int[_visitedPoints.Count];
            var ypoints = new int[_visitedPoints.Count];
            var times = new int[_visitedPoints.Count];
            for (int i = 0; i < times.Length; i++)
            {
                times[i] = i;
                xpoints[i] = (int) _visitedPoints[i].Position.X;
                ypoints[i] = (int) _visitedPoints[i].Position.Y;
            }

            var timesDataSource = new EnumerableDataSource<int>(times);
            timesDataSource.SetXMapping(x => timeAxis.ConvertToDouble(x));

            var xPointsDataSource = new EnumerableDataSource<int>(xpoints);
            xPointsDataSource.SetYMapping(y => Convert.ToInt32(y));

            var yPointsDataSource = new EnumerableDataSource<int>(ypoints);
            yPointsDataSource.SetYMapping(y => Convert.ToInt32(y));

            var compositeDataSource1 = new CompositeDataSource(xPointsDataSource, timesDataSource);
            var compositeDataSource2 = new CompositeDataSource(yPointsDataSource, timesDataSource);

            plotter.AddLineGraph(compositeDataSource1,
                                 new Pen(Brushes.GreenYellow, 2),
                                 new CirclePointMarker {Size = 10.0, Fill = Brushes.Red},
                                 new PenDescription("x/t"));
            plotter.AddLineGraph(compositeDataSource2,
                                 new Pen(Brushes.Gold, 2),
                                 new CirclePointMarker {Size = 10.0, Fill = Brushes.DodgerBlue},
                                 new PenDescription("y/t"));

            plotter.Viewport.FitToView();
        }
Пример #24
0
        public void drawgraph(List<int> y, List<int> x, ChartPlotter plotter1)
        {
            var datesDataSource = new EnumerableDataSource<int>(y);
            datesDataSource.SetXMapping(t => t);

            var numberOpenDataSource = new EnumerableDataSource<int>(x);
            numberOpenDataSource.SetYMapping(k => k);

            CompositeDataSource compositeDataSource1 = new
              CompositeDataSource(datesDataSource, numberOpenDataSource);
            plotter1.Children.RemoveAll((typeof(LineGraph)));
            plotter1.AddLineGraph(compositeDataSource1,
              new Pen(Brushes.Blue, 2),
              new CirclePointMarker { Size = 0.0, Fill = Brushes.Red },
              new PenDescription("Angle variation"));

            
            plotter1.Viewport.FitToView();
        }
 public CompositeEnumerator(CompositeDataSource dataSource, DependencyObject context)
 {
     enumerators = dataSource.dataParts.Select(part => part.GetEnumerator(context)).ToList();
 }
        private void PlotNormalDistribution(double[] data, Histogram histogram, string distributionName, Color color)
        {
            if (data == null || histogram == null)
                return;

            var points = 50;

            var normalDistribution = new NormalDistribution(data.Average(), Math.Variance(data), points, histogram.LowerBound, histogram.UpperBound);

            //var normalDistribution = new NormalDistribution(histogram.Mean(), histogram.Variance(), points, histogram.LowerBound, histogram.UpperBound);

            var densityCurve = normalDistribution.DensityCurve;

            var xValues = new double[points];
            var yValues = new double[points];

            for (var index = 0; index < points; index++)
            {
                xValues[index] = densityCurve[index, 0];
                yValues[index] = densityCurve[index, 1];
            }

            // Add data sources.
            var yDataSource = new EnumerableDataSource<double>(yValues);
            yDataSource.SetYMapping(Y => Y);
            yDataSource.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, Y => string.Format("Normal Value \n\n{0}", Y));

            var xDataSource = new EnumerableDataSource<double>(xValues);
            xDataSource.SetXMapping(X => X);

            var compositeDataSource = new CompositeDataSource(xDataSource, yDataSource);

            // MatchValuePlotter.Viewport.Restrictions.Add(new PhysicalProportionsRestriction { ProportionRatio = 500000 });
            var graph = ChartPlotter.AddLineGraph(compositeDataSource, color, 0.5, distributionName);

            // Cache for later usage (e.g. change visibility).
            if (graph != null)
                _histogramGraphs.Add(graph);
        }
Пример #27
0
		void UpdateFromDB()
		{
			var plotViewModel = DataContext as PlotViewModel;
			if (plotViewModel == null)
				return;

			if (updateCollectionTimer != null)
			{
				updateCollectionTimer.Tick -= Update;
				updateCollectionTimer.Stop();
			}
			plotter.Children.RemoveAll(typeof(MarkerPointsGraph));
			plotter.Children.RemoveAll(typeof(LineGraph));

			var orderedCurrentConsumptions = new List<CurrentConsumption>();
			try
			{
				orderedCurrentConsumptions = plotViewModel.CurrentConsumptions.OrderBy(x => x.DateTime).ToList();
			}
			catch
			{
				
			}
			var dates = new DateTime[orderedCurrentConsumptions.Count];
			var curents = new int[orderedCurrentConsumptions.Count];

			for (int i = 0; i < orderedCurrentConsumptions.Count; ++i)
			{
				dates[i] = orderedCurrentConsumptions[i].DateTime;
				curents[i] = orderedCurrentConsumptions[i].Current;
			}

			var datesDataSource = new EnumerableDataSource<DateTime>(dates);
			datesDataSource.SetXMapping(dateAxis.ConvertToDouble);

			var currentsDataSource = new EnumerableDataSource<int>(curents);
			currentsDataSource.SetYMapping(Convert.ToDouble);

			CompositeDataSource compositeDataSource = new CompositeDataSource(datesDataSource, currentsDataSource);

			plotter.AddLineGraph(compositeDataSource,
					  new Pen(Brushes.Green, 2),
					  new CirclePointMarker { Size = 5.0, Fill = Brushes.Red },
					  new PenDescription("Статистика токопотребления"));

			plotter.Viewport.FitToView();
		}
			public CompositeEnumerator(CompositeDataSource dataSource, DependencyObject context) {
				enumerators = dataSource.dataParts.Select(part => part.GetEnumerator(context)).ToList();
			}
Пример #29
0
        void waveIn_DataAvailable(object sender, WaveInEventArgs e)
        {
            if (init_inbetween)
            {
                inbetween = new float[e.BytesRecorded / 4 - buffersize];
                for (int i = 0; i < e.BytesRecorded / 4 - buffersize; i++)
                    inbetween[i] = 0;
                init_inbetween = false;
            }

            for (int index = 0; index < buffersize; index++)
            {
                int sample = (int)((e.Buffer[index * 4 + 3] << 24) |
                                        (e.Buffer[index * 4 + 2] << 16) |
                                        (e.Buffer[index * 4 + 1] << 8) |
                                        (e.Buffer[index*4 + 0]));

                float sample32 = sample / 2147483648f;

                if (index >= (buffersize - inbetween.Length))
                    sampledata[index] = inbetween[index - buffersize + inbetween.Length];
                else
                    sampledata[index] = sampledata[index+buffersize+inbetween.Length];
                sampledata[index+buffersize] = sample32;

            }

            inbetween = new float[e.BytesRecorded / 4 - buffersize];
            for (int i = buffersize; i < e.BytesRecorded / 4; i++)
            {
                int sample = (int)((e.Buffer[i * 4 + 3] << 24) |
                                        (e.Buffer[i * 4 + 2] << 16) |
                                        (e.Buffer[i * 4 + 1] << 8) |
                                        (e.Buffer[i * 4 + 0]));

                float sample32 = sample / 2147483648f;
                inbetween[i - buffersize] = sample32;
            }

            bufferFFT();
            if (graphing)
            {
                bins = new EnumerableDataSource<int>(bin);
                bins.SetXMapping(x => x);

                rawIn = new EnumerableDataSource<float>(sampledata);
                rawIn.SetYMapping(y => y);
                chart1.Children.RemoveAll<LineGraph>();
                CompositeDataSource comp1 = new CompositeDataSource(bins, rawIn);
                chart1.AddLineGraph(comp1, Colors.Red);

                fftIn = new EnumerableDataSource<double>(filteredindata);
                fftIn.SetYMapping(y => y);

                chart2.Children.RemoveAll<LineGraph>();
                CompositeDataSource comp2 = new CompositeDataSource(bins, fftIn);
                chart2.AddLineGraph(comp2, Colors.Red);
            }

            if (waveOut != null)
            {

                KF = new List<KeyFrequency>();
                for (int i = 0; i < frequencies.Count; i++)
                {
                    KF.Add(new KeyFrequency(frequencies.ElementAt(i), i + 1, 33, filteredindata, centerbins.ElementAt(i)));
                    velocity[i] = KF.ElementAt(i).state;

                }

            }
        }
        private void PlotPercentiles(List<double> measure, List<double> age, List<double> score)
        {
            try
            {
                bool useCustomColor = UseCustomCurveColors;

                plotter.Visibility = System.Windows.Visibility.Visible;
                //plotter.RemoveUserElements();// = new ChartPlotter();
                // load growth curves from the appropriate file
                List<GrowthCurvesPercentiles> percentilesList = LoadGrowthCurvesPercentiles();

                double[] C01 = new double[percentilesList.Count];
                double[] C1 = new double[percentilesList.Count];
                double[] C3 = new double[percentilesList.Count];
                double[] C5 = new double[percentilesList.Count];
                double[] C10 = new double[percentilesList.Count];
                double[] C15 = new double[percentilesList.Count];
                double[] C25 = new double[percentilesList.Count];
                double[] C50 = new double[percentilesList.Count];
                double[] C75 = new double[percentilesList.Count];
                double[] C85 = new double[percentilesList.Count];
                double[] C90 = new double[percentilesList.Count];
                double[] C95 = new double[percentilesList.Count];
                double[] C97 = new double[percentilesList.Count];
                double[] C99 = new double[percentilesList.Count];
                double[] C999 = new double[percentilesList.Count];
                double[] ages = new double[percentilesList.Count];

                if (percentilesList.Count <= 0)
                {
                    return;
                }

                for (int i = 0; i < percentilesList.Count; ++i)
                {
                    C01[i] = percentilesList[i].C01;
                    C1[i] = percentilesList[i].C1;
                    C3[i] = percentilesList[i].C3;
                    C5[i] = percentilesList[i].C5;
                    C10[i] = percentilesList[i].C10;
                    C15[i] = percentilesList[i].C15;
                    C25[i] = percentilesList[i].C25;
                    C50[i] = percentilesList[i].C50;
                    C75[i] = percentilesList[i].C75;
                    C85[i] = percentilesList[i].C85;
                    C90[i] = percentilesList[i].C90;
                    C95[i] = percentilesList[i].C95;
                    C97[i] = percentilesList[i].C97;
                    C99[i] = percentilesList[i].C99;
                    C999[i] = percentilesList[i].C999;
                    ages[i] = percentilesList[i].xaxis;
                }

                var C01DataSource = new EnumerableDataSource<double>(C01);
                C01DataSource.SetYMapping(y => y);

                var C1DataSource = new EnumerableDataSource<double>(C1);
                C1DataSource.SetYMapping(y => y);

                var C3DataSource = new EnumerableDataSource<double>(C3);
                C3DataSource.SetYMapping(y => y);

                var C5DataSource = new EnumerableDataSource<double>(C5);
                C5DataSource.SetYMapping(y => y);

                var C10DataSource = new EnumerableDataSource<double>(C10);
                C10DataSource.SetYMapping(y => y);

                var C15DataSource = new EnumerableDataSource<double>(C15);
                C15DataSource.SetYMapping(y => y);

                var C25DataSource = new EnumerableDataSource<double>(C25);
                C25DataSource.SetYMapping(y => y);

                var C50DataSource = new EnumerableDataSource<double>(C50);
                C50DataSource.SetYMapping(y => y);

                var C75DataSource = new EnumerableDataSource<double>(C75);
                C75DataSource.SetYMapping(y => y);

                var C85DataSource = new EnumerableDataSource<double>(C85);
                C85DataSource.SetYMapping(y => y);

                var C90DataSource = new EnumerableDataSource<double>(C90);
                C90DataSource.SetYMapping(y => y);

                var C95DataSource = new EnumerableDataSource<double>(C95);
                C95DataSource.SetYMapping(y => y);

                var C97DataSource = new EnumerableDataSource<double>(C97);
                C97DataSource.SetYMapping(y => y);

                var C99DataSource = new EnumerableDataSource<double>(C99);
                C99DataSource.SetYMapping(y => y);

                var C999DataSource = new EnumerableDataSource<double>(C999);
                C999DataSource.SetYMapping(y => y);

                var ageDataSource = new EnumerableDataSource<double>(ages);
                ageDataSource.SetXMapping(x => x);

                var ageMeasurementDataSource = new EnumerableDataSource<double>(age);
                ageMeasurementDataSource.SetXMapping(x => x);

                //var scoreDataSource = new EnumerableDataSource<double>(score);
                //scoreDataSource.SetXYMapping(

                var measureDataSource = new EnumerableDataSource<double>(measure);
                measureDataSource.SetYMapping(y => y);

                CompositeDataSource compositeDataSource0 = new
                  CompositeDataSource(ageDataSource, C01DataSource);
                CompositeDataSource compositeDataSource1 = new
                  CompositeDataSource(ageDataSource, C1DataSource);
                CompositeDataSource compositeDataSource2 = new
                  CompositeDataSource(ageDataSource, C3DataSource);
                CompositeDataSource compositeDataSource3 = new
                  CompositeDataSource(ageDataSource, C5DataSource);
                CompositeDataSource compositeDataSource4 = new
                  CompositeDataSource(ageDataSource, C10DataSource);
                CompositeDataSource compositeDataSource5 = new
                  CompositeDataSource(ageDataSource, C15DataSource);
                CompositeDataSource compositeDataSource6 = new
                  CompositeDataSource(ageDataSource, C25DataSource);
                CompositeDataSource compositeDataSource7 = new
                  CompositeDataSource(ageDataSource, C50DataSource);
                CompositeDataSource compositeDataSource8 = new
                  CompositeDataSource(ageDataSource, C75DataSource);
                CompositeDataSource compositeDataSource9 = new
                  CompositeDataSource(ageDataSource, C85DataSource);
                CompositeDataSource compositeDataSource10 = new
                  CompositeDataSource(ageDataSource, C90DataSource);
                CompositeDataSource compositeDataSource11 = new
                  CompositeDataSource(ageDataSource, C95DataSource);
                CompositeDataSource compositeDataSource12 = new
                  CompositeDataSource(ageDataSource, C97DataSource);
                CompositeDataSource compositeDataSource13 = new
                  CompositeDataSource(ageDataSource, C99DataSource);
                CompositeDataSource compositeDataSource14 = new
                  CompositeDataSource(ageDataSource, C999DataSource);

                CompositeDataSource compositeDataSourceMeasurement = new
                  CompositeDataSource(ageMeasurementDataSource, measureDataSource);

                if (C999[1] > 0)
                {
                    if (useCustomColor)
                    {
                        plotter.AddLineGraph(compositeDataSource14,
                            new Pen(new SolidColorBrush(CustomCurveColor), 1),
                            new PenDescription("99.9th Percentile"));
                    }
                    else
                    {
                        plotter.AddLineGraph(compositeDataSource14,
                            new Pen(new SolidColorBrush(colorRed), 1),
                            new PenDescription("99.9th Percentile"));
                    }
                }

                if (C99[1] > 0)
                {
                    if (useCustomColor)
                    {
                        plotter.AddLineGraph(compositeDataSource13,
                            new Pen(new SolidColorBrush(CustomCurveColor), 1),
                            new PenDescription("99th Percentile"));
                    }
                    else
                    {
                        plotter.AddLineGraph(compositeDataSource13,
                            new Pen(new SolidColorBrush(colorBrown), 1),
                            new PenDescription("99th Percentile"));
                    }
                }

                if (C97[1] > 0)
                {
                    if (useCustomColor)
                    {
                        plotter.AddLineGraph(compositeDataSource12,
                          new Pen(new SolidColorBrush(CustomCurveColor), 1),
                          new PenDescription("97th Percentile"));
                    }
                    else
                    {
                        plotter.AddLineGraph(compositeDataSource12,
                          new Pen(new SolidColorBrush(colorRed), 1),
                          new PenDescription("97th Percentile"));
                    }
                }

                if (C95[1] > 0)
                {
                    if (useCustomColor)
                    {
                        plotter.AddLineGraph(compositeDataSource11,
                          new Pen(new SolidColorBrush(CustomCurveColor), 1),
                          new PenDescription("95th Percentile"));
                    }
                    else
                    {
                        plotter.AddLineGraph(compositeDataSource11,
                          new Pen(new SolidColorBrush(colorOrange), 1),
                          new PenDescription("95th Percentile"));
                    }
                }

                if (C90[1] > 0)
                {
                    if (useCustomColor)
                    {
                        plotter.AddLineGraph(compositeDataSource10,
                          new Pen(new SolidColorBrush(CustomCurveColor), 1),
                          new PenDescription("90th Percentile"));
                    }
                    else
                    {
                        plotter.AddLineGraph(compositeDataSource10,
                          new Pen(new SolidColorBrush(colorBrown), 1),
                          new PenDescription("90th Percentile"));
                    }
                }

                if (C85[1] > 0)
                {
                    if (useCustomColor)
                    {
                        plotter.AddLineGraph(compositeDataSource9,
                          new Pen(new SolidColorBrush(CustomCurveColor), 1),
                          new PenDescription("85th Percentile"));
                    }
                    else
                    {
                        plotter.AddLineGraph(compositeDataSource9,
                          new Pen(new SolidColorBrush(colorBlue), 1),
                          new PenDescription("85th Percentile"));
                    }
                }

                if (C75[1] > 0)
                {
                    if (useCustomColor)
                    {
                        plotter.AddLineGraph(compositeDataSource8,
                          new Pen(new SolidColorBrush(CustomCurveColor), 1),
                          new PenDescription("75th Percentile"));
                    }
                    else
                    {
                        plotter.AddLineGraph(compositeDataSource8,
                          new Pen(new SolidColorBrush(colorPurple), 1),
                          new PenDescription("75th Percentile"));
                    }
                }

                if (C50[1] > 0)
                {
                    if (useCustomColor)
                    {
                        plotter.AddLineGraph(compositeDataSource7,
                          new Pen(new SolidColorBrush(CustomCurveColor), 2),
                          new PenDescription("50th Percentile"));
                    }
                    else
                    {
                        plotter.AddLineGraph(compositeDataSource7,
                          new Pen(new SolidColorBrush(colorGreen), 1),
                          new PenDescription("50th Percentile"));
                    }
                }

                if (C25[1] > 0)
                {
                    if (useCustomColor)
                    {
                        plotter.AddLineGraph(compositeDataSource6,
                          new Pen(new SolidColorBrush(CustomCurveColor), 1),
                          new PenDescription("25th Percentile"));
                    }
                    else
                    {
                        plotter.AddLineGraph(compositeDataSource6,
                          new Pen(new SolidColorBrush(colorPurple), 1),
                          new PenDescription("25th Percentile"));
                    }
                }

                if (C15[1] > 0)
                {
                    if (useCustomColor)
                    {
                        plotter.AddLineGraph(compositeDataSource5,
                          new Pen(new SolidColorBrush(CustomCurveColor), 1),
                          new PenDescription("15th Percentile"));
                    }
                    else
                    {
                        plotter.AddLineGraph(compositeDataSource5,
                          new Pen(new SolidColorBrush(colorBlue), 1),
                          new PenDescription("15th Percentile"));
                    }
                }

                if (C10[1] > 0)
                {
                    if (useCustomColor)
                    {
                        plotter.AddLineGraph(compositeDataSource4,
                          new Pen(new SolidColorBrush(CustomCurveColor), 1),
                          new PenDescription("10th Percentile"));
                    }
                    else
                    {
                        plotter.AddLineGraph(compositeDataSource4,
                          new Pen(new SolidColorBrush(colorBrown), 1),
                          new PenDescription("10th Percentile"));
                    }
                }

                if (C5[1] > 0)
                {
                    if (useCustomColor)
                    {
                        plotter.AddLineGraph(compositeDataSource3,
                          new Pen(new SolidColorBrush(CustomCurveColor), 1),
                          new PenDescription("5th Percentile"));
                    }
                    else
                    {
                        plotter.AddLineGraph(compositeDataSource3,
                          new Pen(new SolidColorBrush(colorOrange), 1),
                          new PenDescription("5th Percentile"));
                    }
                }

                if (C3[1] > 0)
                {
                    if (useCustomColor)
                    {
                        plotter.AddLineGraph(compositeDataSource2,
                          new Pen(new SolidColorBrush(CustomCurveColor), 1),
                          new PenDescription("3rd Percentile"));
                    }
                    else
                    {
                        plotter.AddLineGraph(compositeDataSource2,
                          new Pen(new SolidColorBrush(colorRed), 1),
                          new PenDescription("3rd Percentile"));
                    }
                }

                if (C1[1] > 0)
                {
                    if (useCustomColor)
                    {
                        plotter.AddLineGraph(compositeDataSource1,
                      new Pen(new SolidColorBrush(CustomCurveColor), 1),
                      new PenDescription("1st Percentile"));
                    }
                    else
                    {
                        plotter.AddLineGraph(compositeDataSource1,
                      new Pen(new SolidColorBrush(colorBrown), 1),
                      new PenDescription("1st Percentile"));
                    }
                }

                if (C01[1] > 0)
                {
                    if (useCustomColor)
                    {
                        plotter.AddLineGraph(compositeDataSource0,
                      new Pen(new SolidColorBrush(CustomCurveColor), 1),
                      new PenDescription("0.1st Percentile"));
                    }
                    else
                    {
                        plotter.AddLineGraph(compositeDataSource0,
                      new Pen(new SolidColorBrush(colorRed), 1),
                      new PenDescription("0.1st Percentile"));
                    }
                }

                Pen patientPen = new Pen(new SolidColorBrush(colorBlack), 2);
                patientPen.DashStyle = DashStyles.Dash;

                    plotter.AddLineGraph(compositeDataSourceMeasurement,
                        patientPen,
                        new CirclePointMarker
                        {
                            Size = 5,
                            Pen = new Pen(new SolidColorBrush(colorBlack), 2),
                            Fill = Brushes.Transparent
                        },
                        new PenDescription(patientLabel));

                //if (config.ShowDataPointLabels)
                //{
                //    ///////////////////////////////
                //    for (int i = 0; i < age.Count; i++)
                //    {
                //        List<double> ageLabel = new List<double>();
                //        List<double> measureLabel = new List<double>();
                //        string percentile = String.Format("{0:0.00}", score[i]);

                //        ageLabel.Add(age[i]);
                //        measureLabel.Add(measure[i]);

                //        var ageMeasurementDataSourceLabel = new EnumerableDataSource<double>(ageLabel);
                //        ageMeasurementDataSourceLabel.SetXMapping(x => x);

                //        var measureDataSourceLabel = new EnumerableDataSource<double>(measureLabel);
                //        measureDataSourceLabel.SetYMapping(y => y);

                //        ds.Add(new CompositeDataSource(ageMeasurementDataSourceLabel, measureDataSourceLabel));

                //        chart.Add(plotter.AddLineGraph(ds[i],
                //            null,
                //            new CenteredTextMarker
                //            {
                //                Text = " " + percentile + " "
                //            },
                //            new PenDescription(score[i].ToString())));
                //    }
                //    ////////////////////////////////
                //}

                //chart.MarkerGraph.DataSource = null;

                xAxis.ShowMinorTicks = true;
                yAxis.ShowMinorTicks = true;
                plotter.AxisGrid.DrawVerticalMinorTicks = false;
                plotter.AxisGrid.DrawHorizontalMinorTicks = false;
                plotter.Legend.LegendLeft = 45;
                plotter.Legend.LegendRight = Double.NaN;

                if (!ShowLegend)
                {
                    plotter.Legend.Visibility = Visibility.Hidden;
                }
                else
                {
                    plotter.Legend.Visibility = Visibility.Visible;
                }

                //if (config.ShowCoordinateCursor)
                //{
                    //plotter.Children.Add(new CursorCoordinateGraph());
                //}
                plotter.Viewport.FitToView();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #31
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            dealData.ReadInterestRate(out dates, out interestRate);
            datesDataSource = new EnumerableDataSource<DateTime>(dates);
            datesDataSource.SetXMapping(x => dateAxis.ConvertToDouble(x));
            interestRateDataSource = new EnumerableDataSource<decimal>(interestRate);
            interestRateDataSource.SetYMapping(y => interestAxis.ConvertToDouble((int)(y * 100)) / 100);

            var compositeDataSource = new CompositeDataSource(datesDataSource, interestRateDataSource);

            plotter.AddLineGraph(compositeDataSource,Colors.Green,1,"Interest Rate");

            plotter.Viewport.FitToView();

            timer.Interval = TimeSpan.FromSeconds(6);
            timer.Tick += new EventHandler(GetHttpData);
            timer.IsEnabled = true;
        }