public IDictionary <int, IDictionary <string, decimal> > AvgTotalValueByEconomicActivityByYear()
        {
            var totalValues = SumByEconomicActivityByYear();
            var noProjects  = CountByEconomicActivityByYear();
            var map         = PrepareDictionary <int, string, decimal>(totalValues.Keys, totalValues.First().Value.Keys);

            foreach (var year in totalValues.Keys)
            {
                foreach (var projectLocation in totalValues[year].Keys)
                {
                    map[year][projectLocation] = noProjects[year][projectLocation] == 0
                        ? 0m
                        : decimal.Round(totalValues[year][projectLocation] / noProjects[year][projectLocation], 2);
                }
            }

            var chartBuilder = new ColumnChartBuilder <string, decimal>()
                               .Title("Average project's total value for each area of economic activity by year")
                               .AxesTitles("Years", "Average project's total value (PLN)")
                               .Height(400)
                               .Width(2000)
                               .WithLegend("Years");

            foreach (var yearSeries in map.OrderBy(entry => entry.Key))
            {
                chartBuilder.AddSeries(yearSeries.Key.ToString(), yearSeries.Value);
            }

            var chart = chartBuilder.Build();

            chart.SaveImage(Path.Combine(ChartsFolder, "avgByAoeaByYear.png"), ChartImageFormat.Png);

            return(map);
        }
        public IDictionary <int, IDictionary <string, int> > CountByEconomicActivityByYear()
        {
            var map = PrepareDictionary <int, string, int>(_distinctYears, _distinctAreasOfEconomicActivities);

            foreach (var project in _projects)
            {
                var year = project.ProjectStartDate.Year;
                var aoea = project.AreaOfEconomicActivity.Name;

                ++map[year][aoea];
            }

            var chartBuilder = new ColumnChartBuilder <string, int>()
                               .Title("Number of projects each area of economic activity by year")
                               .AxesTitles("Years", "Number of projects")
                               .Height(400)
                               .Width(2000)
                               .WithLegend("Years");

            foreach (var yearSeries in map.OrderBy(entry => entry.Key))
            {
                chartBuilder.AddSeries(yearSeries.Key.ToString(), yearSeries.Value);
            }

            var chart = chartBuilder.Build();

            chart.SaveImage(Path.Combine(ChartsFolder, "countByAoeaByYear.png"), ChartImageFormat.Png);

            return(map);
        }
        public IDictionary <int, IDictionary <string, decimal> > AverageTotalProjectValueForEachLocation()
        {
            var totalValues = SumOfTotalProjectValuesForEachLocation();
            var noProjects  = NumberOfProjectsForEachLocation();
            var map         = PrepareDictionary <int, string, decimal>(totalValues.Keys, totalValues.First().Value.Keys);

            foreach (var year in totalValues.Keys)
            {
                foreach (var projectLocation in totalValues[year].Keys)
                {
                    map[year][projectLocation] = noProjects[year][projectLocation] == 0
                        ? 0m
                        : decimal.Round(totalValues[year][projectLocation] / noProjects[year][projectLocation], 2);
                }
            }

            var chartBuilder = new ColumnChartBuilder <string, decimal>()
                               .Title("Average project's total value for each location by years")
                               .AxesTitles("Voivodeships", "Average project's total value (PLN)")
                               .Height(400)
                               .Width(1000)
                               .WithLegend("Years");

            foreach (var yearSeries in map.OrderBy(entry => entry.Key))
            {
                chartBuilder.AddSeries(yearSeries.Key.ToString(), yearSeries.Value);
            }

            var chart = chartBuilder.Build();

            chart.SaveImage(Path.Combine(ChartsFolder, "avgValueByYearByRegion.png"), ChartImageFormat.Png);

            return(map);
        }
        public IDictionary <int, IDictionary <string, double> > AverageProjectLengthByYearByRegion()
        {
            var counts   = PrepareDictionary <int, string, int>(_distinctYears, _distinctLocations);
            var averages = PrepareDictionary <int, string, double>(_distinctYears, _distinctLocations);

            foreach (var project in _projects)
            {
                var length           = project.GetProjectLength().TotalDays;
                var year             = project.ProjectStartDate.Year;
                var projectLocations = project.ProjectLocations.Select(pl => pl.Name).ToList();

                if (projectLocations.Count == 1 && projectLocations.First() == ProjectLocation.WholeCountry.Name)
                {
                    foreach (var projectLocation in averages[year].Keys.Where(ProjectLocation.IsInPoland).ToList())
                    {
                        averages[year][projectLocation] = (averages[year][projectLocation] * counts[year][projectLocation] + length) / (counts[year][projectLocation] + 1);
                        ++counts[year][projectLocation];
                    }
                }
                else
                {
                    foreach (var projectLocation in projectLocations)
                    {
                        averages[year][projectLocation] = (averages[year][projectLocation] * counts[year][projectLocation] + length) / (counts[year][projectLocation] + 1);
                        ++counts[year][projectLocation];
                    }
                }
            }

            var chartBuilder = new ColumnChartBuilder <string, double>()
                               .Title("Average project's length in days for each location by year")
                               .AxesTitles("Years", "Average project's length (days)")
                               .Height(400)
                               .Width(1000)
                               .WithLegend("Years");

            foreach (var yearSeries in averages.OrderBy(entry => entry.Key))
            {
                chartBuilder.AddSeries(yearSeries.Key.ToString(), yearSeries.Value);
            }

            var chart = chartBuilder.Build();

            chart.SaveImage(Path.Combine(ChartsFolder, "agvLengthByYearByLocation.png"), ChartImageFormat.Png);

            return(averages);
        }
        public IDictionary <int, IDictionary <string, decimal> > SumOfTotalProjectValuesForEachLocation()
        {
            var distinctYears            = GetDistinctYears();
            var distinctProjectLocations = GetDistinctProjectLocations();
            var map = PrepareDictionary <int, string, decimal>(distinctYears, distinctProjectLocations);

            foreach (var project in _projects)
            {
                var projectValue     = project.TotalProjectValue;
                var year             = project.ProjectStartDate.Year;
                var projectLocations = project.ProjectLocations.Select(pl => pl.Name).ToList();

                if (projectLocations.Count == 1 && projectLocations.First() == ProjectLocation.WholeCountry.Name)
                {
                    foreach (var projectLocation in map[year].Keys.Where(ProjectLocation.IsInPoland).ToList())
                    {
                        map[year][projectLocation] += projectValue;
                    }
                }
                else
                {
                    foreach (var projectLocation in projectLocations)
                    {
                        map[year][projectLocation] += projectValue;
                    }
                }
            }

            var chartBuilder = new ColumnChartBuilder <string, decimal>()
                               .Title("Sum of projects total values for each location by years")
                               .AxesTitles("Voivodeships", "Sum of projects total values (PLN)")
                               .Height(400)
                               .Width(1000)
                               .WithLegend("Years");

            foreach (var yearSeries in map.OrderBy(entry => entry.Key))
            {
                chartBuilder.AddSeries(yearSeries.Key.ToString(), yearSeries.Value);
            }

            var chart = chartBuilder.Build();

            chart.SaveImage(Path.Combine(ChartsFolder, "sumByYearByRegion.png"), ChartImageFormat.Png);

            return(map);
        }