コード例 #1
0
        private void SetupChart()
        {
            model = new PlotModel()
            {
            };

            var linearAxis = new OxyPlot.Axes.LinearAxis()
            {
                MinimumPadding = 0,
                MaximumPadding = 0.1,
            };

            var axis = new OxyPlot.Axes.CategoryAxis()
            {
            };

            axis.Labels.AddRange(new[] { "Video A", "Video B" });

            model.Axes.Add(linearAxis);
            model.Axes.Add(axis);

            series = new ErrorColumnSeries()
            {
                StrokeThickness = 1,
            };

            model.Series.Add(series);

            chart.Children.Add(new PlotView()
            {
                Model  = model,
                Width  = chart.Width,
                Height = chart.Height,
            });
        }
コード例 #2
0
        /// <summary>
        /// This function is called every frame to update the graph's values
        /// </summary>
        public override void Draw()
        {
            base.Draw();
            PlotModel.Title = "Memory Usage";
            CategoryAxis X = new CategoryAxis();
            CategoryAxis Y = new CategoryAxis(); // Create the X and Y axes

            X.Title = "Usage";
            PlotModel.Axes.Add(Y);
            PlotModel.Axes.Add(X); // Add them to the model
            ColumnSeries alloc = new ColumnSeries();

            alloc.Items.Add(new ColumnItem(256)); // create a column and set its value
            alloc.ColumnWidth = 25;
            alloc.FillColor   = Colors.CornflowerBlue.ToOxyColor();
            alloc.Title       = "Allocated";
            PlotModel.Series.Add(alloc);
            ColumnSeries free = new ColumnSeries();

            free.Items.Add(new ColumnItem(512));
            free.ColumnWidth = 25;
            free.FillColor   = Colors.GreenYellow.ToOxyColor();
            free.Title       = "Free";
            PlotModel.Series.Add(free);
            ColumnSeries swap = new ColumnSeries();

            swap.Items.Add(new ColumnItem(768));
            swap.ColumnWidth = 25;
            swap.FillColor   = Colors.Red.ToOxyColor();
            swap.Title       = "Swap";
            PlotModel.Series.Add(swap); // add the columns to the plot model
        }
コード例 #3
0
        public void CategoryAxis()
        {
            var s1 = new OxyPlot.Axes.CategoryAxis();
            var s2 = new CategoryAxis();

            OxyAssert.PropertiesAreEqual(s1, s2);
        }
コード例 #4
0
        private void CreateTradeRetsByDayAndHourChartModel()
        {
            var distinctDays  = Data.tradeRetsByDayAndHour.Select(x => x.weekDay).Distinct();
            var distinctHours = Data.tradeRetsByDayAndHour.Select(x => x.hour).OrderByDescending(x => x).Distinct();

            var model = new PlotModel();
            var xAxis = new OxyPlot.Axes.CategoryAxis
            {
                Key         = "dayAxis",
                Position    = OxyPlot.Axes.AxisPosition.Bottom,
                ItemsSource = distinctDays.Select(x => x.ToString())
            };

            var yAxis = new OxyPlot.Axes.CategoryAxis
            {
                Key         = "hourAxis",
                Position    = OxyPlot.Axes.AxisPosition.Left,
                ItemsSource = distinctHours.Select(x => x.ToString())
            };

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

            model.Axes.Add(new OxyPlot.Axes.LinearColorAxis
            {
                Palette = OxyPalettes.BlueWhiteRed31
            });

            //take avg trade ret by day/hour and turn it into an array
            int dayCount  = distinctDays.Count();
            int hourCount = distinctHours.Count();
            var data      = new double[dayCount, hourCount];

            var weekDayTrans = distinctDays.Select((x, a) => new { x, a }).ToDictionary(x => x.x, x => x.a);
            var hourTrans    = distinctHours.Select((x, a) => new { x, a }).OrderByDescending(x => x.x).ToDictionary(x => x.x, x => x.a);

            foreach (var ret in Data.tradeRetsByDayAndHour)
            {
                data[weekDayTrans[ret.weekDay], hourTrans[ret.hour]] = ret.avgRet;
            }

            var heatMapSeries = new OxyPlot.Series.HeatMapSeries
            {
                X0                = 0,
                X1                = dayCount - 1,
                Y0                = 0,
                Y1                = hourCount - 1,
                XAxisKey          = "dayAxis",
                YAxisKey          = "hourAxis",
                RenderMethod      = HeatMapRenderMethod.Rectangles,
                LabelFontSize     = 0.2, // neccessary to display the label
                LabelFormatString = "p2",
                Data              = data
            };

            model.Series.Add(heatMapSeries);

            TradeRetsByDayAndHourModel = model;
        }
コード例 #5
0
        /// <summary>
        /// This function is called every frame to update the graph's values
        /// </summary>
        public override void Draw()
        {
            base.Draw();
            PlotModel.Title = "%CPU Utilisation";
            CategoryAxis X = new CategoryAxis();
            CategoryAxis Y = new CategoryAxis(); // Create the X and Y axes

            X.Title          = "% Utilised";
            Y.IntervalLength = 1.0;
            PlotModel.Axes.Add(Y);
            PlotModel.Axes.Add(X);                 // add them to the model
            ColumnSeries col = new ColumnSeries(); // create a column

            col.Items.Add(new ColumnItem(100));    // set the value of the column
            col.ColumnWidth = 25;
            col.FillColor   = Colors.CornflowerBlue.ToOxyColor();
            PlotModel.Series.Add(col); // add the column to the graph
        }
コード例 #6
0
        static PlotModel CreateChartOnlyBars()
        {
            var splotModel = new PlotModel();


            splotModel.IsLegendVisible     = false;
            splotModel.Background          = OxyColor.FromArgb(0, 0, 0, 255);
            splotModel.TextColor           = OxyColor.FromArgb(0, 0, 0, 255);
            splotModel.PlotAreaBorderColor = OxyColor.FromArgb(0, 0, 0, 255);

            var axis = new OxyPlot.Axes.LinearAxis();

            axis.IsPanEnabled = axis.IsAxisVisible = false;

            splotModel.Axes.Add(axis);

            var dateAxis = new OxyPlot.Axes.CategoryAxis();

            dateAxis.IsPanEnabled = dateAxis.IsAxisVisible = false;
            splotModel.Axes.Add(dateAxis);

            return(splotModel);
        }
コード例 #7
0
        private static void MakeBarPlot([JetBrains.Annotations.NotNull] string outputPath, [ItemNotNull][JetBrains.Annotations.NotNull] List <Column> columns, int position, int day)
        {
            var plotModel2 = new PlotModel();
            // filter significant columns
            var allColumns = new List <Tuple <string, double> >();

            for (var i = 1; i < columns.Count; i++)
            {
                allColumns.Add(new Tuple <string, double>(columns[i].Name, columns[i].MakeSum(position, 1440)));
            }
            allColumns.Sort((x, y) => y.Item2.CompareTo(x.Item2));
            var topCols = allColumns.Select(x => x.Item1).Take(20).ToList();
            var p       = OxyPalettes.HueDistinct(topCols.Count);
            var oxc     = OxyColor.FromArgb(255, 50, 50, 50);

            plotModel2.LegendPosition    = LegendPosition.BottomCenter;
            plotModel2.LegendPlacement   = LegendPlacement.Outside;
            plotModel2.LegendOrientation = LegendOrientation.Horizontal;
            plotModel2.Title             = "Day " + day;
            // axes
            var cate = new CategoryAxis
            {
                AbsoluteMinimum = 0,
                MinimumPadding  = 0,
                GapWidth        = 0,
                MajorStep       = 60,
                Title           = "Activities"
            };

            plotModel2.Axes.Add(cate);

            var linearAxis2 = new LinearAxis
            {
                AbsoluteMinimum = 0,
                MaximumPadding  = 0.06,
                MinimumPadding  = 0,
                Title           = "Minutes"
            };

            plotModel2.Axes.Add(linearAxis2);
            const int minutesToSum = 15;

            for (var i = 1; i < columns.Count; i++)
            {
                if (columns[i].MakeSum(position, 1440) > 0)
                {
                    var columnSeries2 = new ColumnSeries
                    {
                        IsStacked       = true,
                        StrokeThickness = 0,
                        Title           = columns[i].Name
                    };
                    for (var j = position; j < position + 1440; j += minutesToSum)
                    {
                        columnSeries2.Items.Add(new ColumnItem(columns[i].MakeSum(j, minutesToSum) / minutesToSum));
                    }
                    if (topCols.Contains(columns[i].Name))
                    {
                        var coloridx = topCols.IndexOf(columns[i].Name);
                        columnSeries2.FillColor = p.Colors[coloridx];
                    }
                    else
                    {
                        columnSeries2.FillColor = oxc;
                    }
                    plotModel2.Series.Add(columnSeries2);
                }
            }
            var path2 = Path.Combine(outputPath, "ActivityPlot." + day + ".bar.png");

            PngExporter.Export(plotModel2, path2, 3200, 1600, OxyColor.FromRgb(255, 255, 255), 100);
        }
コード例 #8
0
 public void CategoryAxis()
 {
     var s1 = new OxyPlot.Axes.CategoryAxis();
     var s2 = new CategoryAxis();
     OxyAssert.PropertiesAreEqual(s1, s2);
 }
コード例 #9
0
		public WeatherObservationPage ()
		{
			var weatherSeries = new LineSeries ();

			var m = new PlotModel ("Weather");

			var magnitudeAxis = new OxyPlot.Axes.LinearAxis ();
			magnitudeAxis.Minimum = 0;
			magnitudeAxis.Maximum = 40;
			magnitudeAxis.Title = "Temperature";
			m.Axes.Add (magnitudeAxis);

			var dateAxis = new OxyPlot.Axes.CategoryAxis ();
			dateAxis.Labels.Add("Station");
			m.Axes.Add (dateAxis);

			weatherSeries.ItemsSource = new List<DataPoint> (); // empty to start
			m.Series.Add (weatherSeries);

			var opv = new OxyPlotView {
				WidthRequest = 300, HeightRequest = 300,
				BackgroundColor = Color.Aqua
			};
			opv.Model = m;

			Insights.Track ("SHOWGRAPH");


			var l = new Label {
				Text = "Hello, Oxyplot!",
				VerticalOptions = LayoutOptions.CenterAndExpand,
				HorizontalOptions = LayoutOptions.CenterAndExpand,
			};
			var b = new Button { Text = "Get Weather Data" };
			b.Clicked += async (sender, e) => {
				var sv = new GeoNamesWebService();
				var we = await sv.GetWeatherObservationsAsync();
				Xamarin.Forms.Device.BeginInvokeOnMainThread( () => {
					Debug.WriteLine("found " + we.Length + " weather observations");
					l.Text = we.Length + " weather observations";

					var eqlist = new List<WeatherObservation>(we);
//					eqlist.Sort((x, y) => string.Compare(x.datetime, y.datetime));


					var columSeries = new ColumnSeries();


					foreach (var eq in eqlist) {
						double t = 0.0;
						Double.TryParse(eq.temperature, out t);
						columSeries.Items.Add(new ColumnItem(t, 0));
						//pts.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Parse(eq.datetime)), Double.Parse(eq.temperature)));
					}
					opv.Model.Series.Clear();
					opv.Model.Series.Add(columSeries);

					Device.BeginInvokeOnMainThread(() => {
						opv.InvalidateDisplay ();
					});
				});
			};


			Padding = new Thickness (0, 20, 0, 0);
			Content = new StackLayout {
				Children = {
					opv,
					b,
					l
				}
			};
		}
コード例 #10
0
		static PlotModel CreateChartOnlyBars ()
		{
			var splotModel = new PlotModel ();


			splotModel.IsLegendVisible = false;
			splotModel.Background = OxyColor.FromArgb (0, 0, 0, 255);
			splotModel.TextColor = OxyColor.FromArgb (0, 0, 0, 255);
			splotModel.PlotAreaBorderColor = OxyColor.FromArgb (0, 0, 0, 255);

			var axis = new OxyPlot.Axes.LinearAxis ();
			axis.IsPanEnabled =  axis.IsAxisVisible = false;

			splotModel.Axes.Add (axis);

			var dateAxis = new OxyPlot.Axes.CategoryAxis ();
			dateAxis.IsPanEnabled =   dateAxis.IsAxisVisible = false;
			splotModel.Axes.Add (dateAxis);

			return splotModel;
		}
コード例 #11
0
ファイル: Form1.cs プロジェクト: Malakahh/BesterUI
        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");
            }
        }
コード例 #12
0
ファイル: MoodPeople.cs プロジェクト: fsoyka/RUOK
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            //somehow an orientation change changes the language. Therefore we check and reset the language here depending on the stored preferences
            //check language preferences, if they are set apply them otherwise stay with the current language
            ISharedPreferences sharedPref = GetSharedPreferences("com.FSoft.are_u_ok.PREFERENCES",FileCreationMode.Private);
            String savedLanguage = sharedPref.GetString ("Language", "");
            //if there is a saved language (length > 0) and the current language is different from the saved one, then change
            Android.Content.Res.Configuration conf = Resources.Configuration;
            if ((savedLanguage.Length > 0) & (conf.Locale.Language != savedLanguage)){
                //set language and restart activity to see the effect
                conf.Locale = new Java.Util.Locale(savedLanguage);
                Android.Util.DisplayMetrics dm = this.Resources.DisplayMetrics;
                this.Resources.UpdateConfiguration (conf, dm);
            }

            // Create your application here
            SetContentView(Resource.Layout.PlotDoubleScreen);
            db = new MoodDatabase(this);

            Button Back = FindViewById<Button> (Resource.Id.button1);
            Back.Click += delegate {
                //create an intent to go back to the history screen
            //				Intent intent = new Intent(this, typeof(History));
            //				intent.SetFlags(ActivityFlags.ClearTop); //remove the history and go back to home screen
            //				StartActivity(intent);
                OnBackPressed();
            };

            //CREATE HISTOGRAM FOR PEOPLE CONTEXT ON THE LEFT
            plotViewModelLeft = FindViewById<PlotView>(Resource.Id.plotViewModelLeft);

            //select all mood values for which people was 0 (alone)
            cursor = db.ReadableDatabase.RawQuery("SELECT mood FROM MoodData WHERE people = 0 AND NOT mood = -1", null); // cursor query

            if (cursor.Count > 0) {

                //initialize with 9 zero entries
                int[] histArray = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
                //go through each entry and create the histogram count
                for (int ii = 0; ii < cursor.Count; ii++) {
                    cursor.MoveToPosition (ii);
                    int mood_temp = cursor.GetInt (0); //get mood from database
                    histArray [mood_temp] += 1; //increase histogram frequency by one
                    //System.Console.WriteLine("Mood: " + mood_temp.ToString() + " Freq: " + histArray [mood_temp].ToString());
                }

                PlotModel temp = new PlotModel ();
                //determine font size, either keep default or for small screens set it to a smaller size
                double dFontSize = temp.DefaultFontSize;
                if (Resources.DisplayMetrics.HeightPixels <= 320)
                    dFontSize = 5;

                //define axes

                //we need 9 categories for the histogram since we score the mood between 0 and 8
                var categoryAxis1 = new OxyPlot.Axes.CategoryAxis ();
            //			categoryAxis1.GapWidth = 0;
                categoryAxis1.LabelField = "Label";
            //			categoryAxis1.MinorStep = 1;
                categoryAxis1.Position = OxyPlot.Axes.AxisPosition.Bottom;
                categoryAxis1.ActualLabels.Add ("0");
                categoryAxis1.ActualLabels.Add ("1");
                categoryAxis1.ActualLabels.Add ("2");
                categoryAxis1.ActualLabels.Add ("3");
                categoryAxis1.ActualLabels.Add ("4");
                categoryAxis1.ActualLabels.Add ("5");
                categoryAxis1.ActualLabels.Add ("6");
                categoryAxis1.ActualLabels.Add ("7");
                categoryAxis1.ActualLabels.Add ("8");

            //			categoryAxis1.AbsoluteMaximum = 10;
            //			categoryAxis1.Maximum = 10;
                categoryAxis1.StringFormat = "0";
                categoryAxis1.IsPanEnabled = false;
                categoryAxis1.IsZoomEnabled = false;
                categoryAxis1.FontSize = dFontSize;
                categoryAxis1.Title = Resources.GetString (Resource.String.Mood);
                temp.Axes.Add (categoryAxis1);

                var linearAxis1 = new OxyPlot.Axes.LinearAxis ();
                linearAxis1.AbsoluteMinimum = 0;
                linearAxis1.AbsoluteMaximum = histArray.Max () * 1.2; //this has to be a bit higher than the highest frequency of the histogram
                linearAxis1.Minimum = 0;
                linearAxis1.Maximum = histArray.Max () * 1.2;
            //			linearAxis1.MaximumPadding = 0.1;
            //			linearAxis1.MinimumPadding = 0;
                linearAxis1.Position = OxyPlot.Axes.AxisPosition.Left;
                linearAxis1.FontSize = dFontSize;
                linearAxis1.IsZoomEnabled = false;
                linearAxis1.StringFormat = "0.0";
                linearAxis1.Title = Resources.GetString (Resource.String.Frequency);
                temp.Axes.Add (linearAxis1);

                var columnSeries1 = new ColumnSeries ();
                //http://forums.xamarin.com/discussion/20809/is-there-no-plotview-which-is-in-oxyplot-compent-in-xamarin-android
                //add data
                foreach (int i in histArray) {
                    columnSeries1.Items.Add (new ColumnItem (i, -1));
                }
                columnSeries1.LabelFormatString = "{0}";
                columnSeries1.FontSize = dFontSize;
                temp.Series.Add (columnSeries1);

                temp.Title = Resources.GetString (Resource.String.Alone);
                temp.TitleFontSize = dFontSize;
                MyModelLeft = temp;

                plotViewModelLeft.Model = MyModelLeft;
            }

            //CREATE HISTOGRAM FOR PEOPLE CONTEXT ON THE RIGHT
            plotViewModelRight = FindViewById<PlotView>(Resource.Id.plotViewModelRight);

            //select all mood values for which people was 0 (alone)
            cursor = db.ReadableDatabase.RawQuery("SELECT mood FROM MoodData WHERE NOT people = 0 AND NOT mood = -1", null); // cursor query

            //only continue if there is data, otherwise there will be an error
            if (cursor.Count > 0) {

                //initialize with 9 zero entries
                int[] histArrayRight = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
                //go through each entry and create the histogram count
                for (int ii = 0; ii < cursor.Count; ii++) {
                    cursor.MoveToPosition (ii);
                    int mood_temp = cursor.GetInt (0); //get mood from database
                    histArrayRight [mood_temp] += 1; //increase histogram frequency by one
                    //System.Console.WriteLine("Mood: " + mood_temp.ToString() + " Freq: " + histArray [mood_temp].ToString());
                }

                PlotModel tempRight = new PlotModel ();
                double dFontSize = tempRight.DefaultFontSize;
                if (Resources.DisplayMetrics.HeightPixels <= 320)
                    dFontSize = 5;

                //define axes

                //we need 9 categories for the histogram since we score the mood between 0 and 8
                var categoryAxisRight = new OxyPlot.Axes.CategoryAxis ();
                //categoryAxisRight.LabelField = "Label";
                categoryAxisRight.Position = OxyPlot.Axes.AxisPosition.Bottom;
                categoryAxisRight.ActualLabels.Add ("0");
                categoryAxisRight.ActualLabels.Add ("1");
                categoryAxisRight.ActualLabels.Add ("2");
                categoryAxisRight.ActualLabels.Add ("3");
                categoryAxisRight.ActualLabels.Add ("4");
                categoryAxisRight.ActualLabels.Add ("5");
                categoryAxisRight.ActualLabels.Add ("6");
                categoryAxisRight.ActualLabels.Add ("7");
                categoryAxisRight.ActualLabels.Add ("8");
                categoryAxisRight.StringFormat = "0";
                categoryAxisRight.IsPanEnabled = false;
                categoryAxisRight.IsZoomEnabled = false;
                categoryAxisRight.FontSize = dFontSize;
                categoryAxisRight.Title = Resources.GetString (Resource.String.Mood);
                tempRight.Axes.Add (categoryAxisRight);

                var linearAxisRight = new OxyPlot.Axes.LinearAxis ();
                linearAxisRight.AbsoluteMinimum = 0;
                linearAxisRight.AbsoluteMaximum = histArrayRight.Max () * 1.2; //this has to be a bit higher than the highest frequency of the histogram
                linearAxisRight.Minimum = 0;
                linearAxisRight.Maximum = histArrayRight.Max () * 1.2;
                linearAxisRight.Position = OxyPlot.Axes.AxisPosition.Left;
                linearAxisRight.FontSize = dFontSize;
                linearAxisRight.IsZoomEnabled = false;
                linearAxisRight.StringFormat = "0.0";
                linearAxisRight.Title = Resources.GetString (Resource.String.Frequency);
                tempRight.Axes.Add (linearAxisRight);

                var columnSeriesRight = new ColumnSeries ();
                //http://forums.xamarin.com/discussion/20809/is-there-no-plotview-which-is-in-oxyplot-compent-in-xamarin-android
                //add data
                foreach (int i in histArrayRight) {
                    columnSeriesRight.Items.Add (new ColumnItem (i, -1));
                }
                columnSeriesRight.LabelFormatString = "{0}";
                columnSeriesRight.FontSize = dFontSize;
                tempRight.Series.Add (columnSeriesRight);

                tempRight.Title = Resources.GetString (Resource.String.WithPeople);
                tempRight.TitleFontSize = dFontSize;
                MyModelRight = tempRight;

                plotViewModelRight.Model = MyModelRight;
            }
        }
コード例 #13
0
        private void CreateTradeRetsByDayAndHourChartModel()
        {
            var distinctDays = Data.tradeRetsByDayAndHour.Select(x => x.weekDay).Distinct();
            var distinctHours = Data.tradeRetsByDayAndHour.Select(x => x.hour).OrderByDescending(x => x).Distinct();

            var model = new PlotModel();
            var xAxis = new OxyPlot.Axes.CategoryAxis
            {
                Key = "dayAxis",
                Position = OxyPlot.Axes.AxisPosition.Bottom,
                ItemsSource = distinctDays.Select(x => x.ToString())
            };

            var yAxis = new OxyPlot.Axes.CategoryAxis
            {
                Key = "hourAxis",
                Position = OxyPlot.Axes.AxisPosition.Left,
                ItemsSource = distinctHours.Select(x => x.ToString())
            };

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

            model.Axes.Add(new OxyPlot.Axes.LinearColorAxis
            {
                Palette = OxyPalettes.BlueWhiteRed31
            });

            //take avg trade ret by day/hour and turn it into an array
            int dayCount = distinctDays.Count();
            int hourCount = distinctHours.Count();
            var data = new double[dayCount, hourCount];

            var weekDayTrans = distinctDays.Select((x, a) => new { x, a }).ToDictionary(x => x.x, x => x.a);
            var hourTrans = distinctHours.Select((x, a) => new { x, a }).OrderByDescending(x => x.x).ToDictionary(x => x.x, x => x.a);
            foreach (var ret in Data.tradeRetsByDayAndHour)
            {
                data[weekDayTrans[ret.weekDay], hourTrans[ret.hour]] = ret.avgRet;
            }

            var heatMapSeries = new OxyPlot.Series.HeatMapSeries
            {
                X0 = 0,
                X1 = dayCount - 1,
                Y0 = 0,
                Y1 = hourCount - 1,
                XAxisKey = "dayAxis",
                YAxisKey = "hourAxis",
                RenderMethod = HeatMapRenderMethod.Rectangles,
                LabelFontSize = 0.2, // neccessary to display the label
                LabelFormatString = "p2",
                Data = data
            };

            model.Series.Add(heatMapSeries);

            TradeRetsByDayAndHourModel = model;
        }
コード例 #14
0
        public WeatherObservationPage()
        {
            var weatherSeries = new LineSeries();

            var m = new PlotModel("Weather");

            var magnitudeAxis = new OxyPlot.Axes.LinearAxis();

            magnitudeAxis.Minimum = 0;
            magnitudeAxis.Maximum = 40;
            magnitudeAxis.Title   = "Temperature";
            m.Axes.Add(magnitudeAxis);

            var dateAxis = new OxyPlot.Axes.CategoryAxis();

            dateAxis.Labels.Add("Station");
            m.Axes.Add(dateAxis);

            weatherSeries.ItemsSource = new List <DataPoint> ();            // empty to start
            m.Series.Add(weatherSeries);

            var opv = new OxyPlotView {
                WidthRequest    = 300, HeightRequest = 300,
                BackgroundColor = Color.Aqua
            };

            opv.Model = m;

            Insights.Track("SHOWGRAPH");


            var l = new Label {
                Text              = "Hello, Oxyplot!",
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
            };
            var b = new Button {
                Text = "Get Weather Data"
            };

            b.Clicked += async(sender, e) => {
                var sv = new GeoNamesWebService();
                var we = await sv.GetWeatherObservationsAsync();

                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => {
                    Debug.WriteLine("found " + we.Length + " weather observations");
                    l.Text = we.Length + " weather observations";

                    var eqlist = new List <WeatherObservation>(we);
//					eqlist.Sort((x, y) => string.Compare(x.datetime, y.datetime));


                    var columSeries = new ColumnSeries();


                    foreach (var eq in eqlist)
                    {
                        double t = 0.0;
                        Double.TryParse(eq.temperature, out t);
                        columSeries.Items.Add(new ColumnItem(t, 0));
                        //pts.Add(new DataPoint(OxyPlot.Axes.DateTimeAxis.ToDouble(DateTime.Parse(eq.datetime)), Double.Parse(eq.temperature)));
                    }
                    opv.Model.Series.Clear();
                    opv.Model.Series.Add(columSeries);

                    Device.BeginInvokeOnMainThread(() => {
                        opv.InvalidateDisplay();
                    });
                });
            };


            Padding = new Thickness(0, 20, 0, 0);
            Content = new StackLayout {
                Children =
                {
                    opv,
                    b,
                    l
                }
            };
        }