Exemplo n.º 1
0
        private void InitializeCharts()
        {
            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));

            _distanceChartConfig = ChartService.DrawPieChart("Overall distance by type", new SortedDictionary <string, float>(activityTypesWithDistances));
            _countChartConfig    = ChartService.DrawPieChart("Activity count by type", new SortedDictionary <string, int>(activityTypesWithCount));
            _durationChartConfig = ChartService.DrawPieChart("Overall duration by type", new SortedDictionary <string, float>(activityTypesWithDuration));
        }