/// <summary> /// Creates the table with the basic information. /// </summary> /// <returns>The created table.</returns> public PdfPTable CreateRallyLengthTable() { PdfPTable table = new PdfPTable(10); float[] widths = new float[] { 1.8f, 2.3f, 1.1f, 1.1f, 1.1f, 1.1f, 2.1f, 2.1f, 2.1f, 2.1f }; Rectangle rect = new Rectangle(17, 1); table.SetWidthPercentage(widths, rect); PdfPCell cell1 = GetCell(string.Empty, 1, 1, 1); cell1.MinimumHeight = 30.0f; table.AddCell(cell1); table.AddCell(GetCell("Total Rally Length", 1, 1, 2)); table.AddCell(GetCell("Serv A", 1, 1, 2)); table.AddCell(GetCell("Serv B", 1, 1, 2)); table.AddCell(GetCell("Win A", 1, 1, 2)); table.AddCell(GetCell("Win B", 1, 1, 2)); table.AddCell(GetCell("Service A\nWinner A", 1, 1, 2)); table.AddCell(GetCell("Service A\nWinner B", 1, 1, 2)); table.AddCell(GetCell("Service B\nWinner A", 1, 1, 2)); table.AddCell(GetCell("Service B\nWinner B", 1, 1, 3)); RallyLengthStatistics stats = this.report.RallyLength; PdfPCell cell2 = GetCell("Mean", 4); cell2.MinimumHeight = 20.0f; table.AddCell(cell2); table.AddCell(GetCell(Convert.ToString(0), 5)); table.AddCell(GetCell(Convert.ToString(Math.Round(stats.ServiceA.Mean, 2)), 5)); table.AddCell(GetCell(Convert.ToString(Math.Round(stats.ServiceB.Mean, 2)), 5)); table.AddCell(GetCell(Convert.ToString(Math.Round(stats.WinnerA.Mean, 2)), 5)); table.AddCell(GetCell(Convert.ToString(Math.Round(stats.WinnerB.Mean, 2)), 5)); table.AddCell(GetCell(Convert.ToString(Math.Round(stats.WinnerAWithServiceA.Mean, 2)), 5)); table.AddCell(GetCell(Convert.ToString(Math.Round(stats.WinnerBWithServiceA.Mean, 2)), 5)); table.AddCell(GetCell(Convert.ToString(Math.Round(stats.WinnerAWithServiceB.Mean, 2)), 5)); table.AddCell(GetCell(Convert.ToString(Math.Round(stats.WinnerBWithServiceB.Mean, 2)), 5)); PdfPCell cell3 = GetCell("Median", 4); cell3.MinimumHeight = 20.0f; table.AddCell(cell3); table.AddCell(GetCell(Convert.ToString(0), 5)); table.AddCell(GetCell(Convert.ToString(stats.ServiceA.Median), 5)); table.AddCell(GetCell(Convert.ToString(stats.ServiceB.Median), 5)); table.AddCell(GetCell(Convert.ToString(stats.WinnerA.Median), 5)); table.AddCell(GetCell(Convert.ToString(stats.WinnerB.Median), 5)); table.AddCell(GetCell(Convert.ToString(stats.WinnerAWithServiceA.Median), 5)); table.AddCell(GetCell(Convert.ToString(stats.WinnerBWithServiceA.Median), 5)); table.AddCell(GetCell(Convert.ToString(stats.WinnerAWithServiceB.Median), 5)); table.AddCell(GetCell(Convert.ToString(stats.WinnerBWithServiceB.Median), 5)); return(table); }
/// <summary> /// Creates the rally length statistics /// </summary> /// <returns>The created <see cref="RallyLengthStatistics"/></returns> private RallyLengthStatistics CreateRallyLengthStatistics() { RallyLengthStatistics stats = new RallyLengthStatistics(); //// stats for serving player A var servingA = this.Match.Rallies .Where(r => r.Server == MatchPlayer.First) .OrderBy(l => l.Length) .ToList(); stats.ServiceA.Mean = servingA.Select(r => r.Length).Average(); stats.ServiceA.Median = servingA[(int)Math.Ceiling(servingA.Count / 2.0)].Length; //// stats for winner A var winnersA = this.Match.Rallies .Where(r => r.Winner == MatchPlayer.First) .OrderBy(l => l.Length) .ToList(); stats.WinnerA.Mean = winnersA.Select(r => r.Length).Average(); stats.WinnerA.Median = winnersA[(int)Math.Ceiling(winnersA.Count / 2.0)].Length; //// stats for winner A when A is serving player var winnersAByServingA = winnersA .Where(r => r.Server == MatchPlayer.First) .OrderBy(l => l.Length) .ToList(); stats.WinnerAWithServiceA.Mean = winnersAByServingA.Select(r => r.Length).Average(); stats.WinnerAWithServiceA.Median = winnersAByServingA[(int)Math.Ceiling(winnersAByServingA.Count / 2.0)].Length; //// stats for winner A when B is serving player var winnersAByServingB = winnersA .Where(r => r.Server == MatchPlayer.First) .OrderBy(l => l.Length) .ToList(); stats.WinnerAWithServiceB.Mean = winnersAByServingB.Select(r => r.Length).Average(); stats.WinnerAWithServiceB.Median = winnersAByServingB[(int)Math.Ceiling(winnersAByServingB.Count / 2.0)].Length; //// stats for serving player B var servingB = this.Match.Rallies .Where(r => r.Server == MatchPlayer.Second) .OrderBy(l => l.Length) .ToList(); stats.ServiceB.Mean = servingB.Select(r => r.Length).Average(); stats.ServiceB.Median = servingB[(int)Math.Ceiling(servingB.Count / 2.0)].Length; //// stats for winner B var winnersB = this.Match.Rallies .Where(r => r.Winner == MatchPlayer.Second) .OrderBy(l => l.Length) .ToList(); stats.WinnerB.Mean = winnersB.Select(r => r.Length).Average(); stats.WinnerB.Median = winnersB[(int)Math.Ceiling(winnersB.Count / 2.0)].Length; //// stats for winner B when A is serving player var winnersBByServingA = winnersA .Where(r => r.Server == MatchPlayer.First) .OrderBy(l => l.Length) .ToList(); stats.WinnerBWithServiceA.Mean = winnersBByServingA.Select(r => r.Length).Average(); stats.WinnerBWithServiceA.Median = winnersBByServingA[(int)Math.Ceiling(winnersBByServingA.Count / 2.0)].Length; //// stats for winner B when B is serving player var winnersBByServingB = winnersA .Where(r => r.Server == MatchPlayer.First) .OrderBy(l => l.Length) .ToList(); stats.WinnerBWithServiceB.Mean = winnersBByServingB.Select(r => r.Length).Average(); stats.WinnerBWithServiceB.Median = winnersBByServingB[(int)Math.Ceiling(winnersBByServingB.Count / 2.0)].Length; return(stats); }