public static string GetTargetValueLabel(this PerformanceMeasureReportingPeriod performanceMeasureReportingPeriod, PerformanceMeasure performanceMeasure)
        {
            var fixedTarget = performanceMeasure.PerformanceMeasureFixedTargets.FirstOrDefault();

            if (fixedTarget != null)
            {
                return(fixedTarget.PerformanceMeasureTargetValueLabel);
            }
            return(performanceMeasure.PerformanceMeasureReportingPeriodTargets.SingleOrDefault(x => x.PerformanceMeasureReportingPeriodID == performanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodID)?.PerformanceMeasureTargetValueLabel);
        }
        public static string GetGeospatialAreaTargetValueLabel(this PerformanceMeasureReportingPeriod performanceMeasureReportingPeriod, PerformanceMeasure performanceMeasure, GeospatialArea geospatialArea)
        {
            var fixedTarget = performanceMeasure.GeospatialAreaPerformanceMeasureFixedTargets.FirstOrDefault(x =>
                                                                                                             x.GeospatialAreaID == geospatialArea.GeospatialAreaID);

            if (fixedTarget != null)
            {
                return(fixedTarget.GeospatialAreaPerformanceMeasureTargetValueLabel);
            }
            return(performanceMeasure.GeospatialAreaPerformanceMeasureReportingPeriodTargets.SingleOrDefault(x => x.PerformanceMeasureReportingPeriodID == performanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodID && x.GeospatialAreaID == geospatialArea.GeospatialAreaID)?.GeospatialAreaPerformanceMeasureTargetValueLabel);
        }
 private PerformanceMeasureReportingPeriodSubcategoryOptionReportedValue(int calendarYear, double?reportedValue, int sortOrder, int performanceMeasureSubcategoryOptionID, PerformanceMeasureSubcategory performanceMeasureSubcategory, string performanceMeasureSubcategoryOptionName, string chartName)
 {
     PerformanceMeasureReportingPeriod =
         new PerformanceMeasureReportingPeriod(performanceMeasureSubcategory.PerformanceMeasure, new DateTime(calendarYear, 1, 1), calendarYear.ToString())
     {
         PerformanceMeasureReportingPeriodID = calendarYear
     };
     ReportedValue = reportedValue;
     SortOrder     = sortOrder;
     PerformanceMeasureSubcategoryOptionID   = performanceMeasureSubcategoryOptionID;
     PerformanceMeasureSubcategory           = performanceMeasureSubcategory;
     PerformanceMeasureSubcategoryOptionName = performanceMeasureSubcategoryOptionName;
     ChartName = chartName;
 }
Esempio n. 4
0
        public static string FormattedDataTooltip(IReadOnlyCollection <IGrouping <Tuple <string, int>, PerformanceMeasureReportingPeriodSubcategoryOptionReportedValue> > groupedBySubcategoryOption,
                                                  PerformanceMeasureReportingPeriod performanceMeasureReportingPeriod,
                                                  MeasurementUnitType performanceMeasureMeasurementUnitType,
                                                  bool reverseTooltipOrder,
                                                  double?targetValue,
                                                  string targetValueDescription,
                                                  double?geospatialAreaTargetValue,
                                                  string geospatialAreaTargetValueDescription,
                                                  bool showCumulativeResults,
                                                  PerformanceMeasureReportingPeriod initialPerformanceMeasureReportingPeriod)
        {
            // shape data
            var calendarReportedYearValuesDictionary = new Dictionary <string, double>();
            var orderedSubCategoryOptions            = reverseTooltipOrder
                ? groupedBySubcategoryOption.OrderByDescending(x => x.Key.Item2)
                : groupedBySubcategoryOption.OrderBy(x => x.Key.Item2);

            orderedSubCategoryOptions.ForEach(x =>
            {
                double calendarYearReportedValue;
                if (showCumulativeResults)
                {
                    calendarYearReportedValue =
                        x.Where <PerformanceMeasureReportingPeriodSubcategoryOptionReportedValue>(pmrp => pmrp.PerformanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodCalendarYear <=
                                                                                                  performanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodCalendarYear)
                        .Sum(pmrp => pmrp.ReportedValue) ?? 0;
                }
                else
                {
                    calendarYearReportedValue =
                        x.Where <PerformanceMeasureReportingPeriodSubcategoryOptionReportedValue>(pmrp => pmrp.PerformanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodCalendarYear ==
                                                                                                  performanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodCalendarYear)
                        .Sum(pmrp => pmrp.ReportedValue) ?? 0;
                }
                calendarReportedYearValuesDictionary.Add(x.Key.Item1, calendarYearReportedValue);
            });

            var stringPrecision = new String('0', performanceMeasureMeasurementUnitType.NumberOfSignificantDigits);
            var prefix          = performanceMeasureMeasurementUnitType == MeasurementUnitType.Dollars ? "$" : null;

            // build html for tooltip
            var html = "<div class='googleTooltipDiv'>";

            html += $"<p><b>{performanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodLabel}</b></p>";
            html += "<table class='table table-striped googleTooltipTable'>";
            foreach (KeyValuePair <string, double> calendarReportedYearValue in calendarReportedYearValuesDictionary)
            {
                var formattedValue = calendarReportedYearValue.Value.ToString($"#,###,###,##0.{stringPrecision}");


                html += $"<tr><td>{calendarReportedYearValue.Key}</td><td style='text-align: right'><b>{prefix ?? String.Empty}{formattedValue} {performanceMeasureMeasurementUnitType.LegendDisplayName ?? String.Empty}</b></td></tr>";
            }

            var formattedTotal = calendarReportedYearValuesDictionary.Sum(x => x.Value).ToString($"#,###,###,##0.{stringPrecision}");

            html += $"<tr class='googleTooltipTableTotalRow'><td>Total</td><td style='text-align: right'><b>{prefix ?? String.Empty}{formattedTotal} {performanceMeasureMeasurementUnitType.LegendDisplayName ?? String.Empty}</b></td></tr>";
            if (targetValue.HasValue && !string.IsNullOrWhiteSpace(targetValueDescription))
            {
                var formattedTarget = targetValue.Value.ToString($"#,###,###,##0.{stringPrecision}");
                html += $"<tr class='googleTooltipTableTotalRow'><td>{targetValueDescription}</td><td style='text-align: right'><b>{prefix ?? String.Empty}{formattedTarget} {performanceMeasureMeasurementUnitType.LegendDisplayName ?? String.Empty}</b></td></tr>";
            }
            if (geospatialAreaTargetValue.HasValue && !string.IsNullOrWhiteSpace(geospatialAreaTargetValueDescription))
            {
                var formattedTarget = geospatialAreaTargetValue.Value.ToString($"#,###,###,##0.{stringPrecision}");
                html += $"<tr class='googleTooltipTableTotalRow'><td>{geospatialAreaTargetValueDescription}</td><td style='text-align: right'><b>{prefix ?? String.Empty}{formattedTarget} {performanceMeasureMeasurementUnitType.LegendDisplayName ?? String.Empty}</b></td></tr>";
            }
            html += "</table></div>";

            return(html);
        }
Esempio n. 5
0
 private static string GetFormattedGeospatialAreaTargetValue(PerformanceMeasureReportingPeriod performanceMeasureReportingPeriod, PerformanceMeasure performanceMeasure, GeospatialArea geospatialArea)
 {
     return($"{GoogleChartJson.GetFormattedValue(performanceMeasureReportingPeriod.GetGeospatialAreaTargetValue(performanceMeasure, geospatialArea), performanceMeasure.MeasurementUnitType)} ({performanceMeasureReportingPeriod.GetGeospatialAreaTargetValueLabel(performanceMeasure, geospatialArea)})");
 }
        public static string FormattedDataTooltip(IReadOnlyCollection <IGrouping <Tuple <string, int>, PerformanceMeasureReportingPeriodSubcategoryOptionReportedValue> > groupedBySubcategoryOption, PerformanceMeasureReportingPeriod performanceMeasureReportingPeriod, MeasurementUnitType performanceMeasureMeasurementUnitType)
        {
            // shape data
            var calendarReportedYearValuesDictionary = new Dictionary <string, double>();

            groupedBySubcategoryOption.OrderBy(x => x.Key.Item2).ForEach(x =>
            {
                var calendarYearReportedValue = x.Where(isorv => isorv.PerformanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodLabel == performanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodLabel)
                                                .Sum(isorv => isorv.ReportedValue) ?? 0;
                calendarReportedYearValuesDictionary.Add(x.Key.Item1, calendarYearReportedValue);
            });
            var stringPrecision = new String('0', performanceMeasureMeasurementUnitType.NumberOfSignificantDigits);
            var prefix          = performanceMeasureMeasurementUnitType == MeasurementUnitType.Dollars ? "$" : null;

            // build html for tooltip
            var html = "<div class='googleTooltipDiv'>";

            html += $"<p><b>{performanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodLabel}</b></p>";
            html += "<table class='table table-striped googleTooltipTable'>";
            foreach (KeyValuePair <string, double> calendarReportedYearValue in calendarReportedYearValuesDictionary)
            {
                var formattedValue = calendarReportedYearValue.Value.ToString($"#,###,###,##0.{stringPrecision}");


                html += $"<tr><td>{calendarReportedYearValue.Key}</td><td style='text-align: right'><b>{prefix ?? String.Empty}{formattedValue} {performanceMeasureMeasurementUnitType.LegendDisplayName ?? String.Empty}</b></td></tr>";
            }

            var formattedTotal = calendarReportedYearValuesDictionary.Sum(x => x.Value).ToString($"#,###,###,##0.{stringPrecision}");

            html += $"<tr class='googleTooltipTableTotalRow'><td>Total</td><td style='text-align: right'><b>{prefix ?? String.Empty}{formattedTotal} {performanceMeasureMeasurementUnitType.LegendDisplayName ?? String.Empty}</b></td></tr>";
            html += "</table></div>";

            return(html);
        }
 private static string GetFormattedTargetValue(PerformanceMeasureReportingPeriod performanceMeasureReportingPeriod, PerformanceMeasure performanceMeasure)
 {
     return($"{GoogleChartJson.GetFormattedValue(performanceMeasureReportingPeriod.TargetValue, performanceMeasure.MeasurementUnitType)} ({performanceMeasureReportingPeriod.TargetValueDescription})");
 }