protected void InitBuild(Grouping grouping)
 {
     if (grouping != null)
     {
         Grouping = grouping;
         IndicatorMetadata = IndicatorMetadataRepository.Instance.GetIndicatorMetadata(grouping.IndicatorId);
         Period = new DataPointOffsetCalculator(grouping, DataPointOffset, IndicatorMetadata.YearType).TimePeriod;
         Formatter = GetFormatter();
     }
 }
        public void Format(GroupRoot groupRoot, IndicatorMetadata metadata, TimePeriodFormatter timePeriodFormatter, NumericFormatter formatter)
        {
            foreach (CoreDataSet coreData in groupRoot.Data)
            {
                formatter.Format(coreData);
                formatter.FormatConfidenceIntervals(coreData);
            }

            foreach (var grouping in groupRoot.Grouping)
            {
                formatter.Format(grouping.ComparatorData);
                formatter.FormatConfidenceIntervals(grouping.ComparatorData);
                timePeriodFormatter.Format(grouping, metadata);
            }
        }
        private Dictionary<string, CoreDataSet> AddEthnicityLabelToCoreDataSet(
            IEnumerable<CoreDataSet> coreDataSets, NumericFormatter formatter)
        {
            var data = new Dictionary<string, CoreDataSet>();

            foreach (CoreDataSet coreDataSet in coreDataSets)
            {
                formatter.Format(coreDataSet);
                coreDataProcessor.Truncate(coreDataSet);
                switch (coreDataSet.CategoryId)
                {
                    case 1:
                        data.Add("White", coreDataSet);
                        break;
                    case 2:
                        data.Add("Mixed", coreDataSet);
                        break;
                    case 3:
                        data.Add("Asian", coreDataSet);
                        break;
                    case 4:
                        data.Add("Black", coreDataSet);
                        break;
                    case 5:
                        data.Add("Chinese", coreDataSet);
                        break;
                    case 6:
                        data.Add("Other", coreDataSet);
                        break;
                    case 7:
                        data.Add("Unknown", coreDataSet);
                        break;
                }
            }
            return data;
        }
 private void WhenNumericFormatterIsCreated()
 {
     formatter = NumericFormatterFactory.New(metadata, ReaderFactory.GetGroupDataReader());
 }
        private List<string> GetFormattedComparatorValues(IList<TimePeriod> timePeriods, IndicatorMetadata indicatorMetadata,
            Grouping grouping, NumericFormatter formatter, int comparatorId)
        {
            List<string> values = new List<string>();

            var dataProvider = comparatorId == ComparatorIds.England ?
                nationalCoreDataSetProvider :
                parentCoreDataSetProvider;

            foreach (TimePeriod timePeriod in timePeriods)
            {
                var data = dataProvider.GetData(grouping, timePeriod, indicatorMetadata);
                formatter.Format(data);
                var valF = data != null
                    ? data.ValueFormatted
                    : null;
                values.Add(valF);
            }

            return values;
        }