Ejemplo n.º 1
0
        protected async override Task OnInitializedAsync()
        {
            await EnsureAuthenticatedAsync();

            Console.WriteLine($"{DateTime.Now} Initialized Activities");

            UserActivities = (await StravaService.GetAllActivities(StartDate, EndDate)).ToList();
            CalculateStatistics();
            InitializeCharts();
        }
Ejemplo n.º 2
0
        public void OnDateRangeSelect(DateRange dateRange)
        {
            Task.Run(async() => {
                UserActivities = (await StravaService.GetAllActivities(StartDate, EndDate)).ToList();

                CalculateStatistics();

                var activityGroupsByType = UserActivities.GroupBy(a => a.Type);
                Dictionary <string, int> activityTypesWithCount       = activityGroupsByType.ToDictionary(group => group.Key.ToString(), group => group.Count());
                Dictionary <string, float> activityTypesWithDistances = activityGroupsByType.ToDictionary(group => group.Key.ToString(), group => group.Sum(a => a.Distance));
                Dictionary <string, float> activityTypesWithDuration  = activityGroupsByType.ToDictionary(group => group.Key.ToString(), group => group.Sum(a => a.MovingTime));

                ChartService.UpdatePieChartData(_countChart, _countChartConfig, new SortedDictionary <string, int>(activityTypesWithCount));
                ChartService.UpdatePieChartData(_distanceChart, _distanceChartConfig, new SortedDictionary <string, float>(activityTypesWithDistances));
                ChartService.UpdatePieChartData(_durationChart, _durationChartConfig, new SortedDictionary <string, float>(activityTypesWithDuration));

                StateHasChanged();
            });
        }