public void SetGoogleChartConfigurationForGeospatialAreaPerformanceMeasure(ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure, ProjectFirmaModels.Models.GeospatialArea geospatialArea)
        {
            // Google Chart Configuration
            if (performanceMeasure.GeospatialAreaPerformanceMeasureReportingPeriodTargets.Any() || performanceMeasure.GeospatialAreaPerformanceMeasureFixedTargets.Any())
            {
                foreach (var pfSubcategory in performanceMeasure.PerformanceMeasureSubcategories)
                {
                    var tempChartConfig = GoogleChartConfiguration.GetGoogleChartConfigurationFromJsonObject(pfSubcategory.ChartConfigurationJson);
                    tempChartConfig.SeriesType = "bars";
                    tempChartConfig.Series     =
                        performanceMeasure.HasGeospatialAreaTargets(geospatialArea) && performanceMeasure.HasTargets()
                            ? GoogleChartSeries.GetDefaultGoogleChartSeriesForChartsWithTwoTargets()
                            : GoogleChartSeries.GetDefaultGoogleChartSeriesForChartsWithTargets();

                    pfSubcategory.GeospatialAreaTargetChartConfigurationJson = JObject.FromObject(tempChartConfig).ToString();
                    pfSubcategory.GeospatialAreaTargetGoogleChartTypeID      = performanceMeasure.HasGeospatialAreaTargets(geospatialArea) ? GoogleChartType.ComboChart.GoogleChartTypeID : GoogleChartType.ColumnChart.GoogleChartTypeID;
                    if (performanceMeasure.CanBeChartedCumulatively)
                    {
                        var cumulativeChartConfigurationJson = GoogleChartConfiguration.GetGoogleChartConfigurationFromJsonObject(pfSubcategory.ChartConfigurationJson);
                        cumulativeChartConfigurationJson.SeriesType    = "bars";
                        pfSubcategory.CumulativeChartConfigurationJson = JObject.FromObject(cumulativeChartConfigurationJson).ToString();
                        pfSubcategory.CumulativeGoogleChartTypeID      = performanceMeasure.HasTargets() ? GoogleChartType.ComboChart.GoogleChartTypeID : GoogleChartType.ColumnChart.GoogleChartTypeID;
                    }
                }
            }
        }
示例#2
0
 //Use this constructor when the chart display is not user-configurable
 public GoogleChartJson(string legendTitle,
                        string chartContainerID,
                        GoogleChartConfiguration googleChartConfiguration,
                        GoogleChartType googleChartType,
                        GoogleChartDataTable googleChartDataTable,
                        List <string> chartColumns) : this(legendTitle, chartContainerID, googleChartConfiguration, googleChartType,
                                                           googleChartDataTable, chartColumns, null, null)
 {
 }
        public void SetGoogleChartConfigurationForPerformanceMeasure(
            ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure,
            PerformanceMeasureTargetValueTypeEnum performanceMeasureTargetValueTypeEnum)
        {
            var geospatialAreasWithTargets = new List <ProjectFirmaModels.Models.GeospatialArea>();

            geospatialAreasWithTargets.AddRange(performanceMeasure.GeospatialAreaPerformanceMeasureFixedTargets.Select(x => x.GeospatialArea));
            geospatialAreasWithTargets.AddRange(performanceMeasure.GeospatialAreaPerformanceMeasureReportingPeriodTargets.Select(x => x.GeospatialArea));

            //Google Chart Configuration for the Performance Measure
            foreach (var pfSubcategory in performanceMeasure.PerformanceMeasureSubcategories)
            {
                var tempChartConfig = GoogleChartConfiguration.GetGoogleChartConfigurationFromJsonObject(pfSubcategory.ChartConfigurationJson);
                tempChartConfig.SeriesType = "bars";
                if (performanceMeasure.HasTargets())
                {
                    tempChartConfig.Series          = GoogleChartSeries.GetDefaultGoogleChartSeriesForChartsWithTargets();
                    pfSubcategory.GoogleChartTypeID = GoogleChartType.ComboChart.GoogleChartTypeID;
                }
                else
                {
                    tempChartConfig.Series          = null;
                    pfSubcategory.GoogleChartTypeID = GoogleChartType.ColumnChart.GoogleChartTypeID;
                }
                pfSubcategory.ChartConfigurationJson = JObject.FromObject(tempChartConfig).ToString();
                if (performanceMeasure.CanBeChartedCumulatively)
                {
                    var cumulativeChartConfigurationJson = GoogleChartConfiguration.GetGoogleChartConfigurationFromJsonObject(pfSubcategory.ChartConfigurationJson);
                    cumulativeChartConfigurationJson.SeriesType    = "bars";
                    pfSubcategory.CumulativeChartConfigurationJson = JObject.FromObject(cumulativeChartConfigurationJson).ToString();
                    pfSubcategory.CumulativeGoogleChartTypeID      = performanceMeasure.HasTargets() ? GoogleChartType.ComboChart.GoogleChartTypeID : GoogleChartType.ColumnChart.GoogleChartTypeID;
                }

                // We need to adjust the chart JSON for the the geospatial area as well if there are geospatial area targets for this performance measure by adding an additional line series to the configuration json
                if (geospatialAreasWithTargets.Any())
                {
                    var tempGeospatialChartConfig = GoogleChartConfiguration.GetGoogleChartConfigurationFromJsonObject(pfSubcategory.ChartConfigurationJson);
                    tempGeospatialChartConfig.SeriesType = "bars";
                    tempGeospatialChartConfig.Series     = performanceMeasure.HasTargets() ? GoogleChartSeries.GetDefaultGoogleChartSeriesForChartsWithTwoTargets() : GoogleChartSeries.GetDefaultGoogleChartSeriesForChartsWithTargets();
                    pfSubcategory.GeospatialAreaTargetChartConfigurationJson = JObject.FromObject(tempGeospatialChartConfig).ToString();
                    pfSubcategory.GeospatialAreaTargetGoogleChartTypeID      = GoogleChartType.ComboChart.GoogleChartTypeID;
                }
            }
        }
示例#4
0
        //Used where chartConfiguration comes as a GoogleChartConfiguration object
        //Use this constructor when the chart is not configurable - currently only PM charts
        public GoogleChartJson(string legendTitle,
                               string chartContainerID,
                               GoogleChartConfiguration googleChartConfiguration,
                               GoogleChartType googleChartType,
                               GoogleChartDataTable googleChartDataTable,
                               List <string> chartColumns,
                               string optionalSaveConfigurationUrl,
                               string optionalResetConfigurationUrl)
        {
            LegendTitle              = legendTitle;
            ChartContainerID         = chartContainerID;
            GoogleChartConfiguration = googleChartConfiguration;
            ChartColumns             = chartColumns;

            ChartType                     = googleChartType.GoogleChartTypeDisplayName;
            GoogleChartDataTable          = googleChartDataTable;
            SaveConfigurationUrl          = optionalSaveConfigurationUrl;
            OptionalResetConfigurationUrl = optionalResetConfigurationUrl;
        }