public static List <GoogleChartSeries> CalculateChartSeriesFromCurrentChartSeries(object currentChartSeries, ProjectFirmaModels.Models.PerformanceMeasure performanceMeasure, ProjectFirmaModels.Models.GeospatialArea geospatialArea) { // this was needed to ensure that the graphs on the geospatial detail page display appropriately for performance measure targets. // It attempts to be as friendly as we can to the current chart series that the user/tenant might have set // this is also here to catch situations where there are PM targets and Geospatial targets exists(specifically for cumulative charts on geospatial pages) if (currentChartSeries == null || (performanceMeasure.HasTargets() && performanceMeasure.HasGeospatialAreaTargets(geospatialArea))) { var chartSeries = new List <GoogleChartSeries>(); //add series for the PM targets if (performanceMeasure.HasTargets()) { chartSeries.Add(new GoogleChartSeries(GoogleChartType.LineChart, GoogleChartAxisType.Primary)); } //add another series for the Geospatial targets if (performanceMeasure.HasGeospatialAreaTargets(geospatialArea)) { chartSeries.Add(new GoogleChartSeries(GoogleChartType.LineChart, GoogleChartAxisType.Primary)); } //add final series to have rest of the data default to bar(column) chartSeries.Add(new GoogleChartSeries(GoogleChartType.ColumnChart, GoogleChartAxisType.Primary)); return(chartSeries); } var isListOfGoogleChartSeries = currentChartSeries is List <GoogleChartSeries>; var deserializedChartSeries = !isListOfGoogleChartSeries?JsonConvert.DeserializeObject <List <GoogleChartSeries> >(currentChartSeries.ToString()) : (List <GoogleChartSeries>)currentChartSeries; return(deserializedChartSeries); }
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; } } } }