예제 #1
0
        private void GeneratePlot()
        {
            var matchesInDateRange = MatchHistory.Where(m => Between(m, Settings.StartDate, Settings.EndDate));

            var lineSeries = new LineSeries
            {
                Title  = "SR",
                Values = new ChartValues <LiveCharts.Defaults.ObservableValue>(
                    from r in matchesInDateRange
                    select new LiveCharts.Defaults.ObservableValue(r.CR)
                    ),
                LineSmoothness = 0,
                PointGeometry  = DefaultGeometries.Circle,
                Fill           = System.Windows.Media.Brushes.Transparent,
                DataLabels     = false
            };

            Brush weekendBrush = Brushes.DodgerBlue;

            lineSeries.Configuration = LiveCharts.Configurations.Mappers.Xy <LiveCharts.Defaults.ObservableValue>()
                                       .X((item, index) => index)
                                       .Y(item => item.Value)
                                       .Fill(ShouldBeWeekendColoured(weekendBrush))
                                       .Stroke(ShouldBeWeekendColoured(weekendBrush));

            var xLabels =
                from r in matchesInDateRange
                select r.Date.ToString("G");


            Func <double, string> yFormatter = (i) => i.ToString();
            Func <double, string> xFormatter = (i) => i.ToString("C");

            if (DataSeries != null)
            {
                DataSeries.Clear();
            }
            else
            {
                DataSeries = new SeriesCollection();
            }
            DataSeries.Add(lineSeries);
            Labels          = xLabels.ToArray();
            YFormatter      = yFormatter;
            XFormatter      = xFormatter;
            YAxisStartValue = matchesInDateRange.FirstOrDefault()?.CR ?? 0;
        }
예제 #2
0
        private void GenerateStatistics()
        {
            string[] maps = Maps.All.Where(m => m != "N/A").ToArray();

            TotalPlayed   = MatchHistory.Count();
            TotalWon      = MatchHistory.Wins();
            TotalDrawn    = MatchHistory.Draws();
            TotalLost     = MatchHistory.Losses();
            TotalWithMaps = MatchHistory.Count(r => r.Map != "N/A");
            Stats         = new ObservableCollection <MapStatistics>(
                from map in maps
                let matches = MatchHistory.Where(match => match.Map == map)
                              orderby matches.Wins() descending, matches.Count() descending
                select new MapStatistics()
            {
                Map         = map,
                TotalPlayed = matches.Count(),
                TotalWon    = matches.Wins(),
                TotalDrawn  = matches.Draws(),
                TotalLost   = matches.Losses()
            }
                );
        }