Example #1
0
        private void CalculateRangeInfo()
        {
            this.ActualIncludeZero = ValueHelper.ToBoolean(this.IncludeZero, ValueHelper.ToBoolean(this.Defaults.IncludeZero, false));
            this.ActualMaxMargin   = this.GetMaxAllowedMargin(this.MaxCount);
            Range <double>?dataRange     = RangeHelper.Add <double>(this.ActualDataRange, this.CrossingPosition);
            double?        viewMinimum   = this.ViewMinimum;
            double?        minimum       = viewMinimum.HasValue ? new double?(viewMinimum.GetValueOrDefault()) : this.Minimum;
            double?        viewMaximum   = this.ViewMaximum;
            double?        maximum       = viewMaximum.HasValue ? new double?(viewMaximum.GetValueOrDefault()) : this.Maximum;
            int            num           = this.ActualIncludeZero ? 1 : 0;
            double?        majorInterval = this.MajorInterval;
            double?        interval      = majorInterval.HasValue ? new double?(majorInterval.GetValueOrDefault()) : this.MinorInterval;

            this._rangeInfo = NumericRangeInfo.Calculate(dataRange, minimum, maximum, num != 0, interval);
        }
Example #2
0
        public override void Recalculate()
        {
            Range <DateTime> range = DateTimeSequence.CalculateRange(this.ViewMinimum, this.ViewMaximum, this.Minimum, this.Maximum, RangeHelper.Add <DateTime>(this.ActualDataRange, this.CrossingPosition), this.DefaultRange);
            TimeSpan         size  = range.Maximum.Subtract(range.Minimum);

            this.ActualMajorIntervalUnit = DateTimeScale.IsNullOrRelative(this.MajorIntervalUnit) ? DateTimeSequence.GetMajorUnit(size, this.MaxCount) : this.MajorIntervalUnit.Value;
            this.ActualMinorIntervalUnit = DateTimeScale.IsNullOrRelative(this.MinorIntervalUnit) ? DateTimeSequence.GetMinorUnit(size, this.MaxCount) : this.MinorIntervalUnit.Value;
            int maxCount1 = this.MaxCount;

            switch (this.ActualMajorIntervalUnit)
            {
            case DateTimeScaleUnit.Years:
                this._majorSequence = DateTimeSequence.CalculateYears(range, this.MajorInterval, this.MajorIntervalOffset, maxCount1);
                break;

            case DateTimeScaleUnit.Months:
                this._majorSequence = DateTimeSequence.CalculateMonths(range, this.MajorInterval, this.MajorIntervalOffset, maxCount1);
                break;

            case DateTimeScaleUnit.Weeks:
                this._majorSequence = DateTimeSequence.CalculateWeeks(range, this.MajorInterval, this.MajorIntervalOffset, maxCount1, this.FirstDayOfWeek);
                break;

            case DateTimeScaleUnit.Days:
                this._majorSequence = DateTimeSequence.CalculateDays(range, this.MajorInterval, this.MajorIntervalOffset, maxCount1);
                break;

            case DateTimeScaleUnit.Hours:
                this._majorSequence = DateTimeSequence.CalculateHours(range, this.MajorInterval, this.MajorIntervalOffset, maxCount1);
                break;

            case DateTimeScaleUnit.Minutes:
                this._majorSequence = DateTimeSequence.CalculateMinutes(range, this.MajorInterval, this.MajorIntervalOffset, maxCount1);
                break;

            case DateTimeScaleUnit.Seconds:
                this._majorSequence = DateTimeSequence.CalculateSeconds(range, this.MajorInterval, this.MajorIntervalOffset, maxCount1);
                break;

            case DateTimeScaleUnit.Milliseconds:
                this._majorSequence = DateTimeSequence.CalculateMilliseconds(range, this.MajorInterval, this.MajorIntervalOffset, maxCount1);
                break;

            default:
                throw new NotImplementedException();
            }
            int maxCount2 = this._majorSequence.Count * DateTimeSequence.GetMinorCountPerMajorInterval(this.ActualMajorIntervalUnit);

            switch (this.ActualMinorIntervalUnit)
            {
            case DateTimeScaleUnit.Years:
                this._minorSequence = DateTimeSequence.CalculateYears(range, this.MinorInterval, this.MinorIntervalOffset, maxCount2);
                break;

            case DateTimeScaleUnit.Months:
                this._minorSequence = DateTimeSequence.CalculateMonths(range, this.MinorInterval, this.MinorIntervalOffset, maxCount2);
                break;

            case DateTimeScaleUnit.Weeks:
                this._minorSequence = DateTimeSequence.CalculateWeeks(range, this.MinorInterval, this.MinorIntervalOffset, maxCount2, this.FirstDayOfWeek);
                break;

            case DateTimeScaleUnit.Days:
                this._minorSequence = DateTimeSequence.CalculateDays(range, this.MinorInterval, this.MinorIntervalOffset, maxCount2);
                break;

            case DateTimeScaleUnit.Hours:
                this._minorSequence = DateTimeSequence.CalculateHours(range, this.MinorInterval, this.MinorIntervalOffset, maxCount2);
                break;

            case DateTimeScaleUnit.Minutes:
                this._minorSequence = DateTimeSequence.CalculateMinutes(range, this.MinorInterval, this.MinorIntervalOffset, maxCount2);
                break;

            case DateTimeScaleUnit.Seconds:
                this._minorSequence = DateTimeSequence.CalculateSeconds(range, this.MinorInterval, this.MinorIntervalOffset, maxCount2);
                break;

            case DateTimeScaleUnit.Milliseconds:
                this._minorSequence = DateTimeSequence.CalculateMilliseconds(range, this.MinorInterval, this.MinorIntervalOffset, maxCount2);
                break;

            default:
                throw new NotImplementedException();
            }
            if (this.ActualDataRange.HasValue && !this.Minimum.HasValue)
            {
                range = range.ExtendTo(this._minorSequence.Minimum);
            }
            if (this.ActualDataRange.HasValue && !this.Maximum.HasValue)
            {
                range = range.ExtendTo(this._minorSequence.Maximum);
            }
            this.CalculateActual(range);
            this.CalculateSampleContent();
            base.Recalculate();
        }