//TODO: The GetFullCategoryYearDictionary and GetGoogleChartDataTable functions are probably fine in this Extension class, but the ToGoogleChart functions are more about display and probably could be in a better location
        public static GoogleChartJson ToGoogleChart(this IEnumerable <ProjectFundingSourceExpenditure> projectFundingSourceExpenditures,
                                                    Func <ProjectFundingSourceExpenditure, string> filterFunction,
                                                    List <string> filterValues,
                                                    Func <ProjectFundingSourceExpenditure, IComparable> sortFunction,
                                                    List <int> rangeOfYears,
                                                    string chartContainerID,
                                                    string chartTitle,
                                                    GoogleChartType googleChartType,
                                                    bool isStacked,
                                                    Dictionary <string, string> seriesColorDictionary)
        {
            var fullCategoryYearDictionary = GetFullCategoryYearDictionary(projectFundingSourceExpenditures, filterFunction, filterValues, sortFunction, rangeOfYears);
            var googleChartDataTable       = GetGoogleChartDataTable(fullCategoryYearDictionary, rangeOfYears, googleChartType, seriesColorDictionary);
            var googleChartAxis            = new GoogleChartAxis("Annual Expenditures", MeasurementUnitTypeEnum.Dollars, GoogleChartAxisLabelFormat.Short);
            var googleChartConfiguration   = new GoogleChartConfiguration(chartTitle,
                                                                          isStacked,
                                                                          googleChartType,
                                                                          googleChartDataTable,
                                                                          new GoogleChartAxis(FieldDefinitionEnum.ReportingYear.ToType().GetFieldDefinitionLabel(), null, null),
                                                                          new List <GoogleChartAxis> {
                googleChartAxis
            });

            googleChartConfiguration.SetSeriesIgnoringNullGoogleChartSeries(googleChartDataTable);
            var googleChart = new GoogleChartJson(chartTitle, chartContainerID, googleChartConfiguration,
                                                  googleChartType, googleChartDataTable, null);

            return(googleChart);
        }
Beispiel #2
0
        public ViewResult FundingStatus()
        {
            var firmaPage       = FirmaPageTypeEnum.FundingStatusHeader.GetFirmaPage();
            var firmaPageFooter = FirmaPageTypeEnum.FundingStatusFooter.GetFirmaPage();

            // set up Funding Summary pie chart
            var summaryChartTitle       = "NTA Funding Summary";
            var summaryChartContainerID = summaryChartTitle.Replace(" ", "");
            var googlePieChartSlices    = ProjectModelExtensions.GetFundingStatusPieChartSlices();
            var googleChartDataTable    = ProjectModelExtensions.GetFundingStatusSummaryGoogleChartDataTable(googlePieChartSlices);
            var summaryConfiguration    = new GooglePieChartConfiguration(summaryChartTitle, MeasurementUnitTypeEnum.Dollars, googlePieChartSlices, GoogleChartType.PieChart, googleChartDataTable)
            {
                PieSliceText = "value-and-percentage"
            };

            summaryConfiguration.ChartArea.Top = 60;
            var summaryGoogleChart = new GoogleChartJson(summaryChartTitle, summaryChartContainerID, summaryConfiguration,
                                                         GoogleChartType.PieChart, googleChartDataTable, null);

            summaryGoogleChart.CanConfigureChart = false;

            // set up Funding by Owner Org Type column chart
            var statusByOrgTypeChartTitle = "NTA Funding Status by NTA Owner Organization Type";
            var orgTypeChartContainerID   = statusByOrgTypeChartTitle.Replace(" ", "");
            var googleChartAxisHorizontal = new GoogleChartAxis("NTA Organization Type", null, null)
            {
                Gridlines = new GoogleChartGridlinesOptions(-1, "transparent")
            };
            var googleChartAxis          = new GoogleChartAxis("Total Budget", MeasurementUnitTypeEnum.Dollars, GoogleChartAxisLabelFormat.Decimal);
            var googleChartAxisVerticals = new List <GoogleChartAxis> {
                googleChartAxis
            };
            var orgTypeToAmounts            = ProjectModelExtensions.GetFundingForAllProjectsByOwnerOrgType(CurrentFirmaSession);
            var orgTypeGoogleChartDataTable = ProjectModelExtensions.GetFundingStatusByOwnerOrgTypeGoogleChartDataTable(orgTypeToAmounts);
            var orgTypeChartConfig          = new GoogleChartConfiguration(statusByOrgTypeChartTitle, true, GoogleChartType.ColumnChart, orgTypeGoogleChartDataTable, googleChartAxisHorizontal, googleChartAxisVerticals);

            // need to ignore null GoogleChartSeries so the custom colors match up to the column chart correctly
            orgTypeChartConfig.SetSeriesIgnoringNullGoogleChartSeries(orgTypeGoogleChartDataTable);
            orgTypeChartConfig.Tooltip = new GoogleChartTooltip(true);
            orgTypeChartConfig.Legend.SetLegendPosition(GoogleChartLegendPosition.None);
            var orgTypeGoogleChart = new GoogleChartJson(statusByOrgTypeChartTitle, orgTypeChartContainerID, orgTypeChartConfig, GoogleChartType.ColumnChart, orgTypeGoogleChartDataTable, orgTypeToAmounts.Keys.Select(x => x.OrganizationTypeName).ToList());

            orgTypeGoogleChart.CanConfigureChart = false;

            var viewData = new FundingStatusViewData(CurrentFirmaSession, firmaPage, firmaPageFooter, summaryGoogleChart, orgTypeGoogleChart);

            return(RazorView <FundingStatus, FundingStatusViewData>(viewData));
        }