public static DateRange GetDateRange(FilteringPeriod period)
        {
            DateRange temp;

            switch (period)
            {
            case FilteringPeriod.Day:
                temp    = DateRange.DayFromNow;
                temp.To = temp.To.AddHours(1);
                return(temp);

            case FilteringPeriod.Week:
                temp    = DateRange.WeekFromNow;
                temp.To = temp.To.AddDays(1);
                return(temp);

            case FilteringPeriod.Month:
                temp    = DateRange.MonthFromNow;
                temp.To = temp.To.AddDays(1);
                return(temp);

            case FilteringPeriod.Year:
                temp    = DateRange.YearFromNow;
                temp.To = temp.To.AddMonths(1);
                return(temp);
            }

            throw new PalantirException("Unexpected period value");
        }
        public IEnumerable <TrendChartData> GetCharts(int projectId, DateRange dateRange)
        {
            bool            isOneDayRange   = dateRange.DaysInRange <= 1;
            Periodicity     periodicity     = isOneDayRange ? Periodicity.ByHour : Periodicity.ByDay;
            FilteringPeriod filteringPeriod = isOneDayRange ? FilteringPeriod.Day : FilteringPeriod.Month;

            IList <TrendChartData> data;
            DateRange timeLimit = this.GetLimit(projectId);

            if (this.SetLimit(dateRange, timeLimit))
            {
                data = this.GetPoints(projectId, dateRange, periodicity).Select(x => new TrendChartData(x, filteringPeriod)).ToList();

                for (int i = 0; i < data.Count; i++)
                {
                    data[i].Limited      = true;
                    data[i].MaxTimeLimit = timeLimit.To.ToString();
                    data[i].MinTimeLimit = timeLimit.From.ToString();
                }
            }
            else
            {
                data = this.GetPoints(projectId, dateRange, periodicity).Select(x => new TrendChartData(x, filteringPeriod)).ToList();
            }
            return(data);
        }
        public IEnumerable <TrendChartData> GetCharts(int projectId, FilteringPeriod period)
        {
            DateRange dateRange = DateRangeConverter.GetDateRange(period);

            dateRange.IsSpecified = false;
            Periodicity            periodicity = this.GetPeriodicity(period);
            IList <TrendChartData> data;
            DateRange timeLimit = this.GetLimit(projectId);

            if (this.SetLimit(dateRange, timeLimit) || (timeLimit != null))
            {
                data = this.GetPoints(projectId, dateRange, periodicity).Select(x => new TrendChartData(x, period)).ToList();

                for (int i = 0; i < data.Count; i++)
                {
                    data[i].Limited      = true;
                    data[i].MaxTimeLimit = timeLimit.To.ToString();
                    data[i].MinTimeLimit = timeLimit.From.ToString();
                }
            }
            else
            {
                data = this.GetPoints(projectId, dateRange, periodicity).Select(x => new TrendChartData(x, period)).ToList();
            }

            return(data);
        }
        public TrendChartData GetChart(int projectId, FilteringPeriod period)
        {
            DateRange   dateRange            = DateRangeConverter.GetDateRange(period);
            Periodicity periodicity          = this.GetPeriodicity(period);
            IEnumerable <PointInTime> points = this.GetPoints(projectId, dateRange, periodicity);

            return(new TrendChartData(points, period));
        }
        protected Periodicity GetPeriodicity(FilteringPeriod period)
        {
            switch (period)
            {
            case FilteringPeriod.Day:
                return(Periodicity.ByHour);

            case FilteringPeriod.Week:
            case FilteringPeriod.Month:
                return(Periodicity.ByDay);

            case FilteringPeriod.Year:
                return(Periodicity.ByMonth);
            }

            throw new ArgumentException("Unexpected ChartPeriod value", "period");
        }
Exemple #6
0
        public TrendChartData(IEnumerable <PointInTime> points, FilteringPeriod period)
        {
            string pattern = "{0:dd MMM yyyy}";

            switch (period)
            {
            case FilteringPeriod.Day:
                // час:минуты
                pattern = "{0:HH}:{0:mm}";
                break;

            case FilteringPeriod.Month:
                // день мес¤ц
                pattern = "{0:dd} {0:MMM}";
                break;

            case FilteringPeriod.Week:
                // день мес¤ц (день недели)
                pattern = "{0:dd} {0:MMM} ({0:ddd})";
                break;

            case FilteringPeriod.Year:
                // мес¤ц год
                pattern = "{0:MMM} {0:yyyy}";
                break;
            }

            var dateTimeHelper = Factory.GetInstance <IDateTimeHelper>();

            if (points != null)
            {
                this.Values = points.Select(point => this.CreateChartPoint(point, dateTimeHelper, pattern)).ToList();
            }
            this.ShowPoints     = true;
            this.ShowLines      = true;
            this.ShowBars       = false;
            this.BarWidth       = 0.3;
            this.FillLines      = true;
            this.YaxisOrder     = 1;
            this.Stacking       = false;
            this.Limited        = false;
            this.ShowLabelInTip = false;
        }