コード例 #1
0
ファイル: AreaChartControl.cs プロジェクト: route56/gyrfalcon
        private DateTime GetNext(DateTime curr, GroupWindowType type)
        {
            switch (type)
            {
            case GroupWindowType.Hour:
                return(curr.AddHours(1));

            case GroupWindowType.Day:
                return(curr.AddDays(1));

            case GroupWindowType.Week:
                return(curr.AddDays(7));

            default:
                throw new ArgumentException();
            }
        }
コード例 #2
0
ファイル: AreaChartControl.cs プロジェクト: route56/gyrfalcon
        private static string GetAxisString(DateTime time, GroupWindowType type)
        {
            switch (type)
            {
            case GroupWindowType.Hour:
                return(time.ToShortDateString() + " " + time.Hour);

            case GroupWindowType.Day:
                return(time.ToShortDateString());

            case GroupWindowType.Week:
                ITimeWindow window = new DayTimeWindow(time);
                window = window.ToWeekWindow();
                return(window.StartTime.ToShortDateString() + " " + window.EndTime.ToShortDateString());

            default:
                throw new ArgumentException();
            }
        }
コード例 #3
0
        private IEnumerable <GroupedDataFormat> ToGroupedDataFormat(Func <DateTime, DateTime> filter, GroupWindowType groupWindow)
        {
            var result = _list
                         .GroupBy(s => new
            {
                ATime     = filter(s.Time),
                AActivity = s.Process
            })
                         .Select(r => new
            {
                Time     = r.FirstOrDefault().Time,
                Activity = r.FirstOrDefault(),
                TimeSpan = r.Sum(s => s.Frequency),
            })
                         .GroupBy(s => filter(s.Time))
                         .Select(r =>
            {
                var sortedZip = r.Select(g => g.TimeSpan)
                                .Zip(r.Select(g => g.Activity.Process),
                                     (t, a) => new { Time = t, Activity = a })
                                .OrderByDescending(s => s.Time);

                return(new GroupedDataFormat()
                {
                    GroupBy = filter(r.FirstOrDefault().Time),
                    GroupWindow = groupWindow,
                    Activity = sortedZip.Select(s => s.Activity).ToArray(),
                    TimeSpan = sortedZip.Select(s => s.Time).ToArray()
                });
            })
                         .OrderBy(s => s.GroupBy);

            return(result);
        }