public Stats() { Files = new StatsFiles(); Matches = new StatsMatches(); Time = new StatsTime(); }
/// <summary> /// Cleans and updates the chartStatsNumbers with the data returned from _game.GetStats /// </summary> private void ChartStatsTime_Update() { var data = new List <List <double> >(_game.GetStatsTime); // Get the number of rows int numAttempts = data.Count; // Get the maximum number of columns int numSeries = data.Aggregate(0, (max, next) => next.Count > max ? next.Count : max); // Pad with 0 so that each row has the same number of elements data.ForEach(x => x.AddRange(Enumerable.Repeat(0.0, numSeries - x.Count))); // Add the partial incremental sum var times = new List <List <double> >(); foreach (var row in data) { times.Add(new List <double>()); row.ForEach(i => times.Last().Add(i + times.Last().LastOrDefault())); } // Traspose to get the data ready to plot var plotData = times .SelectMany(inner => inner.Select((item, index) => new { item, index })) .GroupBy(i => i.index, i => i.item) .Select(g => g.ToList()) .ToList(); // Reset plot StatsTime.Plot.Clear(); StatsTime.Plot.XAxis.Label("Sequence"); StatsTime.Plot.YAxis.Label("Time in seconds"); // Plot data var positions = Enumerable.Range(1, data.Count).Select(x => (double)x).ToArray(); plotData.Reverse(); foreach (var row in plotData) { StatsTime.Plot.AddBar(row.ToArray(), positions); } StatsTime.Plot.XAxis.ManualTickPositions(positions, positions.Select(x => $"{x}").ToArray()); StatsTime.Plot.XAxis.ManualTickSpacing(1); StatsTime.Refresh(); }