Exemplo n.º 1
0
            public override Scale Create(DataValueType valueType)
            {
                DateTimeScale dateTimeScale = new DateTimeScale();

                dateTimeScale.ValueType = valueType;
                return((Scale)dateTimeScale);
            }
Exemplo n.º 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();
        }