public void ChangeText(string msg, string time)
        {
            MessageView.Text = msg;
            TimeView.Text    = "Roundtrip Time: " + time;

            DataPointsBuffer.Enqueue(new DataPoint(TimePoint++, int.Parse(msg)));             //DateTime.Now.ToUniversalTime().Millisecond
            if (DataPointsBuffer.Count > 10)
            {
                DataPoint popPoint;
                DataPointsBuffer.TryDequeue(out popPoint);
            }

            var series1 = new OxyPlot.Series.LineSeries
            {
                MarkerType   = OxyPlot.MarkerType.Circle,
                MarkerSize   = 4,
                MarkerStroke = OxyPlot.OxyColors.White
            };

            foreach (var datapoint in DataPointsBuffer)
            {
                series1.Points.Add(datapoint);
            }

            plotModel.Series.Clear();
            plotModel.Series.Add(series1);
            plotModel.InvalidatePlot(true);
        }
示例#2
1
	    public void DrawPoints()
	    {
		    if (Opt.Points == null)
			    throw new NullReferenceException("No any points!");
		    foreach (var poinInfo in Opt.Points)
		    {
			    if (poinInfo.IsPointVisible)
			    {
					var pointLine = new LineSeries
					{
						StrokeThickness = 4,
						Smooth = true,
						Color = OxyColor.FromRgb(0, 0, 0),
						Points = new List<IDataPoint>()
					};
					pointLine.Points.Add(new DataPoint(poinInfo.Point.X, poinInfo.Point.Y));
					_mainPlot.Series.Add(pointLine);  
			    }
				if (poinInfo.Label != null)
				{
					var stringLabel = new OxyPlot.Annotations.TextAnnotation
					{
						Text = poinInfo.Label,
						Position = new DataPoint(poinInfo.Point.X + 2, poinInfo.Point.Y + 2),
						TextColor = OxyColor.FromArgb(0, 0, 0, 0),
						StrokeThickness = 0,
						Stroke = OxyColor.FromArgb(0, 255, 255, 255),
						FontSize = 25
					};
					_mainPlot.Annotations.Add(stringLabel);
				}
		    }
	    }
示例#3
0
        void _presenter_MetricsUpdated(object sender, Presenters.TeamCityMetricsEventArgs e)
        {
            Dispatcher.Invoke(new Action(() =>
            {
                messageText.Visibility = System.Windows.Visibility.Hidden;
                graph.Visibility       = System.Windows.Visibility.Visible;

                var data = this.DataContext as ViewCommon.ZeroToAutoScaleByDateGraphModel;
                if (data != null)
                {
                    var series = data.Model.Series;
                    series.Clear();

                    foreach (var metricSeries in e.Series)
                    {
                        var seriesData = new OxyPlot.Series.LineSeries {
                            Title = metricSeries.Name
                        };
                        seriesData.MarkerType = OxyPlot.MarkerType.Circle;
                        seriesData.MarkerSize = 4;
                        foreach (var metricPoint in metricSeries.Points)
                        {
                            seriesData.Points.Add(OxyPlot.Axes.DateTimeAxis.CreateDataPoint(metricPoint.X, metricPoint.Y));
                        }
                        seriesData.StrokeThickness = 4;
                        series.Add(seriesData);
                    }
                }

                graph.Model.InvalidatePlot(true);
            }));
        }
示例#4
0
        public ChartVm(Cache cache, string name)
        {
            PlotData = new PlotModel {
                Title = $"{Localization.Chart}: {name}"
            };

            _cache = cache;
            _data  = new LineSeries();

            foreach (var element in cache.GetAll())
            {
                var time = DateTimeAxis.ToDouble(element.Stamp);
                _data.Points.Add(new DataPoint(time, element.Value));
            }

            PlotData.Axes.Add(new DateTimeAxis {
                StringFormat = "mm:ss"
            });
            PlotData.Axes.Add(new LinearAxis {
                Maximum = 100, Minimum = 0
            });
            PlotData.Series.Add(_data);

            _cache.OnValuesChanged += OnValuesChanged;
        }
示例#5
0
        static void DisplayActions(NetworkModel model, OxyPlot.Series.LineSeries series = null)
        {
            Console.WriteLine("\n\nActions:");
            Console.WriteLine("[Any key] Run | [Q]uit | [S]ave | [D]elete");
            Console.WriteLine("");

            switch (Console.ReadKey(true).Key)
            {
            case ConsoleKey.Q:
            {
                Environment.Exit(0);
                break;
            }

            case ConsoleKey.S:
            {
                SaveModel(model, series);
                Environment.Exit(0);
                break;
            }

            case ConsoleKey.D:
            {
                DeleteModel(model);
                Environment.Exit(0);
                break;
            }
            }
        }
示例#6
0
        static void SaveModel(NetworkModel model, OxyPlot.Series.LineSeries series = null)
        {
            Console.WriteLine("\nSaving model...");
            if (series != null)
            {
                try
                {
                    var graphPoints = new List <Vector <double> >();

                    foreach (var point in series.Points)
                    {
                        graphPoints.Add(Vector <double> .Build.Dense(new double[] { point.Y }));
                    }

                    DelimitedWriter.Write(model.Path("graph"), Matrix <double> .Build.DenseOfRowVectors(graphPoints));

                    Console.WriteLine("Saved graph data");
                }
                catch
                {
                    Console.WriteLine("Unable to save graph data");
                }
            }
            model.Save();
            Console.WriteLine("Model has been saved.");
        }
        public void GetItemSalesChartForSingleItem()
        {
            try
            {
                PlotModel = new PlotModel();
                SetUpModelNew();
                var dataPerDetector = OrderDetails.Where(a => a.BeverageId == SelectedBeverage.BeverageId).Take(10).OrderBy(a => a.SaleDate.Date)
                                      .GroupBy(m => m.SaleDate.Date).Select(g => new { Total = g.Sum(p => p.Quantity), date = g.Key, Item = g.Select(a => a.Beverage.Name).FirstOrDefault() }).ToList();

                //string bevname = GetBeverageName(data.Key);
                var lineSerie = new OxyPlot.Series.LineSeries
                {
                    ToolTip = string.Format(" {0} Sales", dataPerDetector.Select(a => a.Item).FirstOrDefault()),
                    // LabelFormatString = string.Format("{0} Sales", dataPerDetector.Select(a => a.Item).FirstOrDefault()),
                    StrokeThickness = 1,
                    MarkerSize      = 3,
                    //MarkerStroke = OxyColor.FromUInt32((uint)data.Key),

                    MarkerType = MarkerType.Diamond,// markerTypes[data.Key],
                    CanTrackerInterpolatePoints = false,
                    Title = string.Format("{0} Sales", dataPerDetector.Select(a => a.Item).FirstOrDefault())
                };
                dataPerDetector.ForEach(d => lineSerie.Points.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(d.date), d.Total)));
                PlotModel.Series.Add(lineSerie);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public void GetItemSalesChart()
 {
     try
     {
         foreach (var item in Beverages)
         {
             var dataPerDetector = OrderDetails.Where(a => a.BeverageId == item.BeverageId).OrderByDescending(m => m.SaleDate.Date).GroupBy(m => m.SaleDate.Date).
                                   Select(g => new { Total = g.Sum(p => p.Quantity), date = g.Key }).Take(100).ToList();
             var lineSerie = new OxyPlot.Series.LineSeries
             {
                 // LabelFormatString = item.ItemName,
                 StrokeThickness             = 1,
                 MarkerSize                  = 3,
                 MarkerStroke                = OxyColor.FromUInt32((UInt32)item.BeverageId),
                 MarkerType                  = MarkerType.Diamond,
                 CanTrackerInterpolatePoints = false,
                 Title   = item.Name,
                 ToolTip = item.Name
             };
             foreach (var item2 in dataPerDetector)
             {
                 lineSerie.Points.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(item2.date), (double)item2.Total));
             }
             PlotModel.Series.Add(lineSerie);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#9
0
        private void PlotLinearRegression(List <GPoint> points)
        {
            var ls = new OxyPlot.Series.LineSeries()
            {
                MarkerType   = ShowMarker ? MarkerType.None : MarkerType.Plus,
                MarkerStroke = OxyPlot.OxyColors.Blue
            };

            LinearFunction func;

            if (LinearRegression.Regression(points.ToArray(), out func))
            {
                int    TOTAL = 10;
                double x     = points.First().X;
                double stepX = (points.Last().X - x) / TOTAL;
                for (int i = 0; i <= TOTAL; i++)
                {
                    double y = func.Slope * x + func.Intercept;
                    ls.Points.Add(new OxyPlot.DataPoint(x, y));
                    x += stepX;
                }
                ls.Title = $"Linear Regression(R: {func.CorrelationCoeff:f5})";
            }
            else
            {
                ls.Title = "Linear Regression(Failed)";
            }

            base.Series.Add(ls);
        }
示例#10
0
        private void PlotBezierTangentByDegree(List <GPoint> points)
        {
            base.Axes.Add(new OxyPlot.Axes.LinearAxis
            {
                Title    = "Tangent of Bezier(Degree)",
                Position = OxyPlot.Axes.AxisPosition.Left
            });
            AddZeroLineAnnotation();

            OxyPlot.Series.LineSeries ls = new OxyPlot.Series.LineSeries()
            {
                Title        = "Tangent of Bezier(Degree)",
                MarkerType   = ShowMarker ? MarkerType.None : MarkerType.Plus,
                MarkerStroke = OxyPlot.OxyColors.Blue
            };

            int        degree  = points.Count - 1;
            NURBSCurve bspline = new NURBSCurve(points, degree);

            for (double u = 0; u <= 1.0; u += 0.01)
            {
                double tangent = bspline.TangentByDegree(u);
                ls.Points.Add(new OxyPlot.DataPoint(u * 100.0, tangent));
            }

            base.Series.Add(ls);
        }
示例#11
0
        private void PlotSimplifyCurvature(List <GPoint> curvatures)
        {
            OxyPlot.Series.LineSeries ls = new OxyPlot.Series.LineSeries()
            {
                Title        = "Direct Simplication",
                MarkerType   = ShowMarker ? MarkerType.None : MarkerType.Diamond,
                MarkerStroke = OxyPlot.OxyColors.Pink
            };
            List <GPoint> simplified1 = SimplifyPolyline(curvatures, 0);

            foreach (var p in simplified1)
            {
                ls.Points.Add(new OxyPlot.DataPoint(p.X, p.Y));
            }

            base.Series.Add(ls);

            // Plot maneuvers
            curvatures.ForEach(x => x.W = x.X); // X is distance
            List <GPoint> simplified2 = SimplifyPolyline(curvatures, CurveManeuverParameter.CurveMinDistance);
            List <GPoint> maneuvers   = PolylineSimplication.SimplifyHeadingChange(simplified2.ToArray(), CurveManeuverParameter.YTolerance);

            AddScatterSeries(maneuvers, "Maneuvers");
            PlotSameRanges(maneuvers);
        }
示例#12
0
        private void UpdateHistogram()
        {
            HistogramProcessing histogramProcessing = new HistogramProcessing();

            int[]     histogram      = histogramProcessing.GetHistogram(Image);
            PlotModel histogramModel = new PlotModel();

            OxyPlot.Series.LineSeries columnSeries = new OxyPlot.Series.LineSeries()
            {
                Color = OxyColor.FromRgb(0, 0, 0),
            };

            for (int i = 0; i < histogram.Length; i++)
            {
                columnSeries.Points.Add(new DataPoint(i, histogram[i]));
            }
            histogramModel.Series.Clear();
            histogramModel.Series.Add(columnSeries);

            histogramModel.Axes.Add(new LinearAxis
            {
                Position = AxisPosition.Bottom,
                Minimum  = -1,
                Maximum  = 257
            });
            histogramModel.Axes.Add(new LinearAxis
            {
                Position = AxisPosition.Left,
                Minimum  = -1
            });

            histogramView.Model = histogramModel;
        }
        protected override void RemoveSignal(OxyPlot.Series.Series series)
        {
            if (series == null)
            {
                return;
            }

            PlotSignalModel signal = (PlotSignalModel)series.Tag;

            //this.paneModel.Signals.Remove(signal);

            PlotModel.Series.Remove(series);

            OxyPlot.Series.LineSeries lax = series as OxyPlot.Series.LineSeries;
            if (lax != null)
            {
                PlotModel.Axes.Remove(lax.YAxis);
            }

            if (SelectedSeries == series)
            {
                SelectedSeries = null;
            }

            PlotModel.InvalidatePlot(false);
        }
示例#14
0
        //public static Series<DateTime, double> GetData(string filePath, string column = "open")
        //{

        //    var frame = Deedle.Frame.ReadCsv(filePath);
        //    string key = frame.ColumnKeys.SingleOrDefault(_ => String.Equals(_, "date", StringComparison.CurrentCultureIgnoreCase));
        //    if (key == null)
        //        throw new Exception("no date column in data");
        //    var frameDate = frame.IndexRows<DateTime>(key).SortRowsByKey();
        //    return frameDate.GetColumn<double>(column);

        //}

        public static PlotModel GetPlotModel(Series <DateTime, double> series)
        {
            var model = new PlotModel()
            {
                LegendSymbolLength = 24
            };
            var s1 = new OxyPlot.Series.LineSeries()
            {
                Color                 = OxyColors.SkyBlue,
                MarkerType            = MarkerType.Square,
                MarkerSize            = 2,
                MarkerStroke          = OxyColors.White,
                MarkerFill            = OxyColors.Blue,
                MarkerStrokeThickness = 1.5
            };

            model.Series.Add(s1);

            //
            foreach (var s in series.Observations)
            {
                s1.Points.Add(new DataPoint((s.Key - default(DateTime)).TotalHours, s.Value));
            }
            return(model);
        }
示例#15
0
        public MainViewModel()
        {
            TempDataPoints = new ObservableCollection <DataPoint>();
            HumiDataPoints = new ObservableCollection <DataPoint>();

            Model = new PlotModel()
            {
                Title = "Simple Example", Subtitle = "using OxyPlot"
            };
            var series1 = new LineSeries {
                Title = "梁業", MarkerType = MarkerType.Circle, Smooth = true
            };
            var series2 = new LineSeries {
                Title = "物業", MarkerType = MarkerType.Star, Smooth = true, MarkerStroke = OxyColors.Red
            };
            var dateTimeAxis1 = new DateTimeAxis();

            dateTimeAxis1.Title = "Time";
            Model.Axes.Add(dateTimeAxis1);
            Model.Series.Add(series1);
            Model.Series.Add(series2);

            Random rd = new Random();

            Task.Run(
                () =>
            {
                while (true)
                {
                    series1.Points.Add(DateTimeAxis.CreateDataPoint(DateTime.Now, rd.Next(10, 30)));
                    series2.Points.Add(DateTimeAxis.CreateDataPoint(DateTime.Now, rd.Next(10, 30)));
                    if (series1.Points.Count > 100)
                    {
                        series1.Points.RemoveAt(0);
                        series2.Points.RemoveAt(0);
                    }
                    Model.InvalidatePlot(true);
                    Thread.Sleep(1000);
                }
            });
            Task.Run(
                () =>
            {
                while (true)
                {
                    var date = DateTime.Now;
                    App.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        TempDataPoints.Add(DateTimeAxis.CreateDataPoint(date, (double)(rd.Next(100, 500) / 10.0)));
                        HumiDataPoints.Add(DateTimeAxis.CreateDataPoint(date, (double)(rd.Next(500, 800) / 10.0)));
                        if (TempDataPoints.Count > 300)
                        {
                            TempDataPoints.RemoveAt(0);
                            HumiDataPoints.RemoveAt(0);
                        }
                    }));
                    Thread.Sleep(1000);
                }
            });
        }
示例#16
0
        public int AddLineSeries(string title, string description = "", bool isVisible = true)
        {
            //TODO: improve how to limit the number of plots
            //For now, we just ignore series after the max number has been reached
            if (Plot.Series.Count < m_maxNumSeries)
            {
                if (m_lineSeriesLock == null) //might be null if loaded from file
                {
                    m_lineSeriesLock = new object();
                }
                lock (m_lineSeriesLock)
                {
                    OxyPlot.Series.LineSeries newSeries = new OxyPlot.Series.LineSeries {
                        Title = title, MarkerType = MarkerType.None
                    };
                    newSeries.IsVisible = isVisible;
                    Plot.Series.Add(newSeries);

                    PlotLineSeriesPropertiesViewModel lineProps = Properties.LineSeriesByName(title);

                    if (lineProps == null)
                    {
                        Properties.AddLineSeries(title, description, newSeries);
                    }
                    else
                    {
                        lineProps.LineSeries = newSeries;
                    }

                    return(Plot.Series.Count - 1);;
                }
            }
            return(-1);
        }
示例#17
0
    public MainWindow()
    {
        InitializeComponent();
        DataContext = new ViewModel();
        plotModel   = new PlotModel {
            Title = "OxyPlot"
        };
        plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis {
            Position = OxyPlot.Axes.AxisPosition.Bottom
        });
        plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis {
            Position = OxyPlot.Axes.AxisPosition.Left, Maximum = 10, Minimum = 0
        });
        var series1 = new OxyPlot.Series.LineSeries
        {
            MarkerType   = MarkerType.Circle,
            MarkerSize   = 5,
            MarkerStroke = OxyColors.White
        };

        series1.Points.Add(new DataPoint(0, 6));
        series1.Points.Add(new DataPoint(1, 2));
        series1.Points.Add(new DataPoint(2, 4));
        series1.Points.Add(new DataPoint(3, 2));
        series1.Points.Add(new DataPoint(4, 7));
        series1.Points.Add(new DataPoint(6, 6));
        series1.Points.Add(new DataPoint(8, 8));
        series1.Smooth = true;
        plotModel.Series.Add(series1);
        this.Content = new OxyPlot.Wpf.PlotView()
        {
            Model = plotModel
        };
        plotModel.MouseDown += PlotModel_MouseDown;
    }
        private void FillSerie(object data)
        {
            Task.Factory.StartNew(() =>
            {
                PlotModel.Series.Clear();
                OxyPlot.Series.LineSeries lineSerie = new OxyPlot.Series.LineSeries
                {
                    StrokeThickness             = 2,
                    CanTrackerInterpolatePoints = true,
                    Smooth = true,
                };
                PlotModel.Series.Add(lineSerie);

                double[] samples = data as double[];

                var points   = new List <DataPoint>();
                double xPos  = 0;
                double xStep = 1;
                for (int i = 0; i < samples.Length; i++)
                {
                    double y = samples[i];
                    points.Add(new DataPoint(xPos, y));
                    xPos += xStep;
                }
                lineSerie.ItemsSource = points;

                PlotModel.InvalidatePlot(true);
            });
        }
示例#19
0
        public void GetTotalSalesChart()
        {
            try
            {
                ChartHeader     = "Sales Chart";
                PlotModel.Title = ChartHeader;
                var dataPerDetector = Orders.OrderBy(m => m.SaleDate.Date).GroupBy(m => m.SaleDate.Date).
                                      Select(g => new { Total = g.Sum(p => p.TotalAmount), date = g.Key }).ToList();

                var lineSerie = new OxyPlot.Series.LineSeries
                {
                    // LabelFormatString = dataPerDetector.Select(a=>a.Total).FirstOrDefault().ToString(),
                    StrokeThickness = 1,
                    MarkerSize      = 3,
                    //MarkerStroke = OxyColors.Red,
                    MarkerType = MarkerType.Diamond,
                    CanTrackerInterpolatePoints = false,
                    Title  = "Sales",
                    Smooth = false,
                };
                foreach (var item in dataPerDetector)
                {
                    lineSerie.Points.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(item.date), (double)item.Total));
                }

                PlotModel.Series.Add(lineSerie);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#20
0
        public PlotWindow(List <List <double> > results)
        {
            var plotModel = new OxyPlot.PlotModel();

            plotModel.Title = "Mean Absolute Validation Error Per Fold";

            plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis()
            {
                Position = OxyPlot.Axes.AxisPosition.Left, Title = "Error"
            });
            plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis()
            {
                Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "Epochs"
            });

            var colors = new OxyPlot.OxyColor[] { OxyPlot.OxyColors.Blue, OxyPlot.OxyColors.Green, OxyPlot.OxyColors.Red, OxyPlot.OxyColors.Black };

            for (int row = 0; row < results.Count; row++)
            {
                var lineSeries = new OxyPlot.Series.LineSeries();
                lineSeries.ItemsSource = results[row].Select((value, index) => new OxyPlot.DataPoint(index, value));
                lineSeries.Title       = string.Format("Fold {0}/{1}", row + 1, results.Count);
                lineSeries.Color       = colors[row];
                plotModel.Series.Add(lineSeries);
            }

            var plotView = new OxyPlot.Wpf.PlotView();

            plotView.Model = plotModel;

            Title   = "Chart";
            Content = plotView;
        }
示例#21
0
 public PlotLineSeriesPropertiesViewModel(string name, string description, OxyPlot.Series.LineSeries lineSeries)
 {
     LineSeries  = lineSeries;
     Visible     = true;
     Name        = Herd.Utils.OxyPlotMathNotation(name);
     Description = description;
 }
 public DataLoading()
 {
     TestCommand = new RelayCommand(() => ShowActualPoints());
     PlotModel   = new PlotModel();
     X           = new OxyPlot.Axes.LinearAxis()
     {
         Position = OxyPlot.Axes.AxisPosition.Bottom,
         Minimum  = 1,
         Maximum  = 5
     };
     Y = new OxyPlot.Axes.LinearAxis()
     {
         Position     = OxyPlot.Axes.AxisPosition.Left,
         IsPanEnabled = false
     };
     FirstSeries  = new OxyPlot.Series.LineSeries();
     SecondSeries = new OxyPlot.Series.LineSeries();
     FirstLoad();
     PlotModel.Axes.Add(X);
     PlotModel.Axes.Add(Y);
     OxyPlot.Wpf.PlotView PV = new OxyPlot.Wpf.PlotView();
     PlotModel.Axes[0].AxisChanged += (o, e) =>
     {
         double LastPoint = (from y in FirstSeries.Points select y.X).Min();
         ShowActuals(LastPoint);
     };
 }
示例#23
0
        public TemperaturePlotWindow(float[] temperature)
        {
            var plotModel = new OxyPlot.PlotModel();

            plotModel.Title = "Temperature";

            plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis()
            {
                Position = OxyPlot.Axes.AxisPosition.Left, Title = "Celcius"
            });
            //plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "Epochs" });

            var labels     = new string[] { "Temperature" };
            var colors     = new OxyPlot.OxyColor[] { OxyPlot.OxyColors.Blue };
            var lineSeries = new OxyPlot.Series.LineSeries();

            lineSeries.ItemsSource = temperature.Select((value, index) => new OxyPlot.DataPoint(index, value));
            lineSeries.Title       = labels[0];
            lineSeries.Color       = colors[0];
            plotModel.Series.Add(lineSeries);

            var plotView = new OxyPlot.Wpf.PlotView();

            plotView.Model = plotModel;

            Content = plotView;
        }
示例#24
0
		public void DrawCurves()
		{
			if (Opt.Curves == null)
				throw new NullReferenceException("No any curves!");
			foreach (var func in Opt.Curves)
			{
				var line = new LineSeries
				{
					StrokeThickness = 2,
					Smooth = true,
					Color = OxyColor.FromRgb(0, 0, 0),
					LineStyle = func.Style,
					Points = new List<IDataPoint>(),
					Title = func.Caption
				};

				var i = (double)Opt.Diapason.FromX;
				if (!func.InvertFunc)
					while (i <= Opt.Diapason.ToX)
					{
						line.Points.Add(new DataPoint(i, func.Function(i)));
						i += Opt.Step;
					}
				else
					while (i <= Opt.Diapason.ToY)
					{
						line.Points.Add(new DataPoint(func.Function(i), i));
						i += Opt.Step;
					}
				_mainPlot.Series.Add(line);
			}
		}
示例#25
0
        private void CreateSamplePointsLineSeries()
        {
            var lineSerie = new LineSeries
            {
                LineStyle  = LineStyle.Solid,
                Color      = OxyColor.FromRgb(255, 0, 0),
                DataFieldX = "xData",
                DataFieldY = "yData"
            };
            var testLineSerie = new LineSeries
            {
                LineStyle  = LineStyle.Solid,
                Color      = OxyColor.FromRgb(0, 255, 0),
                DataFieldX = "xData",
                DataFieldY = "yData"
            };


            for (var i = 0; i < _totalTestErrors.Count; i++)
            {
                var error = _totalTestErrors[i];
                testLineSerie.Points.Add(new DataPoint(i, error));
            }

            for (var i = 0; i < _totalErrors.Count; i++)
            {
                var error = _totalErrors[i];
                lineSerie.Points.Add(new DataPoint(i, error));
            }

            PlotModel.Series.Add(lineSerie);
            PlotModel.Series.Add(testLineSerie);
        }
示例#26
0
            public void LineSeries()
            {
                var s1 = new OxyPlot.Series.LineSeries();
                var s2 = new LineSeries();

                OxyAssert.PropertiesAreEqual(s1, s2);
            }
示例#27
0
        public void saveChart(List <Individual> individuals)
        {
            var line1 = new OxyPlot.Series.LineSeries
            {
                Title           = $"Y",
                Color           = OxyColors.Blue,
                StrokeThickness = 1,
                MarkerSize      = 2,
                MarkerType      = MarkerType.Circle
            };

            for (int i = 0; i < individuals.Count; i++)
            {
                line1.Points.Add(new DataPoint(i + 1, individuals[i].FunctionResult));
            }

            var model = new PlotModel
            {
                Title = $"wykres wartosci funkcji w zaleznosci od epok",
            };

            model.Series.Add(line1);
            var chartName = Directory.GetCurrentDirectory() + "\\results\\chart" + DateTime.Now.ToString("yyyy-dd-M--HH-mm-ss") + ".pdf";

            using (var stream = File.Create(chartName))
            {
                var pdfExporter = new PdfExporter {
                    Width = 600, Height = 400
                };
                pdfExporter.Export(model, stream);
            };
        }
        private PlotModel _createChart(SlackChannel channel)
        {
            PlotModel chart = new PlotModel {
                LegendPosition = LegendPosition.RightTop, LegendPlacement = LegendPlacement.Outside
            };

            chart.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, Minimum = 40, Maximum = 110
            });
            foreach (KeyValuePair <SlackUser, List <bool> > pair in _data[channel])
            {
                LineSeries series = new LineSeries {
                    MarkerType = MarkerType.Circle
                };
                int numberOfTimesThere = 0;
                for (int j = 0; j < pair.Value.Count; j++)
                {
                    numberOfTimesThere += pair.Value[j] ? 1 : 0;
                    DataPoint nextPoint = new DataPoint(j + 1, (float)numberOfTimesThere * 100 / (j + 1));
                    series.Points.Add(nextPoint);
                }
                series.Title = pair.Key.Name + " (" + Math.Round(series.Points.Last().Y, 2) + "%)";
                chart.Series.Add(series);
            }

            return(chart);
        }
示例#29
0
        private void RefreshZGraph()
        {
            _plot.Series.Clear();
            var lineSeries1 = new LineSeries
            {
                Title                 = string.Empty,
                MarkerFill            = OxyColor.FromRgb(255, 0, 0),
                MarkerSize            = 1,
                MarkerStroke          = OxyColor.FromRgb(255, 0, 0),
                MarkerStrokeThickness = 1.5,
                MarkerType            = MarkerType.Circle
            };

            _plot.Series.Add(lineSeries1);
            var prof = Presenter.ThisProfile.Datapoints;

            foreach (var tp1 in prof)
            {
                var x      = DateTimeAxis.ToDouble(tp1.DateAndTime);
                var y      = tp1.Value;
                var bottom = new DataPoint(x, y);
                lineSeries1.Points.Add(bottom);
            }
            foreach (var axis in _plot.Axes)
            {
                axis.Reset();
            }
            _plot.InvalidatePlot(true);
        }
        private LineSeries GenerateSerieForGray(Image <Gray, byte> grayImage, int chanel, String color)
        {
            var chanelValues = new List <int>();

            for (int x = 0; x < grayImage.Width; x++)
            {
                chanelValues.Add(grayImage.Data[(int)DataProvider.MousePosition.Y, x, chanel]);
            }

            if (color.Equals("Gray"))
            {
                var series = new LineSeries
                {
                    MarkerType   = MarkerType.None,
                    MarkerSize   = 1,
                    MarkerStroke = OxyColors.Red,
                    MarkerFill   = OxyColors.Red,
                    Color        = OxyColors.Red
                };

                for (int index = 0; index < chanelValues.Count; ++index)
                {
                    series.Points.Add(new DataPoint(index, chanelValues[index]));
                }

                return(series);
            }

            return(null);
        }
示例#31
0
        private void AddBezierByNURBS(List <GPoint> points)
        {
            if (points.Count() < 3)
            {
                return;
            }

            int degree = points.Count - 1;
            var ls     = new OxyPlot.Series.LineSeries()
            {
                MarkerType   = ShowMarker ? MarkerType.None : MarkerType.Plus,
                MarkerStroke = OxyPlot.OxyColors.Blue
            };

            double duration = Util.Util.MeasureExecTime(() =>
            {
                const int INTERVAL_NUM = 100;
                double step            = 1.0 / INTERVAL_NUM;
                NURBSCurve bspline     = new NURBSCurve(points, degree);
                for (double t = 0; t < 1.0; t += step)
                {
                    GPoint p = bspline.NonRationalBSpline(t);
                    ls.Points.Add(new OxyPlot.DataPoint(p.X, p.Y));
                }
            });

            ls.Title = $"NURBS(Bezier-{degree})({duration:0.###}ms)";
            base.Series.Add(ls);
        }
        private void FillSerie(object data)
        {
            Task.Factory.StartNew(() =>
             {
            PlotModel.Series.Clear();
            OxyPlot.Series.LineSeries lineSerie = new OxyPlot.Series.LineSeries
            {
               StrokeThickness = 2,
               CanTrackerInterpolatePoints = true,
               Smooth = true,
            };
            PlotModel.Series.Add(lineSerie);

            double[] samples = data as double[];

            var points = new List<DataPoint>();
            double xPos = 0;
            double xStep = 1;
            for(int i = 0; i < samples.Length; i++)
            {
               double y = samples[i];
               points.Add(new DataPoint(xPos, y));
               xPos += xStep;
            }
            lineSerie.ItemsSource = points;

            PlotModel.InvalidatePlot(true);
             });
        }
示例#33
0
        public PlotWindow(List <List <double> > results)
        {
            var plotModel = new OxyPlot.PlotModel();

            plotModel.Title = "Training and Validation Accuracy";

            plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis()
            {
                Position = OxyPlot.Axes.AxisPosition.Left, Title = "Accuracy", Minimum = 0, Maximum = 1
            });
            plotModel.Axes.Add(new OxyPlot.Axes.LinearAxis()
            {
                Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "Epochs"
            });

            var labels = new string[] { "Training", "Validation" };
            var colors = new OxyPlot.OxyColor[] { OxyPlot.OxyColors.Blue, OxyPlot.OxyColors.Green };

            for (int row = 0; row < results.Count; row++)
            {
                var lineSeries = new OxyPlot.Series.LineSeries();
                lineSeries.ItemsSource = results[row].Select((value, index) => new OxyPlot.DataPoint(index, value));
                lineSeries.Title       = labels[row];
                lineSeries.Color       = colors[row];
                plotModel.Series.Add(lineSeries);
            }

            var plotView = new OxyPlot.Wpf.PlotView();

            plotView.Model = plotModel;

            Title   = "Chart";
            Content = plotView;
        }
示例#34
0
	    public void DrawCurve(List<double> x, List<double> y, string title = null)
	    {
		    if (x.Count != y.Count)
			    throw new ArgumentException("X and Y must have the same count of elemrnts!");
		    var curve = new LineSeries
		    {
			    StrokeThickness = 2,
			    Smooth = true,
			    Color = OxyColor.FromRgb(0, 0, 0),
			    LineStyle = LineStyle.Solid,
			    Points = new List<IDataPoint>(),
			    Title = title
		    };
			for (var i = 0; i < x.Count; i++)
		    {
				curve.Points.Add(new DataPoint(x[i], y[i]));
		    }
			_mainPlot.Series.Add(curve);
	    }
示例#35
0
	    public void DrawLine(DataPoint start, DataPoint end, LineStyle style = LineStyle.Solid)
	    {
			var line = new LineSeries
			{
				StrokeThickness = 2,
				Smooth = true,
				Color = OxyColor.FromRgb(0, 0, 0),
				LineStyle = style,
				Points = new List<IDataPoint>()
			};
		    var deltaX = Math.Abs(start.X - end.X);
			var deltaY = Math.Abs(start.Y - end.Y);
		    var k = deltaY / deltaX;
		    if (start.Y > end.Y)
			    k = -k;
			var i = 0.0;
			while (i <= deltaX)
			{
				var x = i;
				if (start.X > end.X)
					x = -i;
				line.Points.Add(new DataPoint(start.X + x, (start.Y + k*i)));
				i += Opt.Step;
			}
			//Shit for vertical line
		    if ((int)start.X == (int)end.X)
		    {
			    var startY = start.Y < end.Y ? start : end;
			    for (var j = startY.Y; j < startY.Y + deltaY; j += Opt.Step)
				    line.Points.Add(new DataPoint(start.X, j));
		    }
			_mainPlot.Series.Add(line);
	    }
示例#36
0
        // Charge les résultats dans le graphique
        private void LoadData(Dictionary<DateTime,ResultValue> plotResults, double payOff)
        {
            var lineSerie1 = new OxyPlot.Series.LineSeries
            {
                Title = "Portfolio Value",
                StrokeThickness = 2,
                MarkerSize = 3,
                CanTrackerInterpolatePoints = false,
                Smooth = false,
            };

            var lineSerie2 = new OxyPlot.Series.LineSeries
            {
                Title = "Option Value",
                StrokeThickness = 2,
                MarkerSize = 3,
                CanTrackerInterpolatePoints = false,
                Smooth = false,
            };

            var lineSerie3 = new OxyPlot.Series.LineSeries
            {
                Title = "PayOff",
                StrokeThickness = 2,
                MarkerSize = 3,
                CanTrackerInterpolatePoints = false,
                Smooth = false,
            };

            foreach (var data in plotResults)
            {
                lineSerie1.Points.Add(new DataPoint(DateTimeAxis.ToDouble(data.Key), data.Value.PortfolioValue));
                lineSerie2.Points.Add(new DataPoint(DateTimeAxis.ToDouble(data.Key), data.Value.OptionValue));
                lineSerie3.Points.Add(new DataPoint(DateTimeAxis.ToDouble(data.Key), payOff));
            }
            PlotModel.Series.Add(lineSerie1);
            PlotModel.Series.Add(lineSerie2);
            PlotModel.Series.Add(lineSerie3);
        }
示例#37
0
        private void btn_CreateResultTable_Click(object sender, EventArgs e)
        {
            OxyColor EEGColor = OxyColors.Cyan;
            OxyColor EDAColor = OxyColors.LightGreen;
            OxyColor HRColor = OxyColors.Salmon;

            //var tester = new List<double>
            //{
            //    0.01
            //};

            //var tester2 = new List<double>
            //{
            //    0.01, 0.01
            //};

            //var tester3 = new List<double>
            //{
            //    0.01, 0.01, 0.01
            //};

            //MessageBox.Show(tester.FisherCombineP().ToString("0.00000000") + "\n" + tester2.FisherCombineP().ToString("0.00000000") + "\n" + tester3.FisherCombineP().ToString("0.00000000"));

            //var res1 = FisherCompare1(0.4, 10, 0.3, 12);
            //var res2 = FisherCompare2(0.4, 10, 0.3, 12);

            //MessageBox.Show("1)\n" + res1.Item1 + "\n" + res1.Item2 + "\n" + res1.Item3 + "\n\n2)\n" + res2.Item1 + "\n" + res2.Item2 + "\n" + res2.Item3);

            string corrType = "Pearson";
            //string corrType = "Kendall";
            //string corrType = "Spearman";
            double minMilliseconds = 10000;

            FolderBrowserDialog fbd = new FolderBrowserDialog();
            if (fbd.ShowDialog() == DialogResult.OK)
            {
                //sensor is first string
                var timeTable = new Dictionary<string, Dictionary<int, List<Tuple<double, double>>>>();
                var stimuliTable = new Dictionary<string, Dictionary<string, List<Tuple<double, double>>>>();
                var totalList = new Dictionary<string, List<Tuple<double, double>>>();
                var big5List = new Dictionary<string, List<Dictionary<Big5, int>>>();
                List<string> sensors = new List<string>();
                List<int> times = new List<int>();
                List<string> stimulis = new List<string>();
                List<string> resultFiles = new List<string>();

                foreach (var folder in Directory.GetDirectories(fbd.SelectedPath))
                {
                    if (folder.Contains("Stimuli high") ||
                        folder.Contains("Stimuli low") ||
                        folder.Contains("Time 0") ||
                        folder.Contains("Time 1") ||
                        folder.Contains("Time 2") ||
                        folder.Contains(".git") ||
                        folder.Split('\\').Last() == "3" ||
                        folder.Split('\\').Last() == "6" ||
                        folder.Split('\\').Last() == "13")
                    {
                        continue;
                    }

                    string subject = folder.Split('\\').Last();

                    var metaLines = File.ReadAllLines($"{folder}/meta.txt");
                    var big5 = GetBig5(metaLines);
                    int time = int.Parse(metaLines[0].Split('=').Last());
                    string stimuli = metaLines[1].Split('=').Last();
                    stimuli = stimuli == "neu" ? "low" : "high";
                    if (!times.Contains(time)) times.Add(time);
                    if (!stimulis.Contains(stimuli)) stimulis.Add(stimuli);

                    List<string> foldersToExamine = new List<string>();
                    foldersToExamine.Add(fbd.SelectedPath + "\\Time " + time);

                    if (time > 0)
                    {
                        foldersToExamine.Add(fbd.SelectedPath + "\\Stimuli " + stimuli);
                    }

                    if (!big5List.ContainsKey("time" + time))
                    {
                        big5List.Add("time" + time, new List<Dictionary<Big5, int>>());
                    }

                    if (!big5List.ContainsKey("stim" + stimuli))
                    {
                        big5List.Add("stim" + stimuli, new List<Dictionary<Big5, int>>());
                    }

                    if (!big5List.ContainsKey("total"))
                    {
                        big5List.Add("total", new List<Dictionary<Big5, int>>());
                    }

                    if (!big5List.ContainsKey("corr"))
                    {
                        big5List.Add("corr", new List<Dictionary<Big5, int>>());
                    }

                    if (!big5List.ContainsKey("revCorr"))
                    {
                        big5List.Add("revCorr", new List<Dictionary<Big5, int>>());
                    }

                    big5List["time" + time].Add(big5);
                    if (time != 0)
                    {
                        big5List["stim" + stimuli].Add(big5);
                    }
                    big5List["total"].Add(big5);
                    foreach (var folderToExamine in foldersToExamine)
                    {
                        foreach (var resultFile in Directory.GetFiles(folderToExamine).Where(f => f.Split('\\').Last().StartsWith(subject) && f.Split('\\').Last().EndsWith(".txt")))
                        {
                            if (resultFiles.Contains(resultFile.Split('\\').Last()) || !folderToExamine.Contains("Time") && !foldersToExamine.Contains("Stimuli") || resultFile.Contains("dtw"))
                            {
                                continue;
                            }

                            resultFiles.Add(resultFile.Split('\\').Last());

                            string sensor = new String(resultFile.Split('.').First().SkipWhile(x => x != '_').Skip(1).SkipWhile(x => x != '_').Skip(1).ToArray());

                            if (!sensors.Contains(sensor)) sensors.Add(sensor);

                            var resultLines = File.ReadAllLines(resultFile);
                            string correlationLine = resultLines.First(x => x.Contains("|" + corrType));
                            int corrId = resultLines.ToList().IndexOf(correlationLine);
                            int sigId = corrId + 2;
                            string significanceLine = resultLines[sigId];
                            string N = resultLines[sigId + 2];

                            double highPassThreshold = minMilliseconds / 1000;

                            if (sensor.Contains("EEG"))
                            {
                                highPassThreshold *= 128;
                            }
                            else if (sensor.Contains("GSR"))
                            {
                                highPassThreshold *= 20;
                            }
                            else if (sensor.Contains("HR"))
                            {
                                highPassThreshold *= 1;
                            }

                            string[] Nsplit = N.Split(new char[] { '|', ' ' }, StringSplitOptions.RemoveEmptyEntries);

                            if (correlationLine.Contains(".a") || significanceLine.Contains(".a") || int.Parse(Nsplit[2]) < highPassThreshold)
                            {
                                if (int.Parse(Nsplit[2]) < highPassThreshold)
                                {
                                    Log.LogMessage("Removing - " + Nsplit[2] + ": " + resultFile);
                                }

                                continue;
                            }

                            int splitIndex = (corrType == "Pearson") ? 3 : 4;

                            double pearsCorrelation = double.Parse(correlationLine.Split(new char[] { '|', '*' }, StringSplitOptions.RemoveEmptyEntries)[splitIndex].Replace(',', '.'), System.Globalization.CultureInfo.InvariantCulture);
                            double pearsSignificance = double.Parse(significanceLine.Split(new char[] { '|', '*' }, StringSplitOptions.RemoveEmptyEntries)[splitIndex].Replace(',', '.'), System.Globalization.CultureInfo.InvariantCulture);

                            var result = Tuple.Create(pearsCorrelation, pearsSignificance);

                            if (!timeTable.ContainsKey(sensor))
                            {
                                timeTable.Add(sensor, new Dictionary<int, List<Tuple<double, double>>>());
                                stimuliTable.Add(sensor, new Dictionary<string, List<Tuple<double, double>>>());
                                totalList.Add(sensor, new List<Tuple<double, double>>());
                            }
                            if (!timeTable[sensor].ContainsKey(time))
                            {
                                timeTable[sensor].Add(time, new List<Tuple<double, double>>());
                            }
                            if (!stimuliTable[sensor].ContainsKey(stimuli))
                            {
                                stimuliTable[sensor].Add(stimuli, new List<Tuple<double, double>>());
                            }

                            timeTable[sensor][time].Add(result);
                            totalList[sensor].Add(result);
                            if (time != 0)
                            {
                                stimuliTable[sensor][stimuli].Add(result);
                            }

                            if (pearsCorrelation > 0)
                            {
                                big5List["corr"].Add(big5);
                            }
                            else
                            {
                                big5List["revCorr"].Add(big5);

                            }
                        }
                    }
                }

                //done gathering results
                List<string> totalToWrite = new List<string>();
                totalToWrite.Add("Sensor&Avg Corr&Avg Sig. \\\\");
                foreach (var sensor in sensors)
                {
                    double avgCorrelation = totalList[sensor].Average(x => x.Item1);
                    double stdevCorrelation = MathNet.Numerics.Statistics.ArrayStatistics.PopulationStandardDeviation(totalList[sensor].Select(x => x.Item1).ToArray());
                    double avgSignificance = totalList[sensor].Average(x => x.Item2);
                    double stdevSignificance = MathNet.Numerics.Statistics.ArrayStatistics.PopulationStandardDeviation(totalList[sensor].Select(x => x.Item2).ToArray());

                    totalToWrite.Add($"{sensor}&{avgCorrelation.ToString("0.000")}({stdevCorrelation.ToString("0.000")})&{avgSignificance.ToString("0.000")}({stdevSignificance.ToString("0.000")}) \\\\");
                }

                Dictionary<Big5, List<string>> big5Anova = new Dictionary<Big5, List<string>>();
                foreach (Big5 item in Enum.GetValues(typeof(Big5)))
                {
                    big5Anova.Add(item, new List<string>());
                    totalToWrite.Add(item + " Mean: " + big5List["total"].Average(x => x[item]).ToString("0.00") + ", SD: " + MathNet.Numerics.Statistics.ArrayStatistics.PopulationStandardDeviation(big5List["total"].Select(x => x[item]).ToArray()).ToString("0.00") + ".");

                    big5List["time0"].ForEach(x => big5Anova[item].Add("0;" + x[item]));
                    big5List["time1"].ForEach(x => big5Anova[item].Add("1;" + x[item]));
                    big5List["time2"].ForEach(x => big5Anova[item].Add("2;" + x[item]));
                    big5List["stimlow"].ForEach(x => big5Anova[item].Add("3;" + x[item]));
                    big5List["stimhigh"].ForEach(x => big5Anova[item].Add("4;" + x[item]));
                }

                foreach (var big5group in big5Anova)
                {
                    File.WriteAllLines(fbd.SelectedPath + "/" + big5group.Key + "_anova.csv", big5group.Value);
                }

                File.WriteAllLines(fbd.SelectedPath + "/" + corrType + "_totals.txt", totalToWrite);

                double width = 1 / (sensors.Count * 1.4);
                double widthTime = 0.3;

                var timeModel = new PlotModel() { Title = $"Time Groups Box Plot" };
                var avgLineSeries = new OxyPlot.Series.LineSeries() { };

                List<OxyColor> colors = new List<OxyColor>()
                {
                };

                int small = sensors.Count / 3;
                int mid = small * 2;
                int stepsize = 255 / small;
                for (int i = 0; i < sensors.Count; i++)
                {
                    byte increaser = (byte)((i % small) * stepsize);
                    byte decreaser = (byte)(255 - increaser);

                    if (i < small)
                    {
                        colors.Add(OxyColor.FromRgb(increaser, decreaser, decreaser));
                    }
                    else if (i < mid)
                    {
                        colors.Add(OxyColor.FromRgb(decreaser, increaser, decreaser));
                    }
                    else
                    {
                        colors.Add(OxyColor.FromRgb(decreaser, decreaser, increaser));
                    }
                }

                List<string> sensorsAdded = new List<string>();

                foreach (var sensor in sensors)
                {
                    List<string> timeAnova = new List<string>();
                    foreach (var time in times)
                    {
                        timeTable[sensor][time].ForEach(x => timeAnova.Add(time + ";" + x.Item1));
                    }
                    File.WriteAllLines(fbd.SelectedPath + "/" + sensor + ".csv", timeAnova);
                }

                Dictionary<string, int[]> significantAmount = new Dictionary<string, int[]>();
                Dictionary<string, int[]> significantAmountMax = new Dictionary<string, int[]>();
                var significantCorr = new Dictionary<string, Tuple<double, double, double, double>[]>();
                foreach (var sensor in sensors)
                {
                    significantAmount.Add(sensor, new int[5]);
                    significantAmountMax.Add(sensor, new int[5]);
                    //significantCorr.Add(sensor, new Tuple<double, double>[5]);
                }

                significantCorr.Add("EEG", new Tuple<double, double, double, double>[5]);
                significantCorr.Add("EDA", new Tuple<double, double, double, double>[5]);
                significantCorr.Add("HR", new Tuple<double, double, double, double>[5]);
                //significantCorr.Add("AVG", new Tuple<double, double, double, double>[5]);

                Action<string, int, List<Tuple<double, double>>> AddCorrelation = (sens, id, correl) =>
                {
                    //old average + sd
                    //significantCorr[sens][id] = Tuple.Create(correl.Average(x => x.Item1), correl.Select(x => x.Item1).STDEV(), correl.Average(x => x.Item2), correl.Select(x => x.Item2).STDEV());

                    //new fisher algorithms
                    significantCorr[sens][id] = Tuple.Create(FisherInverse(correl.Average(x => Fisher(x.Item1))), Math.Round((double)correl.Count), correl.Select(x => x.Item2).FisherCombineP(), Math.Round((double)correl.Count));
                };
                List<string> amountTimeSignificant = new List<string>();

                List<double> timeSignificantPoints = new List<double>();
                var TimeErrorModel = new PlotModel() { Title = $"Time Error Model" };
                var timeErrorSeries = new OxyPlot.Series.ErrorColumnSeries() { };
                TimeErrorModel.Series.Add(timeErrorSeries);
                TimeErrorModel.Axes.Add(new OxyPlot.Axes.LinearAxis { Position = OxyPlot.Axes.AxisPosition.Left });
                var axis = new OxyPlot.Axes.CategoryAxis { Position = OxyPlot.Axes.AxisPosition.Bottom };
                axis.Labels.Add("Time 0");
                axis.Labels.Add("Time 1");
                axis.Labels.Add("Time 2");
                TimeErrorModel.Axes.Add(axis);
                TimeErrorModel.Annotations.Add(new OxyPlot.Annotations.LineAnnotation() { Y = 0, Type = OxyPlot.Annotations.LineAnnotationType.Horizontal });

                var TimeErrorModel2 = new PlotModel() { Title = $"Time Error Model" };
                TimeErrorModel2.Axes.Add(new OxyPlot.Axes.LinearAxis { Position = OxyPlot.Axes.AxisPosition.Left });
                var axis2 = new OxyPlot.Axes.CategoryAxis { Position = OxyPlot.Axes.AxisPosition.Bottom };
                axis2.Labels.Add("Time 0");
                axis2.Labels.Add("Time 1");
                axis2.Labels.Add("Time 2");
                TimeErrorModel2.Axes.Add(axis2);
                List<string> AnovaIndividual = new List<string>();
                List<string> AnovaAvg = new List<string>();
                int anovaIndividualId = 0;
                int anovaAvgId = 0;
                List<string> AnovaIndividualLegend = new List<string>();
                List<string> AnovaAvgLegend = new List<string>();
                foreach (var time in times)
                {
                    int sensorId = 0;
                    List<string> timeToWrite = new List<string>();
                    timeToWrite.Add("Sensor&Avg Corr&Avg Sig. \\\\");

                    List<double> avgs = new List<double>();
                    List<double> sigPoints = new List<double>();

                    var errorSeries = new OxyPlot.Series.ErrorColumnSeries();
                    TimeErrorModel2.Series.Add(errorSeries);

                    var EEGAllCorrelations = new List<Tuple<double, double>>();
                    var GSRAllCorrelations = timeTable["GSR"][time];
                    var HRAllCorrelations = timeTable["HR"][time];
                    foreach (var sensor in sensors)
                    {
                        if (sensor.Contains("EEG"))
                        {
                            EEGAllCorrelations.AddRange(timeTable[sensor][time]);
                        }
                        double avgCorrelation = timeTable[sensor][time].Average(x => x.Item1);
                        double stdevCorrelation = MathNet.Numerics.Statistics.ArrayStatistics.PopulationStandardDeviation(timeTable[sensor][time].Select(x => x.Item1).ToArray());
                        double avgSignificance = timeTable[sensor][time].Average(x => x.Item2);
                        double stdevSignificance = MathNet.Numerics.Statistics.ArrayStatistics.PopulationStandardDeviation(timeTable[sensor][time].Select(x => x.Item2).ToArray());

                        var orderedAll = timeTable[sensor][time].OrderBy(x => x.Item1).ToList();//timeTable[sensor][time].Where(x => x.Item2 * 100 < (int)5).OrderBy(x => x.Item1).ToList();
                        amountTimeSignificant.Add(time + " & " + sensor + " & " + orderedAll.Count);
                        significantAmount[sensor][time] = orderedAll.Count;
                        significantAmountMax[sensor][time] = timeTable[sensor][time].Count;
                        //significantCorr[sensor][time] = Tuple.Create(orderedAll.Average(x => x.Item1), MathNet.Numerics.Statistics.ArrayStatistics.PopulationStandardDeviation(orderedAll.Select(x => x.Item1).ToArray()));

                        //var boxItem = new OxyPlot.Series.BoxPlotItem(time + sensorId * widthTime - (0.5 * widthTime * sensors.Count), orderedAll[0].Item1, orderedAll[(int)(orderedAll.Count * 0.25)].Item1, orderedAll[orderedAll.Count / 2].Item1, orderedAll[(int)(orderedAll.Count * 0.75)].Item1, orderedAll.Last().Item1);
                        //var boxItem = new OxyPlot.Series.BoxPlotItem(sensorId + time * widthTime - (0.5 * widthTime * (times.Count - 1)), orderedAll[0].Item1, orderedAll[(int)(orderedAll.Count * 0.25)].Item1, orderedAll[orderedAll.Count / 2].Item1, orderedAll[(int)(orderedAll.Count * 0.75)].Item1, orderedAll.Last().Item1);
                        //var boxSeries = new OxyPlot.Series.BoxPlotSeries() { };
                        //boxSeries.BoxWidth = widthTime;
                        //boxSeries.WhiskerWidth = widthTime;
                        //boxSeries.Items.Add(boxItem);
                        //boxSeries.Fill = colors[sensorId];
                        //timeModel.Series.Add(boxSeries);

                        errorSeries.Items.Add(new OxyPlot.Series.ErrorColumnItem(orderedAll.Average(x => x.Item1), MathNet.Numerics.Statistics.ArrayStatistics.PopulationStandardDeviation(orderedAll.Select(x => x.Item1).ToArray()), time) { Color = colors[sensorId] });

                        //if (!sensorsAdded.Contains(sensor))
                        //{
                        //    sensorsAdded.Add(sensor);
                        //    boxSeries.Title = sensor;
                        //}

                        avgs.Add(orderedAll.Average(x => x.Item1));
                        sigPoints.AddRange(orderedAll.Select(x => x.Item1));

                        if (avgSignificance * 100 < (int)5)
                        {
                            timeToWrite.Add($"\\textbf{{{sensor}}}&\\textbf{{{avgCorrelation.ToString("0.000")}({stdevCorrelation.ToString("0.000")})}}&\\textbf{{{avgSignificance.ToString("0.000")}({stdevSignificance.ToString("0.000")})}} \\\\");
                        }
                        else
                        {
                            timeToWrite.Add($"{sensor}&{avgCorrelation.ToString("0.000")}({stdevCorrelation.ToString("0.000")})&{avgSignificance.ToString("0.000")}({stdevSignificance.ToString("0.000")}) \\\\");
                        }
                        sensorId++;
                    }

                    double boxWidth = 0.3;

                    //eeg
                    EEGAllCorrelations = EEGAllCorrelations.OrderBy(x => x.Item1).ToList();
                    var EEGSeries = new OxyPlot.Series.BoxPlotSeries() { Fill = EEGColor, BoxWidth = boxWidth, WhiskerWidth = boxWidth };
                    if (time == 0) EEGSeries.Title = "EEG";
                    var EEGItem = CreateBoxItem(EEGAllCorrelations);
                    EEGItem.X = time - EEGSeries.BoxWidth * 1;
                    EEGSeries.Items.Add(EEGItem);
                    timeModel.Series.Add(EEGSeries);

                    AddCorrelation("EEG", time, EEGAllCorrelations);

                    foreach (var cor in EEGAllCorrelations)
                    {
                        AnovaIndividual.Add(anovaIndividualId + ";" + cor.Item1);
                    }
                    AnovaIndividualLegend.Add(anovaIndividualId++ + "=time_" + time + "_EEG");

                    //gsr
                    GSRAllCorrelations = GSRAllCorrelations.OrderBy(x => x.Item1).ToList();
                    var GSRSeries = new OxyPlot.Series.BoxPlotSeries() { Fill = EDAColor, BoxWidth = boxWidth, WhiskerWidth = boxWidth };
                    if (time == 0) GSRSeries.Title = "EDA";
                    var GSRItem = CreateBoxItem(GSRAllCorrelations);
                    GSRItem.X = time;
                    GSRSeries.Items.Add(GSRItem);
                    timeModel.Series.Add(GSRSeries);

                    AddCorrelation("EDA", time, GSRAllCorrelations);

                    foreach (var cor in GSRAllCorrelations)
                    {
                        AnovaIndividual.Add(anovaIndividualId + ";" + cor.Item1);
                    }
                    AnovaIndividualLegend.Add(anovaIndividualId++ + "=time_" + time + "_GSR");

                    //hr
                    HRAllCorrelations = HRAllCorrelations.OrderBy(x => x.Item1).ToList();
                    var HRSeries = new OxyPlot.Series.BoxPlotSeries() { Fill = HRColor, BoxWidth = boxWidth, WhiskerWidth = boxWidth };
                    if (time == 0) HRSeries.Title = "HR";
                    var HRItem = CreateBoxItem(HRAllCorrelations);
                    HRItem.X = time + HRSeries.BoxWidth * 1;
                    HRSeries.Items.Add(HRItem);
                    timeModel.Series.Add(HRSeries);

                    AddCorrelation("HR", time, HRAllCorrelations);

                    foreach (var cor in HRAllCorrelations)
                    {
                        AnovaIndividual.Add(anovaIndividualId + ";" + cor.Item1);
                    }
                    AnovaIndividualLegend.Add(anovaIndividualId++ + "=time_" + time + "_HR");

                    //avg
                    var AVGAllCorrelations = EEGAllCorrelations.Concat(GSRAllCorrelations.Concat(HRAllCorrelations)).ToList();

                    //AddCorrelation("AVG", time, AVGAllCorrelations);

                    foreach (var cor in AVGAllCorrelations)
                    {
                        AnovaAvg.Add(anovaAvgId + ";" + cor.Item1);
                    }
                    AnovaAvgLegend.Add(anovaAvgId++ + "=time_" + time);
                    double totalAvg = AVGAllCorrelations.Average(x => x.Item1);
                    var txtAvg = new OxyPlot.Annotations.TextAnnotation() { TextPosition = new OxyPlot.DataPoint(time, -1), Text = "Avg " + totalAvg.ToString(".000").Replace(",", "."), Stroke = OxyColors.White };
                    timeModel.Annotations.Add(txtAvg);

                    timeErrorSeries.Items.Add(new OxyPlot.Series.ErrorColumnItem(sigPoints.Average(), MathNet.Numerics.Statistics.ArrayStatistics.PopulationStandardDeviation(sigPoints.ToArray()), time));

                    avgLineSeries.Points.Add(new OxyPlot.DataPoint(time, avgs.Average()));
                    File.WriteAllLines(fbd.SelectedPath + "/" + corrType + "_time" + time + ".txt", timeToWrite);
                }
                File.WriteAllLines(fbd.SelectedPath + "/significantTime.tex", amountTimeSignificant);
                timeModel.LegendPlacement = LegendPlacement.Outside;

                timeModel.Axes.Add(new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Left, Maximum = 1, Minimum = -1, Title = "Pearson's r" });
                timeModel.Axes.Add(new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Maximum = 2.5, Minimum = -0.5, MajorStep = 1, Title = "Time", MinorTickSize = 0 });
                //timeModel.Axes.Add(new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Maximum = sensors.Count - 0.5, Minimum = -0.5, MajorStep = 1, Title = "Sensors", MinorTickSize = 0 });
                //boxModel.Series.Add(avgLineSeries);
                PngExporter pnger = new PngExporter();

                pnger.ExportToFile(timeModel, fbd.SelectedPath + "/timeBox.png");

                pnger.ExportToFile(TimeErrorModel, fbd.SelectedPath + "/errorPlotTest.png");
                pnger.ExportToFile(TimeErrorModel2, fbd.SelectedPath + "/errorPlotTest2.png");

                /*
                //correlation and reverse correlation
                foreach (var time in times)
                {
                    //Correlation
                    List<string> correlationTimeToWrite = new List<string>();
                    correlationTimeToWrite.Add("Sensor&Avg Corr&Avg Sig. \\\\");

                    //Reverse correlation
                    List<string> reverseCorrelationTimeToWrite = new List<string>();
                    reverseCorrelationTimeToWrite.Add("Sensor & Avg Corr & Avg Sig. \\\\");

                    foreach (var sensor in sensors)
                    {

                        double correlationAvgCorrelation = timeTable[sensor][time].Where(x => x.Item1 >= 0).Average(x => x.Item1);
                        double correlationStdevCorrelation = MathNet.Numerics.Statistics.ArrayStatistics.PopulationStandardDeviation(timeTable[sensor][time].Where(x => x.Item1 >= 0).Select(x => x.Item1).ToArray());
                        double correlationAvgSignificance = timeTable[sensor][time].Where(x => x.Item1 >= 0).Average(x => x.Item2);
                        double correlationStdevSignificance = MathNet.Numerics.Statistics.ArrayStatistics.PopulationStandardDeviation(timeTable[sensor][time].Where(x => x.Item1 >= 0).Select(x => x.Item2).ToArray());

                        double reverseCorrelationAvgCorrelation = timeTable[sensor][time].Where(x => x.Item1 < 0).Average(x => x.Item1);
                        double reverseCorrelationStdevCorrelation = MathNet.Numerics.Statistics.ArrayStatistics.PopulationStandardDeviation(timeTable[sensor][time].Where(x => x.Item1 < 0).Select(x => x.Item1).ToArray());
                        double reverseCorrelationAvgSignificance = timeTable[sensor][time].Where(x => x.Item1 < 0).Average(x => x.Item2);
                        double reverseCorrelationStdevSignificance = MathNet.Numerics.Statistics.ArrayStatistics.PopulationStandardDeviation(timeTable[sensor][time].Where(x => x.Item1 < 0).Select(x => x.Item2).ToArray());

                        correlationTimeToWrite.Add($"{sensor}&{correlationAvgCorrelation.ToString("0.000")}({correlationStdevCorrelation.ToString("0.000")})&{correlationAvgSignificance.ToString("0.000")}({correlationStdevSignificance.ToString("0.000")}) \\\\");
                        reverseCorrelationTimeToWrite.Add($"{sensor}&{reverseCorrelationAvgCorrelation.ToString("0.000")}({reverseCorrelationStdevCorrelation.ToString("0.000")})&{reverseCorrelationAvgSignificance.ToString("0.000")}({reverseCorrelationStdevSignificance.ToString("0.000")}) \\\\");
                    }

                    foreach (Big5 item in Enum.GetValues(typeof(Big5)))
                    {
                        correlationTimeToWrite.Add(item + " Mean: " + big5List["corr"].Average(x => x[item]).ToString("0.00") + ", SD: " + MathNet.Numerics.Statistics.ArrayStatistics.PopulationStandardDeviation(big5List["corr"].Select(x => x[item]).ToArray()).ToString("0.00") + ".");
                        reverseCorrelationTimeToWrite.Add(item + " Mean: " + big5List["revCorr"].Average(x => x[item]).ToString("0.00") + ", SD: " + MathNet.Numerics.Statistics.ArrayStatistics.PopulationStandardDeviation(big5List["revCorr"].Select(x => x[item]).ToArray()).ToString("0.00") + ".");
                    }

                    File.WriteAllLines(fbd.SelectedPath + "/correlationTime" + time + ".txt", correlationTimeToWrite);
                    File.WriteAllLines(fbd.SelectedPath + "/reverseCorrelationTime" + time + ".txt", reverseCorrelationTimeToWrite);
                }
                */
                var Big5timeBox = new PlotModel() { Title = "Big5 Time Box Plots", LegendPlacement = LegendPlacement.Outside };
                Dictionary<Big5, OxyPlot.Series.BoxPlotSeries> big5timeSeries = new Dictionary<Big5, OxyPlot.Series.BoxPlotSeries>();
                foreach (Big5 item in Enum.GetValues(typeof(Big5)))
                {
                    big5timeSeries.Add(item, new OxyPlot.Series.BoxPlotSeries() { Fill = colors[(int)item * 2], Title = item.ToString(), BoxWidth = 0.1, WhiskerWidth = 0.1 });
                    Big5timeBox.Series.Add(big5timeSeries[item]);
                }

                Big5timeBox.Axes.Add(new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Left, Maximum = 50, Minimum = 10, Title = "Score" });
                Big5timeBox.Axes.Add(new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Maximum = 2.5, Minimum = -0.5, MajorStep = 1, Title = "Time", MinorTickSize = 0 });

                foreach (var time in times)
                {
                    foreach (Big5 item in Enum.GetValues(typeof(Big5)))
                    {
                        var orderino = big5List["time" + time].Select(x => x[item]).OrderBy(x => x).ToList();
                        big5timeSeries[item].Items.Add(new OxyPlot.Series.BoxPlotItem(time - 0.25 + (int)item * 0.1, orderino[0], orderino[(int)(orderino.Count * 0.25)], orderino[orderino.Count / 2], orderino[(int)(orderino.Count * 0.75)], orderino.Last()));
                    }
                }

                pnger.ExportToFile(Big5timeBox, fbd.SelectedPath + "/timeBoxBig5.png");

                foreach (var time in times)
                {
                    List<string> timeToWrite = new List<string>();
                    timeToWrite.Add("\\begin{table}");
                    timeToWrite.Add("\\centering");
                    timeToWrite.Add("{\\large \\textbf{Time " + time + "}}\\vspace{1pt}");
                    timeToWrite.Add("\\begin{tabular}{ccc}");
                    timeToWrite.Add("\\toprule");
                    timeToWrite.Add("Sensor&Avg Corr&Avg Sig. \\\\");
                    timeToWrite.Add("\\midrule");
                    foreach (var sensor in sensors)
                    {
                        double avgCorrelation = timeTable[sensor][time].Average(x => x.Item1);
                        double stdevCorrelation = MathNet.Numerics.Statistics.ArrayStatistics.PopulationStandardDeviation(timeTable[sensor][time].Select(x => x.Item1).ToArray());
                        double avgSignificance = timeTable[sensor][time].Average(x => x.Item2);
                        double stdevSignificance = MathNet.Numerics.Statistics.ArrayStatistics.PopulationStandardDeviation(timeTable[sensor][time].Select(x => x.Item2).ToArray());

                        if (avgSignificance < 0.05)
                        {
                            timeToWrite.Add($"\\textbf{{{sensor}}}&\\textbf{{{avgCorrelation.ToString("0.000")}({stdevCorrelation.ToString("0.000")})}}&\\textbf{{{avgSignificance.ToString("0.000")}({stdevSignificance.ToString("0.000")})}} \\\\");
                        }
                        else
                        {
                            timeToWrite.Add($"{sensor}&{avgCorrelation.ToString("0.000")}({stdevCorrelation.ToString("0.000")})&{avgSignificance.ToString("0.000")}({stdevSignificance.ToString("0.000")}) \\\\");
                        }

                    }
                    timeToWrite.Add("\\bottomrule");
                    timeToWrite.Add("\\end{tabular}");
                    timeToWrite.Add("\\caption{Results from time " + time + ".");

                    foreach (Big5 item in Enum.GetValues(typeof(Big5)))
                    {
                        timeToWrite.Add(item + " Mean: " + big5List["time" + time].Average(x => x[item]).ToString("0.00") + ", SD: " + MathNet.Numerics.Statistics.ArrayStatistics.PopulationStandardDeviation(big5List["time" + time].Select(x => x[item]).ToArray()).ToString("0.00") + ".");
                    }
                    timeToWrite.Add("}");

                    timeToWrite.Add("\\label{[TABLE] res time" + time + "}");
                    timeToWrite.Add("\\end{table}");

                    File.WriteAllLines(fbd.SelectedPath + "/" + corrType + "_time" + time + ".txt", timeToWrite);
                }

                var stimModel = new PlotModel() { Title = "Stimuli Groups Box Plot" };
                int stimId = 0;
                sensorsAdded.Clear();
                avgLineSeries.Points.Clear();

                var Big5StimBox = new PlotModel() { Title = "Big5 Stimuli Box Plots", LegendPlacement = LegendPlacement.Outside };
                Dictionary<Big5, OxyPlot.Series.BoxPlotSeries> big5Series = new Dictionary<Big5, OxyPlot.Series.BoxPlotSeries>();
                foreach (Big5 item in Enum.GetValues(typeof(Big5)))
                {
                    big5Series.Add(item, new OxyPlot.Series.BoxPlotSeries() { Fill = colors[(int)item * 2], Title = item.ToString(), BoxWidth = 0.1, WhiskerWidth = 0.1 });
                    Big5StimBox.Series.Add(big5Series[item]);
                }

                Big5StimBox.Axes.Add(new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Left, Maximum = 50, Minimum = 10, Title = "Score" });
                Big5StimBox.Axes.Add(new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Maximum = 1.5, Minimum = -0.5, MajorStep = 1, Title = "Category", MinorTickSize = 0 });
                List<string> amountStimSignificant = new List<string>();
                foreach (var stimuli in stimulis)
                {
                    List<string> stimuliToWrite = new List<string>();
                    stimuliToWrite.Add("\\begin{table}");
                    stimuliToWrite.Add("\\centering");
                    stimuliToWrite.Add("{\\large \\textbf{Stimuli " + stimuli + "}}\\vspace{1pt}");
                    stimuliToWrite.Add("\\begin{tabular}{ccc}");
                    stimuliToWrite.Add("\\toprule");
                    stimuliToWrite.Add("Sensor&Avg Corr&Avg Sig. \\\\");
                    stimuliToWrite.Add("\\midrule");
                    List<double> avgs = new List<double>();
                    int sensorId = 0;

                    var EEGAllCorrelations = new List<Tuple<double, double>>();
                    var GSRAllCorrelations = stimuliTable["GSR"][stimuli];
                    var HRAllCorrelations = stimuliTable["HR"][stimuli];

                    foreach (var sensor in sensors)
                    {
                        if (sensor.Contains("EEG"))
                        {
                            EEGAllCorrelations.AddRange(stimuliTable[sensor][stimuli]);
                        }
                        double avgCorrelation = stimuliTable[sensor][stimuli].Average(x => x.Item1);
                        double stdevCorrelation = MathNet.Numerics.Statistics.ArrayStatistics.PopulationStandardDeviation(stimuliTable[sensor][stimuli].Select(x => x.Item1).ToArray());
                        double avgSignificance = stimuliTable[sensor][stimuli].Average(x => x.Item2);
                        double stdevSignificance = MathNet.Numerics.Statistics.ArrayStatistics.PopulationStandardDeviation(stimuliTable[sensor][stimuli].Select(x => x.Item2).ToArray());

                        var orderedAll = stimuliTable[sensor][stimuli].Where(x => x.Item2 * 100 < (int)5).OrderBy(x => x.Item1).ToList();
                        amountStimSignificant.Add(stimuli + " & " + sensor + " & " + orderedAll.Count);
                        significantAmount[sensor][stimuli == "low" ? 3 : 4] = orderedAll.Count;
                        significantAmountMax[sensor][stimuli == "low" ? 3 : 4] = stimuliTable[sensor][stimuli].Count;
                        //significantCorr[sensor][stimuli == "low" ? 3 : 4] = Tuple.Create(orderedAll.Average(x => x.Item1), MathNet.Numerics.Statistics.ArrayStatistics.PopulationStandardDeviation(orderedAll.Select(x => x.Item1).ToArray()));
                        var boxItem = new OxyPlot.Series.BoxPlotItem(((1 + stimId) % 2) + sensorId * width - (0.5 * width * sensors.Count), orderedAll[0].Item1, orderedAll[(int)(orderedAll.Count * 0.25)].Item1, orderedAll[orderedAll.Count / 2].Item1, orderedAll[(int)(orderedAll.Count * 0.75)].Item1, orderedAll.Last().Item1);
                        //var boxItem = new OxyPlot.Series.BoxPlotItem(sensorId + ((1 + stimId) % 2) * widthTime - (0.5 * widthTime), orderedAll[0].Item1, orderedAll[(int)(orderedAll.Count * 0.25)].Item1, orderedAll[orderedAll.Count / 2].Item1, orderedAll[(int)(orderedAll.Count * 0.75)].Item1, orderedAll.Last().Item1);
                        var boxSeries = new OxyPlot.Series.BoxPlotSeries() { };
                        boxSeries.BoxWidth = width;
                        boxSeries.WhiskerWidth = width;
                        //boxSeries.BoxWidth = widthTime;
                        //boxSeries.WhiskerWidth = widthTime;
                        boxSeries.Items.Add(boxItem);
                        boxSeries.Fill = colors[sensorId];
                        //stimModel.Series.Add(boxSeries);
                        avgs.Add(orderedAll.Average(x => x.Item1));

                        if (!sensorsAdded.Contains(sensor))
                        {
                            sensorsAdded.Add(sensor);
                            boxSeries.Title = sensor;
                        }

                        if (avgSignificance < 0.05)
                        {
                            stimuliToWrite.Add($"\\textbf{{{sensor}}}&\\textbf{{{avgCorrelation.ToString("0.000")}({stdevCorrelation.ToString("0.000")})}}&\\textbf{{{avgSignificance.ToString("0.000")}({stdevSignificance.ToString("0.000")})}} \\\\");
                        }
                        else
                        {
                            stimuliToWrite.Add($"{sensor}&{avgCorrelation.ToString("0.000")}({stdevCorrelation.ToString("0.000")})&{avgSignificance.ToString("0.000")}({stdevSignificance.ToString("0.000")}) \\\\");
                        }
                        sensorId++;
                    }

                    double boxWidth = 0.3;

                    //eeg
                    EEGAllCorrelations = EEGAllCorrelations.OrderBy(x => x.Item1).ToList();
                    var EEGSeries = new OxyPlot.Series.BoxPlotSeries() { Fill = EEGColor, BoxWidth = boxWidth, WhiskerWidth = boxWidth };
                    if (stimuli == "low") EEGSeries.Title = "EEG";
                    var EEGItem = CreateBoxItem(EEGAllCorrelations);
                    EEGItem.X = (stimuli == "low" ? 0 : 1) - EEGSeries.BoxWidth * 1;
                    EEGSeries.Items.Add(EEGItem);
                    stimModel.Series.Add(EEGSeries);

                    AddCorrelation("EEG", stimuli == "low" ? 3 : 4, EEGAllCorrelations);

                    foreach (var cor in EEGAllCorrelations)
                    {
                        AnovaIndividual.Add(anovaIndividualId + ";" + cor.Item1);
                    }
                    AnovaIndividualLegend.Add(anovaIndividualId++ + "=stimuli_" + stimuli + "_EEG");

                    //gsr
                    GSRAllCorrelations = GSRAllCorrelations.OrderBy(x => x.Item1).ToList();
                    var GSRSeries = new OxyPlot.Series.BoxPlotSeries() { Fill = EDAColor, BoxWidth = boxWidth, WhiskerWidth = boxWidth };
                    if (stimuli == "low") GSRSeries.Title = "EDA";
                    var GSRItem = CreateBoxItem(GSRAllCorrelations);
                    GSRItem.X = (stimuli == "low" ? 0 : 1);
                    GSRSeries.Items.Add(GSRItem);
                    stimModel.Series.Add(GSRSeries);

                    AddCorrelation("EDA", stimuli == "low" ? 3 : 4, GSRAllCorrelations);

                    foreach (var cor in GSRAllCorrelations)
                    {
                        AnovaIndividual.Add(anovaIndividualId + ";" + cor.Item1);
                    }
                    AnovaIndividualLegend.Add(anovaIndividualId++ + "=stimuli_" + stimuli + "_GSR");

                    //hr
                    HRAllCorrelations = HRAllCorrelations.OrderBy(x => x.Item1).ToList();
                    var HRSeries = new OxyPlot.Series.BoxPlotSeries() { Fill = HRColor, BoxWidth = boxWidth, WhiskerWidth = boxWidth };
                    if (stimuli == "low") HRSeries.Title = "HR";
                    var HRItem = CreateBoxItem(HRAllCorrelations);
                    HRItem.X = (stimuli == "low" ? 0 : 1) + HRSeries.BoxWidth * 1;
                    HRSeries.Items.Add(HRItem);
                    stimModel.Series.Add(HRSeries);

                    AddCorrelation("HR", stimuli == "low" ? 3 : 4, HRAllCorrelations);

                    foreach (var cor in HRAllCorrelations)
                    {
                        AnovaIndividual.Add(anovaIndividualId + ";" + cor.Item1);
                    }
                    AnovaIndividualLegend.Add(anovaIndividualId++ + "=stimuli_" + stimuli + "_HR");

                    //avg
                    var AVGAllCorrelations = EEGAllCorrelations.Concat(GSRAllCorrelations.Concat(HRAllCorrelations)).ToList();

                    //AddCorrelation("AVG", stimuli == "low" ? 3 : 4, AVGAllCorrelations);

                    foreach (var cor in AVGAllCorrelations)
                    {
                        AnovaAvg.Add(anovaAvgId + ";" + cor.Item1);
                    }
                    AnovaAvgLegend.Add(anovaAvgId++ + "=stimuli_" + stimuli);

                    avgLineSeries.Points.Add(new OxyPlot.DataPoint(0, avgs.Average()));
                    stimuliToWrite.Add("\\bottomrule");
                    stimuliToWrite.Add("\\end{tabular}");
                    stimuliToWrite.Add("\\caption{Results from stimuli " + stimuli + ".");
                    foreach (Big5 item in Enum.GetValues(typeof(Big5)))
                    {
                        stimuliToWrite.Add(item + " Mean: " + big5List["stim" + stimuli].Average(x => x[item]).ToString("0.00") + ", SD: " + MathNet.Numerics.Statistics.ArrayStatistics.PopulationStandardDeviation(big5List["stim" + stimuli].Select(x => x[item]).ToArray()).ToString("0.00") + ".");
                        var orderino = big5List["stim" + stimuli].Select(x => x[item]).OrderBy(x => x).ToList();
                        big5Series[item].Items.Add(new OxyPlot.Series.BoxPlotItem(((1 + stimId) % 2) - 0.25 + (int)item * 0.1, orderino[0], orderino[(int)(orderino.Count * 0.25)], orderino[orderino.Count / 2], orderino[(int)(orderino.Count * 0.75)], orderino.Last()));
                    }
                    stimuliToWrite.Add("}");
                    stimuliToWrite.Add("\\label{[TABLE] res stimuli" + stimuli + "}");
                    stimuliToWrite.Add("\\end{table}");

                    File.WriteAllLines(fbd.SelectedPath + "/" + corrType + "_stimuli_" + stimuli + ".txt", stimuliToWrite);
                    stimId++;
                }
                File.WriteAllLines(fbd.SelectedPath + "/significantStim.tex", amountStimSignificant);
                List<string> sigAmountLines = new List<string>();
                foreach (var sensor in sensors)
                {
                    string linerino = sensor;
                    for (int i = 0; i < 5; i++)
                    {
                        linerino += $" & {significantAmount[sensor][i]}/{significantAmountMax[sensor][i]}";
                    }
                    sigAmountLines.Add(linerino + "\\\\");
                }
                File.WriteAllLines(fbd.SelectedPath + "/significantTable.tex", sigAmountLines);
                //File.WriteAllLines(fbd.SelectedPath + "/significantTable.tex", significantAmount.Select(x => $"{x.Key} & {x.Value[0]} & {x.Value[1]} & {x.Value[2]} & {x.Value[3]} & {x.Value[4]}").ToList());
                File.WriteAllLines(fbd.SelectedPath + "/significantCorrTable.tex", significantCorr.Select(x => $"{x.Key} & {x.Value[0].Item1.ToString(".000")}({x.Value[0].Item2.ToString(".000")}) & {x.Value[1].Item1.ToString(".000")}({x.Value[1].Item2.ToString(".000")}) & {x.Value[2].Item1.ToString(".000")}({x.Value[2].Item2.ToString(".000")}) & {x.Value[3].Item1.ToString(".000")}({x.Value[3].Item2.ToString(".000")}) & {x.Value[4].Item1.ToString(".000")}({x.Value[4].Item2.ToString(".000")}) \\\\"));
                File.WriteAllLines(fbd.SelectedPath + "/significantCorrTableTime.tex", significantCorr.Select(x => $"{x.Key} & {x.Value[0].Item1.ToString(".000")} (SD={x.Value[0].Item2.ToString(".000")}, p={x.Value[0].Item3.ToString(".000000")}) & {x.Value[1].Item1.ToString(".000")} (SD={x.Value[1].Item2.ToString(".000")}, p={x.Value[1].Item3.ToString(".000000")}) & {x.Value[2].Item1.ToString(".000")} (SD={x.Value[2].Item2.ToString(".000")}, p={x.Value[2].Item3.ToString(".000000")}) \\\\"));
                File.WriteAllLines(fbd.SelectedPath + "/significantCorrTableStimuli.tex", significantCorr.Select(x => $"{x.Key} & {x.Value[3].Item1.ToString(".000")} (SD={x.Value[3].Item2.ToString(".000")}, p={x.Value[3].Item3.ToString(".000")}) & {x.Value[4].Item1.ToString(".000")} (SD={x.Value[4].Item2.ToString(".000")}, p={x.Value[4].Item3.ToString(".000")}) \\\\"));

                List<string> timeLines = new List<string>() { "sensor & 0 vs 1 & 1 vs 2 & 0 vs 2" };
                List<string> stimLines = new List<string>() { "sensor & 0 vs Low & Low vs High & 0 vs High" };
                foreach (var item in significantCorr)
                {
                    var z01 = ZCalc(item.Value[0].Item1, Convert.ToInt32(item.Value[0].Item2), item.Value[1].Item1, Convert.ToInt32(item.Value[1].Item2));
                    var z12 = ZCalc(item.Value[1].Item1, Convert.ToInt32(item.Value[1].Item2), item.Value[2].Item1, Convert.ToInt32(item.Value[2].Item2));
                    var z02 = ZCalc(item.Value[0].Item1, Convert.ToInt32(item.Value[0].Item2), item.Value[2].Item1, Convert.ToInt32(item.Value[2].Item2));
                    var p01 = ZtoP(z01);
                    var p12 = ZtoP(z12);
                    var p02 = ZtoP(z02);
                    timeLines.Add($"{item.Key} & z: {z01} | p: {p01} & z: {z12} | p: {p12} & z: {z02} | p: {p02}");

                    var z0Low = ZCalc(item.Value[0].Item1, Convert.ToInt32(item.Value[0].Item2), item.Value[3].Item1, Convert.ToInt32(item.Value[3].Item2));
                    var zLowHigh = ZCalc(item.Value[3].Item1, Convert.ToInt32(item.Value[3].Item2), item.Value[4].Item1, Convert.ToInt32(item.Value[4].Item2));
                    var z0High = ZCalc(item.Value[0].Item1, Convert.ToInt32(item.Value[0].Item2), item.Value[4].Item1, Convert.ToInt32(item.Value[4].Item2));
                    var p0Low = ZtoP(z0Low);
                    var pLowHigh = ZtoP(zLowHigh);
                    var p0High = ZtoP(z0High);
                    stimLines.Add($"{item.Key} & z: {z0Low} | p: {p0Low} & z: {zLowHigh} | p: {pLowHigh} & z: {z0High} | p: {p0High}");
                }

                File.WriteAllLines(fbd.SelectedPath + "/significantCorrCompareTime.tex", timeLines);
                File.WriteAllLines(fbd.SelectedPath + "/significantCorrCompareStimuli.tex", stimLines);

                pnger.ExportToFile(Big5StimBox, fbd.SelectedPath + "/stimBoxBig5.png");

                stimModel.LegendPlacement = LegendPlacement.Outside;

                //index 1 = low
                var stimTxt0 = new OxyPlot.Annotations.TextAnnotation() { TextPosition = new OxyPlot.DataPoint(0, -1), Text = "Avg " + avgLineSeries.Points[1].Y.ToString(".000").Replace(",", "."), Stroke = OxyColors.White };
                //index 0 = high
                var stimTxt1 = new OxyPlot.Annotations.TextAnnotation() { TextPosition = new OxyPlot.DataPoint(1, -1), Text = "Avg " + avgLineSeries.Points[0].Y.ToString(".000").Replace(",", "."), Stroke = OxyColors.White };
                stimModel.Annotations.Add(stimTxt0);
                stimModel.Annotations.Add(stimTxt1);
                stimModel.Axes.Add(new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Left, Maximum = 1, Minimum = -1, Title = "Pearson's r" });
                stimModel.Axes.Add(new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Maximum = 1.5, Minimum = -0.5, MajorStep = 1, Title = "Stimuli", MinorTickSize = 0 });
                //stimModel.Axes.Add(new OxyPlot.Axes.LinearAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Maximum = sensors.Count - 0.5, Minimum = -0.5, MajorStep = 1, Title = "Sensors", MinorTickSize = 0 });

                pnger.ExportToFile(stimModel, fbd.SelectedPath + "/stimBox.png");

                File.WriteAllLines(fbd.SelectedPath + "/anovaIndividual.csv", AnovaIndividual);
                File.WriteAllLines(fbd.SelectedPath + "/anovaIndividualLegend.csv", AnovaIndividualLegend);
                File.WriteAllLines(fbd.SelectedPath + "/anovaAvg.csv", AnovaAvg);
                File.WriteAllLines(fbd.SelectedPath + "/anovaAvgLegend.csv", AnovaAvgLegend);

                Log.LogMessage("DonnoDK");
            }
        }
示例#38
0
 public int addLineSeries(string title)
 {
     var newSeries = new OxyPlot.Series.LineSeries { Title = title, MarkerType = MarkerType.None };
     m_plot.Series.Add(newSeries);
     int newSeriesId = m_numSeries;
     m_numSeries++;
     return newSeriesId;
 }
        public void CreateRocCurve()
        {
            RocCurve = _filterOptimizer.GetRocCurve(AllParameterResults);
            string graphTitle = "ROC curve";

            PlotModel plotModel = new PlotModel(graphTitle);
            plotModel.TitleFontSize = 11;
            plotModel.Padding = new OxyThickness(0);
            plotModel.PlotMargins = new OxyThickness(0);
            plotModel.PlotAreaBorderThickness = 0;

            var series = new OxyPlot.Series.LineSeries();
            series.MarkerSize = 1;
            series.Color = OxyColors.Black;
            for (int i = 0; i < RocCurve.Xvalues.Length; i++)
            {
                series.Points.Add(new DataPoint(RocCurve.Xvalues[i], RocCurve.Yvalues[i]));
            }

            var xAxis = new LinearAxis(AxisPosition.Bottom, "unlabeled count");
            xAxis.Minimum = 0;

            var yAxis = new LinearAxis(AxisPosition.Left, "labeled count");
            yAxis.Minimum = 0;

            plotModel.Series.Add(series);
            plotModel.Axes.Add(xAxis);
            plotModel.Axes.Add(yAxis);

            RocPlot = plotModel;
        }
示例#40
0
文件: test.cs 项目: halo779/FritzLog
        private void test_Load(object sender, EventArgs e)
        {
            testvar.Add(new RelationalDouble(7.9));

            Plot plot = new Plot();
            plot.Model = new OxyPlot.PlotModel();
            plot.Dock = DockStyle.Fill;
            Controls.Add(plot);

            plot.Model.PlotType = OxyPlot.PlotType.XY;

            var DS = new OxyPlot.Series.LineSeries();

            /*Plot plot = new Plot();
            plot.Model = new OxyPlot.PlotModel();
            plot.Dock = DockStyle.Fill;
            this.Controls.Add(plot);

            plot.Model.PlotType = OxyPlot.PlotType.XY;

            var DS = new OxyPlot.Series.LineSeries();
            var US = new OxyPlot.Series.LineSeries();
            var piolt = new OxyPlot.Series.StemSeries();
            US.Color = OxyPlot.OxyColors.Green;
            DS.Color = OxyPlot.OxyColors.Blue;
            piolt.Color = OxyPlot.OxyColors.OrangeRed;

            string[] tmp = "0,0,0,0,5,9,10,10,10,10,11,10,10,10,10,9,9,9,9,9,8,8,8,9,9,8,9,9,8,8,8,8,8,8,8,8,8,9,9,9,8,9,8,8,8,9,8,9,9,9,8,9,9,8,9,8,8,8,8,8,8,8,8,8,13,14,14,14,14,14,14,14,15,13,14,14,14,14,14,14,14,14,14,14,13,11,0,2,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,6,6,7,6,6,6,6,6,6,6,6,5,4,6,6,2,6,6,4,4,6,5,5,5,5,5,5,5,5,5,5,5,4,5,5,5,4,4,5,5,4,1,7,12,12,13,12,13,13,12,13,12,12,13,12,12,13,12,12,12,12,12,10,12,12,12,12,12,12,12,12,12,12,12,10,12,12,12,12,12,12,12,12,12,12,10,12,12,12,12,12,12,12,12,12,12,11,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0".Split(',');
            int i = 0;
            int c = 0;
            string profile = "8b";

            foreach (var item in tmp)
            {
                if (profile == "8b" && i < 2048)
                {
                    if (c < 87 || c > 147)
                    {
                        DS.Points.Add(new OxyPlot.DataPoint((double)i, Convert.ToDouble(item)));
                        US.Points.Add(new OxyPlot.DataPoint((double)i, 0));
                    }
                    else
                    {
                        DS.Points.Add(new OxyPlot.DataPoint((double)i, 0));
                        US.Points.Add(new OxyPlot.DataPoint((double)i, Convert.ToDouble(item)));
                    }
                    if (c == 74)
                    {
                        piolt.Points.Add(new OxyPlot.DataPoint((double)i, 16));
                    }
                    i += 8;
                    c++;
                }
            }

            plot.Model.Series.Add(DS);
            plot.Model.Series.Add(US);
            plot.Model.Series.Add(piolt);

            */
        }
示例#41
0
        public MainViewModel()
        {
            var powerDistribution = ((App)App.Current).PowerDistribution;
            var powerDistributionLogger = ((App) Application.Current).PowerDistributionLogger;
            var viewSettings = ((App) Application.Current).ViewSettings;

            // View Settings
            this.PlotForeground = viewSettings
                .ObserveProperty(self => self.PlotStyle).Select(style => style.ObserveProperty(self => self.PlotForeground))
                .Switch()
                .Select(color => new SolidColorBrush(color))
                .ToReadOnlyReactiveProperty()
                .AddTo(this.disposables);
            this.PlotBackground = viewSettings
                .ObserveProperty(self => self.PlotStyle).Select(style => style.ObserveProperty(self => self.PlotBackground))
                .Switch()
                .Select(color => new SolidColorBrush(color))
                .ToReadOnlyReactiveProperty()
                .AddTo(this.disposables);

            this.CurrentSensors = powerDistribution.Sensors.ToReadOnlyReactiveCollection(sensor => new CurrentSensorViewModel(sensor)).AddTo(this.disposables);

            this.TotalCurrent = powerDistribution.ObserveProperty(self => self.TotalCurrent).ToReadOnlyReactiveProperty(mode:ReactivePropertyMode.RaiseLatestValueOnSubscribe)
                .AddTo(this.disposables);

            this.Capacity = powerDistribution.ObserveProperty(self => self.Capacity).ToReadOnlyReactiveProperty().AddTo(this.disposables);
            this.Usage = Observable.CombineLatest(
                    this.TotalCurrent,
                    this.Capacity,
                    (totalCurrent, capacity) => capacity > 0 ? totalCurrent / capacity : 0)
                .ToReadOnlyReactiveProperty()
                .AddTo(this.disposables);

            this.AlertState = Observable.CombineLatest(
                    powerDistribution.ObserveProperty(self => self.IsWarningCondition),
                    powerDistribution.ObserveProperty(self => self.IsCriticalCondition),
                    (isWarning, isCritical) => isCritical ? ErrorAlertState : (isWarning ? WarningAlertState : NormalAlertState))
                .ToReadOnlyReactiveProperty()
                .AddTo(this.disposables);


            this.CurrentPlotType = new ReactiveProperty<PlotType>().AddTo(this.disposables);
            this.IsLive = this.CurrentPlotType.Select(type => type == PlotType.Live).ToReadOnlyReactiveProperty().AddTo(this.disposables);
            this.IsCustom = this.CurrentPlotType.Select(type => type == PlotType.Custom).ToReadOnlyReactiveProperty().AddTo(this.disposables);
            this.IsHistroy = this.IsLive.Select(value => !value).ToReadOnlyReactiveProperty().AddTo(this.disposables);

            this.CurrentPlotModel = new OxyPlot.PlotModel()
            {
                Axes =
                {
                    new OxyPlot.Axes.LinearAxis() { Unit = "A", Position = OxyPlot.Axes.AxisPosition.Left, Minimum = 0 },
                    new OxyPlot.Axes.DateTimeAxis() { Unit = "Time", Position = OxyPlot.Axes.AxisPosition.Bottom },
                },
            };
            // Change plot model colors.
            viewSettings
                .ObserveProperty(self => self.PlotStyle).Select(style => style.ObserveProperty(self => self.PlotForeground))
                .Switch()
                .Subscribe(color_ =>
                {
                    var color = color_.ToOxyColor();
                    this.CurrentPlotModel.TextColor = color;
                    this.CurrentPlotModel.PlotAreaBorderColor = color;
                    foreach (var axis in this.CurrentPlotModel.Axes)
                    {
                        axis.MajorGridlineColor = color;
                        axis.MinorGridlineColor = color;
                        axis.TextColor = color;
                        axis.AxislineColor = color;
                        axis.TicklineColor = color;
                    }
                })
                .AddTo(this.disposables);
            var totalCurrentSeries = new OxyPlot.Series.LineSeries()
            {
                Title = "Total Current",
            };
            // Change plot series color.
            viewSettings
                .ObserveProperty(self => self.PlotStyle).Select(style => style.ObserveProperty(self => self.SeriesColor))
                .Switch()
                .Subscribe(color => totalCurrentSeries.Color = color.ToOxyColor())
                .AddTo(this.disposables);

            this.CurrentPlotModel.Series.Add(totalCurrentSeries);


            var currentHistory = this.TotalCurrent
                .Select(Value => new { Value, TimeStamp = DateTime.Now })
                .ToObservationHistory(Observable.Empty<Unit>(), pair => (DateTime.Now - pair.TimeStamp) >= TimeSpan.FromSeconds(60))
                .AddTo(this.disposables);

            var livePlotSource = currentHistory.HistoryChanged
                .Select(_ =>
                {
                    var history = currentHistory.GetHistory();
                    return history.Select(pair => new OxyPlot.DataPoint() {X = OxyPlot.Axes.DateTimeAxis.ToDouble(pair.TimeStamp), Y = pair.Value});
                });


            var historicPlotPeriods = HistoricPlotTypeConditions
                .Select(condition => this.CurrentPlotType
                    .Where(plotType => plotType == condition.PlotType)
                    .Select(_ => { var now_ = DateTimeOffset.Now; return new { From = condition.CalculateFrom(now_), To = condition.CalculateTo(now_)}; })
                )
                .ToArray();
            
            var now = DateTimeOffset.Now;
            var today = now.Subtract(now.TimeOfDay);
            this.PlotFromDate = new ReactiveProperty<DateTimeOffset>(today).AddTo(this.disposables);
            this.PlotToDate = new ReactiveProperty<DateTimeOffset>(today).AddTo(this.disposables);
            this.PlotFromTime = new ReactiveProperty<TimeSpan>(now.TimeOfDay).AddTo(this.disposables);
            this.PlotToTime = new ReactiveProperty<TimeSpan>(now.TimeOfDay).AddTo(this.disposables);
            this.UpdatePlotPeriodCommand = new ReactiveCommand().AddTo(this.disposables);
            var customPlotPeriod = this.UpdatePlotPeriodCommand
                .Select(_ => new {From = this.PlotFromDate.Value.Add(this.PlotFromTime.Value), To = this.PlotToDate.Value.Add(this.PlotToTime.Value)});

            var recordedPlotSource = Observable
                .Merge(historicPlotPeriods.Concat(new[] {customPlotPeriod}))
                .Select(period => powerDistributionLogger.GetPowerDistrubutionByPeriod(period.From, period.To))
                .Select(dataPoints => dataPoints.Select(pair => new OxyPlot.DataPoint() {X = OxyPlot.Axes.DateTimeAxis.ToDouble(pair.TimeStamp.LocalDateTime), Y = pair.Consumption}));

            var hasDataPointsSubject = new Subject<bool>().AddTo(this.disposables);
            var accumulatedCurrentSubject = new Subject<float>().AddTo(this.disposables);
            this.AccumulatedCurrent = accumulatedCurrentSubject.ToReadOnlyReactiveProperty().AddTo(this.disposables);
            this.IsLive
                .Select(isLive => isLive ? livePlotSource : recordedPlotSource)
                .Switch()
                .ObserveOnUIDispatcher()
                .Do(dataPointsEnumerable =>
                {
                    var dataPoints = dataPointsEnumerable.ToArray();
                    accumulatedCurrentSubject.OnNext(
                        (float)dataPoints.Pairwise().Sum(dataPoint => 
                            (dataPoint.OldItem.Y + dataPoint.NewItem.Y) * (OxyPlot.Axes.DateTimeAxis.ToDateTime(dataPoint.NewItem.X) - OxyPlot.Axes.DateTimeAxis.ToDateTime(dataPoint.OldItem.X)).TotalSeconds )
                                / 3600.0f);

                    hasDataPointsSubject.OnNext(dataPoints.Length > 0);
                    totalCurrentSeries.Points.Clear();
                    totalCurrentSeries.Points.AddRange(dataPoints);
                })
                .Do(_ => this.CurrentPlotModel.InvalidatePlot(true))
                .Subscribe()
                .AddTo(this.disposables);

            this.HasDataPoints = hasDataPointsSubject.ToReadOnlyReactiveProperty().AddTo(this.disposables);
        }
        private Series ConvertSeries(ChartSeriesViewModel series)
        {
            Series newSeries = null;
            var valueSeries = series.GetScaleForProperty(series.ValueMemberPath);
            var labelSeries = series.GetScaleForProperty(series.LabelMemberPath);

            switch (series.SeriesType)
            {
                case( ChartSeriesType.Column):
                {
                    newSeries = new ColumnSeries
                    {
                        ValueField = series.ValueMemberPath,
                        ItemsSource = series.DataSource.Data,
                        FillColor = valueSeries.Color.ToOxyColor(),
                        StrokeColor = valueSeries.Color.ToOxyColor(),
                        YAxisKey = valueSeries.Name,
                        XAxisKey = labelSeries.Name,
                    };

                    break;
                }
                case( ChartSeriesType.Line ):
                {
                    newSeries = new LineSeries
                    {
                        ItemsSource = series.DataSource.Data,
                        DataFieldX = series.XMemberPath,
                        DataFieldY = series.YMemberPath,
                        MarkerType = MarkerType.Circle,
                        Color = valueSeries.Color.ToOxyColor(),
                        MarkerFill = valueSeries.Color.ToOxyColor(),
                        YAxisKey = valueSeries.Name,
                        XAxisKey = labelSeries.Name,
                    };
                    break;
                }
                case( ChartSeriesType.Spline):
                {
                    newSeries = new LineSeries
                    {
                        ItemsSource = series.DataSource.Data,
                        DataFieldX = series.XMemberPath,
                        DataFieldY = series.YMemberPath,
                        MarkerType = MarkerType.Circle,
                        Color = valueSeries.Color.ToOxyColor(),
                        MarkerFill = valueSeries.Color.ToOxyColor(),
                        Smooth = true,
                        YAxisKey = valueSeries.Name,
                        XAxisKey = labelSeries.Name,
                    };
                    break;
                }
                case(ChartSeriesType.Area):
                {
                    newSeries = new AreaSeries
                    {
                        ItemsSource = series.DataSource.Data,
                        DataFieldX = series.XMemberPath,
                        DataFieldY = series.YMemberPath,
                        Color = valueSeries.Color.ToOxyColor(),
                        Fill = valueSeries.Color.ToOxyColor(),
                        MarkerFill = valueSeries.Color.ToOxyColor(),
                        YAxisKey = valueSeries.Name,
                        XAxisKey = labelSeries.Name,
                    };
                    break;
                }
                case( ChartSeriesType.SplineArea):
                {
                    newSeries = new AreaSeries
                    {
                        ItemsSource = series.DataSource.Data,
                        DataFieldX = series.XMemberPath,
                        DataFieldY = series.YMemberPath,
                        Color = valueSeries.Color.ToOxyColor(),
                        Fill = valueSeries.Color.ToOxyColor(),
                        MarkerFill = valueSeries.Color.ToOxyColor(),
                        Smooth = true,
                        YAxisKey = valueSeries.Name,
                        XAxisKey = labelSeries.Name,
                    };
                    break;
                }
                case(ChartSeriesType.Bubble):
                {
                    newSeries = new ScatterSeries
                    {
                        ItemsSource = series.DataSource.Data,
                        DataFieldX = series.XMemberPath,
                        DataFieldY = series.YMemberPath,
                        DataFieldSize = series.RadiusMemberPath,
                        MarkerFill = valueSeries.Color.ToOxyColor(),
                        MarkerType = MarkerType.Circle,
                        YAxisKey = valueSeries.Name,
                        XAxisKey = labelSeries.Name,
                    };
                    break;
                }
                case( ChartSeriesType.StepLine):
                {
                    newSeries = new StairStepSeries
                    {
                        ItemsSource = series.DataSource.Data,
                        DataFieldX = series.XMemberPath,
                        DataFieldY = series.YMemberPath,
                        Color = valueSeries.Color.ToOxyColor(),
                        YAxisKey = valueSeries.Name,
                        XAxisKey = labelSeries.Name,
                    };
                    break;
                }
                default:
                {
                    return null;
                }
            }

            newSeries.Title = series.Name;

            return newSeries;
        }
示例#43
0
		public void DrawCurve(List<DataPoint> points, string title = null, LineStyle style = LineStyle.Solid)
		{
			var curve = new LineSeries
			{
				StrokeThickness = 2,
				Smooth = true,
				Color = OxyColor.FromRgb(0, 0, 0),
				LineStyle = style,
				Points = new List<IDataPoint>(),
				Title = title
			};
			for (var i = 0; i < points.Count; i++)
			{
				curve.Points.Add(new DataPoint(points[i].X, points[i].Y));
			}
			_mainPlot.Series.Add(curve);
		}
        private void CreateTheorIsotopicProfilePlot()
        {
            var theorProfileAligned = Workflow.Result.Target.IsotopicProfile.CloneIsotopicProfile();
            double fwhm;
            if (Workflow.Result.IsotopicProfile != null)
            {

                fwhm = Workflow.Result.IsotopicProfile.GetFWHM();
                IsotopicProfileUtilities.AlignTwoIsotopicProfiles(Workflow.Result.IsotopicProfile, theorProfileAligned);

                if (Workflow.SubtractedIso != null && Workflow.SubtractedIso.Peaklist.Count > 0)
                {
                    SubtractedMassSpecXYData = TheorXYDataCalculationUtilities.GetTheoreticalIsotopicProfileXYData(Workflow.SubtractedIso, fwhm);
                }
                else
                {
                    SubtractedMassSpecXYData = new XYData
                    {
                        Xvalues = new double[] { 400, 500, 600 },
                        Yvalues = new double[] { 0, 0, 0 }
                    };
                }
            }
            else
            {
                fwhm = DefaultMsPeakWidth;
            }

            TheorProfileXyData = TheorXYDataCalculationUtilities.GetTheoreticalIsotopicProfileXYData(Workflow.Result.Target.IsotopicProfile, fwhm);

            XYData xydata = new XYData();
            xydata.Xvalues = TheorProfileXyData.Xvalues;
            xydata.Yvalues = TheorProfileXyData.Yvalues;

            //scale to 100;
            for (int i = 0; i < xydata.Yvalues.Length; i++)
            {
                xydata.Yvalues[i] = xydata.Yvalues[i]*100;
            }

            string msGraphTitle = "Theoretical MS - m/z " +
                                  Workflow.Result.Target.MZ.ToString("0.0000") + "; z=" +
                                  Workflow.Result.Target.ChargeState;

            PlotModel plotModel = new PlotModel(msGraphTitle);
            plotModel.TitleFontSize = 11;
            plotModel.Padding = new OxyThickness(0);

            plotModel.PlotMargins = new OxyThickness(50, 0, 0, 0);
            plotModel.PlotAreaBorderThickness = 0;

            var series = new OxyPlot.Series.LineSeries();
            series.MarkerSize = 1;
            series.Color = OxyColors.Black;
            for (int i = 0; i < xydata.Xvalues.Length; i++)
            {
                series.Points.Add(new DataPoint(xydata.Xvalues[i], xydata.Yvalues[i]));
            }

            var xAxis = new LinearAxis(AxisPosition.Bottom, "m/z");
            xAxis.Minimum = MsGraphMinX;
            xAxis.Maximum = MsGraphMaxX;

            var yAxis = new LinearAxis(AxisPosition.Left, "Intensity");
            yAxis.Minimum = 0;
            yAxis.AbsoluteMinimum = 0;
            yAxis.Maximum = 105;
            yAxis.AbsoluteMaximum = 105;
            yAxis.StringFormat = "0.0E0";

            //yAxis.Maximum = maxIntensity + (maxIntensity * .05);
            //yAxis.AbsoluteMaximum = maxIntensity + (maxIntensity * .05);
            yAxis.AxisChanged += OnYAxisChange;

            xAxis.AxislineStyle = LineStyle.Solid;
            xAxis.AxislineThickness = 1;
            yAxis.AxislineStyle = LineStyle.Solid;
            yAxis.AxislineThickness = 1;

            plotModel.Series.Add(series);

            plotModel.Axes.Add(xAxis);
            plotModel.Axes.Add(yAxis);

            TheorIsoPlot = plotModel;
        }
        private void CreateChromCorrPlot()
        {
            ChromCorrXYData = new XYData();
            ChromCorrXYData.Xvalues = Workflow.ChromCorrelationRSquaredVals == null ? new double[] { 0, 1, 2, 3, 4 } : Workflow.ChromCorrelationRSquaredVals.Xvalues;
            ChromCorrXYData.Yvalues = Workflow.ChromCorrelationRSquaredVals == null ? new double[] { 0, 0, 0, 0, 0 } : Workflow.ChromCorrelationRSquaredVals.Yvalues;

            XYData xydata = new XYData();
            xydata.Xvalues = ChromCorrXYData.Xvalues;
            xydata.Yvalues = ChromCorrXYData.Yvalues;

            string graphTitle = "Isotope peak correlation data";
            PlotModel plotModel = new PlotModel(graphTitle);
            plotModel.TitleFontSize = 10;
            plotModel.Padding = new OxyThickness(0);
            plotModel.PlotMargins = new OxyThickness(0);
            plotModel.PlotAreaBorderThickness = 0;

            var series = new OxyPlot.Series.LineSeries();
            series.MarkerSize = 3;
            series.MarkerType = MarkerType.Square;
            series.MarkerStrokeThickness = 1;
            series.MarkerFill = OxyColors.DarkRed;
            series.MarkerStroke = OxyColors.Black;

            series.Color = OxyColors.Black;
            for (int i = 0; i < xydata.Xvalues.Length; i++)
            {
                series.Points.Add(new DataPoint(xydata.Xvalues[i], xydata.Yvalues[i]));
            }

            var xAxis = new LinearAxis(AxisPosition.Bottom, "isotopic peak #");

            var yAxis = new LinearAxis(AxisPosition.Left, "correlation");

            xAxis.AxislineStyle = LineStyle.Solid;
            xAxis.AxislineThickness = 1;
            yAxis.AxislineStyle = LineStyle.Solid;
            yAxis.AxislineThickness = 1;

            xAxis.FontSize = 8;
            xAxis.MajorStep = 1;
            xAxis.ShowMinorTicks = false;
            xAxis.MinorStep = 1;
            yAxis.FontSize = 8;

            yAxis.Minimum = 0;
            yAxis.AbsoluteMinimum = 0;
            yAxis.Maximum = 1.02;
            yAxis.AbsoluteMaximum = 1.02;
            yAxis.AxisChanged += OnYAxisChange;

            plotModel.Series.Add(series);
            plotModel.Axes.Add(yAxis);
            plotModel.Axes.Add(xAxis);

            ChromCorrelationPlot = plotModel;
        }
示例#46
0
        /// <summary>
        /// Setups the oxyplot.
        /// </summary>
        private void SetupOxyPlot()
        {
            XAxis = new LinearAxis {
                Key = "X",
                Position = AxisPosition.Bottom,
                AbsoluteMinimum = TimeSpan.FromSeconds (0).Ticks,
                LabelFormatter = x => {
                    if (x <= TimeSpan.FromSeconds (0).Ticks) {
                        return "Start";
                    }
                    return string.Format ("+{0}", TimeSpan.FromSeconds (x).ToString ("c"));
                },
                MajorGridlineThickness = 1,
                MajorGridlineStyle = LineStyle.Solid,
                MinorGridlineColor = OxyColors.LightGray,
                MinorGridlineStyle = LineStyle.Dot,
                MinorGridlineThickness = .5,
            };

            var YAxis = new LinearAxis {
                Position = AxisPosition.Left,
                Minimum = -0.1,
                Maximum = 1.1,
                LabelFormatter = x => ((int)x == 0) ? "LOW" : "HIGH",
                IsPanEnabled = false,
                IsZoomEnabled = false,
                AbsoluteMaximum = 1.1,
                AbsoluteMinimum = -0.1,
                MinorStep = 1,
                MajorStep = 1,
            };

            sequenceSeries = new OxyPlot.Series.StairStepSeries () {
                DataFieldX = "Time",
                DataFieldY = "Value",
            };

            repeateSeries = new OxyPlot.Series.LineSeries () {
                DataFieldX = "Time",
                DataFieldY = "Value",
                StrokeThickness = 2,
                LineStyle = LineStyle.Dot
            };

            plotModel = new PlotModel {
                PlotType = PlotType.XY,
                Background = OxyPlot.OxyColors.White,
            };
            plotModel.Axes.Add (YAxis);
            plotModel.Axes.Add (XAxis);
            plotModel.Series.Add (sequenceSeries);
            plotView = new PlotView (){ Name = "", Model = plotModel };

            vboxOptions.Add (plotView);
            ((Box.BoxChild)(vboxOptions [plotView])).Position = 2;

            plotView.SetSizeRequest (nvSequenceOptions.WidthRequest, this.HeightRequest / 3);

            plotView.ShowAll ();
        }
        private void CreateObservedIsotopicProfilePlot()
        {
            XYData xydata = new XYData();

            if (Workflow.MassSpectrumXYData == null)
            {
                xydata.Xvalues = Workflow.MassSpectrumXYData == null ? new double[] { 400, 1500 } : Workflow.MassSpectrumXYData.Xvalues;
                xydata.Yvalues = Workflow.MassSpectrumXYData == null ? new double[] { 0, 0 } : Workflow.MassSpectrumXYData.Yvalues;
            }
            else
            {
                xydata.Xvalues = Workflow.MassSpectrumXYData.Xvalues;
                xydata.Yvalues = Workflow.MassSpectrumXYData.Yvalues;

                xydata = xydata.TrimData(Workflow.Result.Target.MZ - 100, Workflow.Result.Target.MZ + 100);
            }

            if (Workflow.Result.IsotopicProfile != null)
            {
                MsGraphMaxY = Workflow.Result.IsotopicProfile.getMostIntensePeak().Height;
            }
            else
            {
                MsGraphMaxY = (float)xydata.getMaxY();
            }

            string msGraphTitle = Workflow.Result.Target.Code + "; m/z " +
                                  Workflow.Result.Target.MZ.ToString("0.0000") + "; z=" +
                                  Workflow.Result.Target.ChargeState;

            PlotModel plotModel = new PlotModel(msGraphTitle);
            plotModel.TitleFontSize = 11;
            plotModel.Padding = new OxyThickness(0);
            plotModel.PlotMargins = new OxyThickness(0);
            plotModel.PlotAreaBorderThickness = 0;

            var series = new OxyPlot.Series.LineSeries();
            series.MarkerSize = 1;
            series.Color = OxyColors.Black;
            for (int i = 0; i < xydata.Xvalues.Length; i++)
            {
                series.Points.Add(new DataPoint(xydata.Xvalues[i], xydata.Yvalues[i]));
            }

            var xAxis = new LinearAxis(AxisPosition.Bottom, "m/z");
            xAxis.Minimum = MsGraphMinX;
            xAxis.Maximum = MsGraphMaxX;

            var yAxis = new LinearAxis(AxisPosition.Left, "Intensity");
            yAxis.Minimum = 0;
            yAxis.AbsoluteMinimum = 0;
            yAxis.Maximum = MsGraphMaxY + MsGraphMaxY * 0.05;
            yAxis.StringFormat = "0.0E0";
            //yAxis.Maximum = maxIntensity + (maxIntensity * .05);
            //yAxis.AbsoluteMaximum = maxIntensity + (maxIntensity * .05);
            yAxis.AxisChanged += OnYAxisChange;

            xAxis.AxislineStyle = LineStyle.Solid;
            xAxis.AxislineThickness = 1;
            yAxis.AxislineStyle = LineStyle.Solid;
            yAxis.AxislineThickness = 1;

            plotModel.Series.Add(series);

            plotModel.Axes.Add(xAxis);
            plotModel.Axes.Add(yAxis);

            ObservedIsoPlot = plotModel;
        }
示例#48
0
        static void SavePng(string path, string name, List<double> A, List<double> B, List<Tuple<int, int>> pairings = null)
        {
            PngExporter pngify = new PngExporter();
            pngify.Width = 3200;
            pngify.Height = 1200;

            var model = new PlotModel() { Title = name };

            var aSeries = new OxyPlot.Series.LineSeries() { Color = OxyColors.Blue };
            var bSeries = new OxyPlot.Series.LineSeries() { Color = OxyColors.Red };

            for (int i = 0; i < A.Count; i++)
            {
                aSeries.Points.Add(new OxyPlot.DataPoint(i, A[i]));
            }

            for (int i = 0; i < B.Count; i++)
            {
                bSeries.Points.Add(new OxyPlot.DataPoint(i, B[i]));
            }

            if (pairings != null)
            {
                for (int i = 0; i < pairings.Count; i += 10)
                {
                    var lineSeries = new OxyPlot.Series.LineSeries() { Color = OxyColors.Gray, StrokeThickness = 0.2 };

                    lineSeries.Points.Add(aSeries.Points[pairings[i].Item1]);
                    lineSeries.Points.Add(bSeries.Points[pairings[i].Item2]);

                    model.Series.Add(lineSeries);
                }
            }

            model.Series.Add(aSeries);
            model.Series.Add(bSeries);

            model.Axes.Add(new OxyPlot.Axes.LinearAxis() { Minimum = 0, Maximum = 1, Position = OxyPlot.Axes.AxisPosition.Left });
            //model.Axes.Add(new OxyPlot.Axes.LinearAxis() { Minimum = 0, Maximum = 1, Position = OxyPlot.Axes.AxisPosition.Bottom });

            pngify.ExportToFile(model, path);
        }
        private void CreateChromatogramPlot()
        {
            var centerScan = Workflow.Result.Target.ScanLCTarget;
            ChromGraphMinX = centerScan - ChromGraphXWindowWidth / 2;
            ChromGraphMaxX = centerScan + ChromGraphXWindowWidth / 2;

            XYData xydata = new XYData();
            if (Workflow.ChromatogramXYData == null)
            {
                xydata.Xvalues = Workflow.ChromatogramXYData == null ? new double[] { 1, Run.MaxLCScan } : Workflow.ChromatogramXYData.Xvalues;
                xydata.Yvalues = Workflow.ChromatogramXYData == null ? new double[] { 0, 0 } : Workflow.ChromatogramXYData.Yvalues;
            }
            else
            {
                xydata.Xvalues = Workflow.ChromatogramXYData.Xvalues;
                xydata.Yvalues = Workflow.ChromatogramXYData.Yvalues;
            }

            string graphTitle = "TargetID=" + Workflow.Result.Target.ID + "; m/z " +
                                  Workflow.Result.Target.MZ.ToString("0.0000") + "; z=" +
                                  Workflow.Result.Target.ChargeState;

            PlotModel plotModel = new PlotModel(graphTitle);
            plotModel.TitleFontSize = 11;
            plotModel.Padding = new OxyThickness(0);
            plotModel.PlotMargins = new OxyThickness(0);
            plotModel.PlotAreaBorderThickness = 0;

            var series = new OxyPlot.Series.LineSeries();
            series.MarkerSize = 1;
            series.Color = OxyColors.Black;
            for (int i = 0; i < xydata.Xvalues.Length; i++)
            {
                series.Points.Add(new DataPoint(xydata.Xvalues[i], xydata.Yvalues[i]));
            }

            var xAxis = new LinearAxis(AxisPosition.Bottom, "scan");
            xAxis.Minimum = ChromGraphMinX;
            xAxis.Maximum = ChromGraphMaxX;

            var yAxis = new LinearAxis(AxisPosition.Left, "Intensity");
            yAxis.Minimum = 0;
            yAxis.AbsoluteMinimum = 0;

            var maxY = xydata.getMaxY();
            yAxis.Maximum = maxY + maxY * 0.05;
            yAxis.AxisChanged += OnYAxisChange;

            xAxis.AxislineStyle = LineStyle.Solid;
            xAxis.AxislineThickness = 1;
            yAxis.AxislineStyle = LineStyle.Solid;
            yAxis.AxislineThickness = 1;

            plotModel.Series.Add(series);
            plotModel.Axes.Add(xAxis);
            plotModel.Axes.Add(yAxis);

            ChromatogramPlot = plotModel;
        }
示例#50
0
        protected MainViewModel()
        {
            _model = new PlotModel
            {
                IsLegendVisible = false,
                DefaultFontSize = 0,
                PlotMargins = new OxyThickness(20, 0, 0, 10)
            };
            _series = new LineSeries
            {
                MarkerType = MarkerType.Circle,
                MarkerSize = 1
            };
            _model.Series.Add(_series);

            _emptyDataPoint = new DataPoint(-1.0, -1.0);
            _newDataPoint = _emptyDataPoint;

            _dispatcher = Dispatcher.CurrentDispatcher;

            TimeRange = 10000;
            _refreshPlot = true;

            _updateThread = new Thread(Update);
            _updateThread.SetApartmentState(ApartmentState.STA);
            _updateThread.IsBackground = true;
            _updateThread.Start();
        }
        private void CreateMsPlotForScanByScanAnalysis(ScanSet scanSet)
        {
            XYData xydata = new XYData();
            xydata.Xvalues = MassSpecXyData == null ? new double[] { 400, 1500 } : MassSpecXyData.Xvalues;
            xydata.Yvalues = MassSpecXyData == null ? new double[] { 0, 0 } : MassSpecXyData.Yvalues;

            string msGraphTitle = "Observed MS - Scan: " + scanSet;

            MsGraphMaxY = (float)xydata.getMaxY(MsGraphMinX, MsGraphMaxX);

            PlotModel plotModel = new PlotModel(msGraphTitle);
            plotModel.TitleFontSize = 11;
            plotModel.Padding = new OxyThickness(0);
            plotModel.PlotMargins = new OxyThickness(0);
            plotModel.PlotAreaBorderThickness = 0;

            var series = new OxyPlot.Series.LineSeries();
            series.MarkerSize = 1;
            series.Color = OxyColors.Black;
            for (int i = 0; i < xydata.Xvalues.Length; i++)
            {
                series.Points.Add(new DataPoint(xydata.Xvalues[i], xydata.Yvalues[i]));
            }

            var xAxis = new LinearAxis(AxisPosition.Bottom, "m/z");
            xAxis.Minimum = MsGraphMinX;
            xAxis.Maximum = MsGraphMaxX;

             var yAxis = new LinearAxis(AxisPosition.Left, "Intensity");
            yAxis.Minimum = 0;
            yAxis.AbsoluteMinimum = 0;
            yAxis.Maximum = MsGraphMaxY + MsGraphMaxY * 0.05;
            //yAxis.Maximum = maxIntensity + (maxIntensity * .05);
            //yAxis.AbsoluteMaximum = maxIntensity + (maxIntensity * .05);
            yAxis.AxisChanged += OnYAxisChange;
            yAxis.StringFormat = "0.0E0";

            xAxis.AxislineStyle = LineStyle.Solid;
            xAxis.AxislineThickness = 1;
            yAxis.AxislineStyle = LineStyle.Solid;
            yAxis.AxislineThickness = 1;

            plotModel.Series.Add(series);

            plotModel.Axes.Add(xAxis);
            plotModel.Axes.Add(yAxis);

            ObservedIsoPlot = plotModel;
        }
示例#52
0
        /// <summary>
        /// Displaies the plot.
        /// </summary>
        private void DisplayPlot()
        {
            if (pinSequence != null) {
                plotView.Model.Series.Clear ();

                var current = new TimeSpan (0);
                var data = new Collection<TimeValue> ();
                for (int i = 0; i < pinSequence.Chain.Count; i++) {
                    data.Add (new TimeValue () {
                        Time = current,
                        Value = ((pinSequence.Chain [i].State == DPinState.HIGH) ? 1 : 0)
                    });
                    current = current.Add (pinSequence.Chain [i].Duration);
                    data.Add (new TimeValue () {
                        Time = current,
                        Value = ((pinSequence.Chain [i].State == DPinState.HIGH) ? 1 : 0)
                    });
                }

                sequenceSeries = new OxyPlot.Series.LineSeries () {
                    DataFieldX = "Time",
                    DataFieldY = "Value",
                    ItemsSource = data,
                    StrokeThickness = 2,
                    Color = ColorHelper.GdkColorToOxyColor (selectedPin.PlotColor)
                };

                repeateSeries.Color = ColorHelper.GdkColorToOxyColor (selectedPin.PlotColor);

                //next Cycle Tease
                //				if ((rbRepeateContinously.Active || (rbStopAfter.Active && sbRadioBtnStopAfter.ValueAsInt > 1)) && data.Count > 0)
                //				{
                //					var repeateData = new Collection<TimeValue> ();
                //					repeateData.Add (data.Last ());
                //					repeateData.Add (
                //						new TimeValue {
                //							Time = data.Last ().Time,
                //							Value = ((pinSequence.Chain [0].State == DPinState.HIGH) ? 1 : 0)
                //						});
                //					repeateData.Add (
                //						new TimeValue {
                //							Time = data.Last ().Time.Add (pinSequence.Chain [0].Duration),
                //							Value = ((pinSequence.Chain [0].State == DPinState.HIGH) ? 1 : 0)
                //						});
                //					repeateSeries.ItemsSource = repeateData;
                //					plotView.Model.Series.Add (repeateSeries);
                //				}

                plotView.Model.Series.Add (sequenceSeries);
                plotView.InvalidatePlot (true);
                plotView.Model.InvalidatePlot (true);
                plotView.ShowAll ();
            }
        }
示例#53
0
 public void LineSeries()
 {
     var s1 = new OxyPlot.Series.LineSeries();
     var s2 = new LineSeries();
     OxyAssert.PropertiesAreEqual(s1, s2);
 }
        private void GetMassSpectrumForCurrentResult()
        {
            if (ObservedIsoPlot==null)
            {
                ObservedIsoPlot=  CreateObservedIsoPlot();
            }

            XYData xydata = new XYData();

            if (CurrentResultInfo.MassSpectrumXYData == null)
            {
                xydata.Xvalues = CurrentResultInfo.MassSpectrumXYData == null ? new double[] { 400, 1500 } : CurrentResultInfo.MassSpectrumXYData.Xvalues;
                xydata.Yvalues = CurrentResultInfo.MassSpectrumXYData == null ? new double[] { 0, 0 } : CurrentResultInfo.MassSpectrumXYData.Yvalues;
            }
            else
            {
                xydata.Xvalues = CurrentResultInfo.MassSpectrumXYData.Xvalues;
                xydata.Yvalues = CurrentResultInfo.MassSpectrumXYData.Yvalues;

                xydata = xydata.TrimData(CurrentResultInfo.Result.Target.MZ - 2, CurrentResultInfo.Result.Target.MZ + 8);
            }

            double msGraphMaxY;
            if (CurrentResultInfo.Result.IsotopicProfile != null)
            {
                msGraphMaxY = CurrentResultInfo.Result.IsotopicProfile.getMostIntensePeak().Height;
            }
            else
            {
                msGraphMaxY = (float)xydata.getMaxY();
            }

            string msGraphTitle = "TargetID= " + CurrentResultInfo.Result.Target.ID +   "; m/z " + CurrentResultInfo.Result.Target.MZ.ToString("0.0000") + "; z=" +
                                  CurrentResultInfo.Result.Target.ChargeState + "; Scan= " + CurrentResultInfo.Result.ScanSet??"[No scan selected]";

            ObservedIsoPlot.Series.Clear();

            var series = new OxyPlot.Series.LineSeries();
            series.MarkerSize = 1;
            series.Color = OxyColors.Black;
            for (int i = 0; i < xydata.Xvalues.Length; i++)
            {
                series.Points.Add(new DataPoint(xydata.Xvalues[i], xydata.Yvalues[i]));
            }

            ObservedIsoPlot.Axes[1].Maximum = msGraphMaxY + msGraphMaxY * 0.05;
            ObservedIsoPlot.Series.Add(series);
        }
        private void CreateChromatogram()
        {
            bool canGenerateChrom = Run != null && Run.ResultCollection.MSPeakResultList != null &&
                                    Run.ResultCollection.MSPeakResultList.Count > 0 && Peaks != null && Peaks.Count > 0
                                    && SelectedPeak != null;

            if (!canGenerateChrom) return;

            double scanWindowWidth = 600;
            int lowerScan = (int)Math.Round(Math.Max(MinLcScan, CurrentLcScan - scanWindowWidth / 2));
            int upperScan = (int)Math.Round(Math.Min(MaxLcScan, CurrentLcScan + scanWindowWidth / 2));

            ChromXyData = _peakChromatogramGenerator.GenerateChromatogram(Run, lowerScan, upperScan,
                                                                          SelectedPeak.XValue, ChromToleranceInPpm);

            if (ChromXyData == null)
            {
                ChromXyData = new XYData();
                ChromXyData.Xvalues = new double[] { lowerScan, upperScan };
                ChromXyData.Yvalues = new double[] { 0, 0 };

            }

            var maxY = (float)ChromXyData.getMaxY();

            string graphTitle = "XIC for most intense peak (m/z " + SelectedPeak.XValue.ToString("0.000") + ")";

            PlotModel plotModel = new PlotModel(graphTitle);
            plotModel.TitleFontSize = 9;
            plotModel.Padding = new OxyThickness(0);
            plotModel.PlotMargins = new OxyThickness(0);
            plotModel.PlotAreaBorderThickness = 0;

            var series = new OxyPlot.Series.LineSeries();
            series.MarkerSize = 1;
            series.Color = OxyColors.Black;
            for (int i = 0; i < ChromXyData.Xvalues.Length; i++)
            {
                series.Points.Add(new DataPoint(ChromXyData.Xvalues[i], ChromXyData.Yvalues[i]));
            }

            var xAxis = new LinearAxis(AxisPosition.Bottom, "scan");
            xAxis.Minimum = lowerScan;
            xAxis.Maximum = upperScan;

            var yAxis = new LinearAxis(AxisPosition.Left, "Intensity");
            yAxis.Minimum = 0;
            yAxis.AbsoluteMinimum = 0;
            yAxis.Maximum = maxY + maxY * 0.05;
            yAxis.AxisChanged += OnYAxisChange;

            xAxis.AxislineStyle = LineStyle.Solid;
            xAxis.AxislineThickness = 1;
            yAxis.AxislineStyle = LineStyle.Solid;
            yAxis.AxislineThickness = 1;

            plotModel.Series.Add(series);
            plotModel.Axes.Add(xAxis);
            plotModel.Axes.Add(yAxis);

            ChromatogramPlot = plotModel;
        }
示例#56
0
        public void B11_Backgrounds()
        {
            var plot = new PlotModel("Backgrounds");
            plot.Axes.Add(new LinearAxis(AxisPosition.Bottom, "X-axis"));
            var yaxis1 = new LinearAxis(AxisPosition.Left, "Y1") { Key = "Y1", StartPosition = 0, EndPosition = 0.5 };
            var yaxis2 = new LinearAxis(AxisPosition.Left, "Y2") { Key = "Y2", StartPosition = 0.5, EndPosition = 1 };
            plot.Axes.Add(yaxis1);
            plot.Axes.Add(yaxis2);

            Action<LineSeries> addExamplePoints = ls =>
                {
                    ls.Points.Add(new DataPoint(3, 13));
                    ls.Points.Add(new DataPoint(10, 47));
                    ls.Points.Add(new DataPoint(30, 23));
                    ls.Points.Add(new DataPoint(40, 65));
                    ls.Points.Add(new DataPoint(80, 10));
                };

            var ls1 = new LineSeries { Background = OxyColors.LightSeaGreen, YAxisKey = "Y1" };
            addExamplePoints(ls1);
            plot.Series.Add(ls1);

            var ls2 = new LineSeries { Background = OxyColors.LightSkyBlue, YAxisKey = "Y2" };
            addExamplePoints(ls2);
            plot.Series.Add(ls2);

            // OxyAssert.AreEqual(plot, "B11");
        }