예제 #1
0
    /// <summary>
    /// Cleans and updates the chartStatsNumbers with the data returned from _game.GetStats
    /// </summary>
    private void ChartStatsNumbers_Update()
    {
        _game.GetStats.Sort((x, y) => x.Number.CompareTo(y.Number));

        List <(int Number, int Total, int Correct)> FullStats = new();

        FullStats.Add(_game.GetStats[0]);
        for (int i = 1; i < _game.GetStats.Count; i++)
        {
            FullStats.InsertRange(i, Enumerable.Repeat((0, 0, 0), _game.GetStats[i].Number - _game.GetStats[i - 1].Number - 1));
            FullStats.Add(_game.GetStats[i]);
        }

        var correct   = FullStats.Select(x => x.Total == 0 ? 0.0 : 100 * (double)x.Correct / x.Total).ToArray();
        var incorrect = FullStats.Select(x => x.Total == 0 ? 0.0 : (double)100).ToArray();

        // Reset plot
        StatsNumbers.Plot.Clear();
        StatsNumbers.Plot.XAxis.Label("Number");
        StatsNumbers.Plot.YAxis.Label("OK percentage");

        // Plot data
        var positions = FullStats.Select(x => (double)x.Number).ToArray();

        StatsNumbers.Plot.AddBar(incorrect, positions, Color.Red);
        StatsNumbers.Plot.AddBar(correct, positions, Color.Green);
        StatsNumbers.Plot.XAxis.ManualTickPositions(positions, positions.Select(x => $"#{x}").ToArray());
        StatsNumbers.Plot.XAxis.ManualTickSpacing(1.0);

        // Adjust axis limits so there is no padding below the bar graph
        StatsNumbers.Plot.SetAxisLimits(yMin: 0);
        StatsNumbers.Refresh();
    }
예제 #2
0
        public FullStats FullServerStats()
        {
            int handshake = Handshake();

            byte[]    fullStatsBytes = FullStats(handshake);
            FullStats fullStats      = new FullStats(fullStatsBytes);

            return(fullStats);
        }