Example #1
0
        public static List <ChartData <int> > GetChartData(this PromoChartData data)
        {
            List <ChartData <int> > result = new List <ChartData <int> > {
            };

            for (int i = 0; i < data.Data.Count; i++)
            {
                result.Add(new ChartData <int> {
                    Category = data.Labels[i], Value = (int)data.Data[i]
                });
            }

            return(result);
        }
Example #2
0
        public static PromoChartData GetPerDateMetrics(this IEnumerable <PromoData> @this)
        {
            var result = new PromoChartData {
                DisplayLabel = "Entries Per Date"
            };

            if (@this != null)
            {
                var x = @this.GroupBy(p => p.Date);

                foreach (var group in x)
                {
                    result.Labels.Add(group.Key.ToShortDateString());
                    result.Data.Add(group.Sum(p => p.NumberOfEntries));
                }
            }

            return(result);
        }