internal void CalculateScaleBreaksRanges(ObservableCollection <ISupportAxes> series) { if (Area == null || AxisScaleBreaks.Count == 0) { return; } DataRangeDelta = 0; BreakRanges = new List <DoubleRange>(); BreakRangesInfo = new Dictionary <DoubleRange, ChartAxisScaleBreak>(); AxisRanges = new List <DoubleRange>(); dataRanges = new List <DoubleRange>(); for (int i = 0; i < AxisScaleBreaks.Count; i++) { if (double.IsNaN(AxisScaleBreaks[i].Start) || (double.IsNaN(AxisScaleBreaks[i].End))) { continue; } var range = new DoubleRange(AxisScaleBreaks[i].Start, AxisScaleBreaks[i].End); if (VisibleRange.Inside(range) && range.Delta > 0) { ComputeBreakRange(range, i); } } AddDataRange(); foreach (var range in dataRanges) { DataRangeDelta += range.Delta; } ComputeAxisHeight(dataRanges, DataRangeDelta); }
protected override void GenerateVisibleLabels() { ChartSeriesBase actualSeries = Area.VisibleSeries .Where(series => series.ActualXAxis == this) .Max(filteredSeries => filteredSeries.DataCount); actualSeries = actualSeries != null ? actualSeries : Area is SfChart ? (Area as SfChart).TechnicalIndicators.Where(series => series.ActualXAxis == this) .Max(filteredSeries => filteredSeries.DataCount) : null; SetRangeForAxisStyle(); if (actualSeries != null) { var XValuesCount = actualSeries.ActualXValues as List <double>; if (XValuesCount != null && XValuesCount.Count > 0) { double interval = Interval != 0 ? Interval : ActualInterval; double position = VisibleRange.Start - (VisibleRange.Start % ActualInterval); var xValues = actualSeries.ActualXValues as List <double>; var xStartValue = xValues[0].FromOADate(); double distinctDate = 0d; int year = xStartValue.Year, month = xStartValue.Month, hour = xStartValue.Hour, mins = xStartValue.Minute, secs = xStartValue.Second, millisecs = xStartValue.Millisecond; DateTime date = xStartValue.Date; switch (ActualIntervalType) { case DateTimeIntervalType.Months: for (; position <= VisibleRange.End; position++) { int pos = ((int)Math.Round(position)); if (VisibleRange.Inside(position) && pos > -1 && pos < xValues.Count) { var xValue = xValues[pos].FromOADate(); if (xValue.Year > year) { year = xValue.Year; month = xValue.Month; } if (xValue.Year == year) { if (xValue.Month > month) { month = xValue.Month; } if (xValue.Month == month) { object obj = GetLabelContent(pos, actualSeries); var dateTimeAxisLabel = new DateTimeAxisLabel(pos, obj, xValues[pos]); dateTimeAxisLabel.IntervalType = ActualIntervalType; dateTimeAxisLabel.IsTransition = DateTimeAxisHelper.GetTransitionState(ref distinctDate, xValue, ActualIntervalType); VisibleLabels.Add(dateTimeAxisLabel); month = xValue.AddMonths((int)interval).Month; year = xValue.AddMonths((int)interval).Year; } } } } break; case DateTimeIntervalType.Years: for (; position <= VisibleRange.End; position++) { int pos = ((int)Math.Round(position)); if (VisibleRange.Inside(position) && pos > -1 && pos < xValues.Count) { var xValue = xValues[pos].FromOADate(); if (xValue.Year > year) { year = xValue.Year; } if (xValue.Year == year) { object obj = GetLabelContent(pos, actualSeries); var dateTimeAxisLabel = new DateTimeAxisLabel(pos, obj, xValues[pos]); dateTimeAxisLabel.IntervalType = ActualIntervalType; dateTimeAxisLabel.IsTransition = DateTimeAxisHelper.GetTransitionState(ref distinctDate, xValue, ActualIntervalType); VisibleLabels.Add(dateTimeAxisLabel); year = xValue.AddYears((int)interval).Year; } } } break; case DateTimeIntervalType.Days: for (; position <= VisibleRange.End; position++) { int pos = ((int)Math.Round(position)); if (VisibleRange.Inside(position) && pos > -1 && pos < xValues.Count) { var xValue = xValues[pos].FromOADate(); if (xValue.Date > date) { date = xValue.Date; } if (xValue.Date == date) { object obj = GetLabelContent(pos, actualSeries); var dateTimeAxisLabel = new DateTimeAxisLabel(pos, obj, xValues[pos]); dateTimeAxisLabel.IntervalType = ActualIntervalType; dateTimeAxisLabel.IsTransition = DateTimeAxisHelper.GetTransitionState(ref distinctDate, xValue, ActualIntervalType); VisibleLabels.Add(dateTimeAxisLabel); date = xValue.AddDays((int)interval).Date; } } } break; case DateTimeIntervalType.Hours: for (; position <= VisibleRange.End; position++) { int pos = ((int)Math.Round(position)); if (VisibleRange.Inside(position) && pos > -1 && pos < xValues.Count) { var xValue = xValues[pos].FromOADate(); if (xValue.Date > date) { date = xValue.Date; hour = xValue.Hour; } if (xValue.Date == date) { if (xValue.Hour > hour) { hour = xValue.Hour; } if (xValue.Hour == hour) { object obj = GetLabelContent(pos, actualSeries); var dateTimeAxisLabel = new DateTimeAxisLabel(pos, obj, xValues[pos]); dateTimeAxisLabel.IntervalType = ActualIntervalType; dateTimeAxisLabel.IsTransition = DateTimeAxisHelper.GetTransitionState(ref distinctDate, xValue, ActualIntervalType); VisibleLabels.Add(dateTimeAxisLabel); hour = xValue.AddHours((int)interval).Hour; date = xValue.AddHours((int)interval).Date; } } } } break; case DateTimeIntervalType.Minutes: for (; position <= VisibleRange.End; position++) { int pos = ((int)Math.Round(position)); if (VisibleRange.Inside(position) && pos > -1 && pos < xValues.Count) { var xValue = xValues[pos].FromOADate(); if (xValue.Date > date) { date = xValue.Date; hour = xValue.Hour; } if (xValue.Date == date) { if (xValue.Hour > hour) { hour = xValue.Hour; mins = xValue.Minute; } if (xValue.Hour == hour) { if (xValue.Minute > mins) { mins = xValue.Minute; } if (xValue.Minute == mins) { object obj = GetLabelContent(pos, actualSeries); var dateTimeAxisLabel = new DateTimeAxisLabel(pos, obj, xValues[pos]); dateTimeAxisLabel.IntervalType = ActualIntervalType; dateTimeAxisLabel.IsTransition = DateTimeAxisHelper.GetTransitionState(ref distinctDate, xValue, ActualIntervalType); VisibleLabels.Add(dateTimeAxisLabel); hour = xValue.AddMinutes((int)interval).Hour; mins = xValue.AddMinutes((int)interval).Minute; date = xValue.AddMinutes((int)interval).Date; } } } } } break; case DateTimeIntervalType.Seconds: for (; position <= VisibleRange.End; position++) { int pos = ((int)Math.Round(position)); if (VisibleRange.Inside(position) && pos > -1 && pos < xValues.Count) { var xValue = xValues[pos].FromOADate(); if (xValue.Date > date) { date = xValue.Date; hour = xValue.Hour; } if (xValue.Date == date) { if (xValue.Hour > hour) { hour = xValue.Hour; mins = xValue.Minute; } if (xValue.Hour == hour) { if (xValue.Minute > mins) { mins = xValue.Minute; secs = xValue.Second; } if (xValue.Minute == mins) { if (xValue.Second > secs) { secs = xValue.Second; } if (xValue.Second == secs) { object obj = GetLabelContent(pos, actualSeries); var dateTimeAxisLabel = new DateTimeAxisLabel(pos, obj, xValues[pos]); dateTimeAxisLabel.IntervalType = ActualIntervalType; dateTimeAxisLabel.IsTransition = DateTimeAxisHelper.GetTransitionState(ref distinctDate, xValue, ActualIntervalType); VisibleLabels.Add(dateTimeAxisLabel); hour = xValue.AddSeconds((int)interval).Hour; mins = xValue.AddSeconds((int)interval).Minute; date = xValue.AddSeconds((int)interval).Date; secs = xValue.AddSeconds((int)interval).Second; } } } } } } break; case DateTimeIntervalType.Milliseconds: for (; position <= VisibleRange.End; position++) { int pos = ((int)Math.Round(position)); if (VisibleRange.Inside(position) && pos > -1 && pos < xValues.Count) { var xValue = xValues[pos].FromOADate(); if (xValue.Date > date) { date = xValue.Date; hour = xValue.Hour; } if (xValue.Date == date) { if (xValue.Hour > hour) { hour = xValue.Hour; mins = xValue.Minute; } if (xValue.Hour == hour) { if (xValue.Minute > mins) { mins = xValue.Minute; secs = xValue.Second; } if (xValue.Minute == mins) { if (xValue.Second > secs) { secs = xValue.Second; millisecs = xValue.Millisecond; } if (xValue.Second == secs) { if (xValue.Millisecond > millisecs) { millisecs = xValue.Millisecond; } if (xValue.Millisecond == millisecs) { object obj = GetLabelContent(pos, actualSeries); var dateTimeAxisLabel = new DateTimeAxisLabel(pos, obj, xValues[pos]); dateTimeAxisLabel.IntervalType = ActualIntervalType; dateTimeAxisLabel.IsTransition = DateTimeAxisHelper.GetTransitionState(ref distinctDate, xValue, ActualIntervalType); VisibleLabels.Add(dateTimeAxisLabel); hour = xValue.AddMilliseconds((int)interval).Hour; mins = xValue.AddMilliseconds((int)interval).Minute; date = xValue.AddMilliseconds((int)interval).Date; secs = xValue.AddMilliseconds((int)interval).Second; millisecs = xValue.AddMilliseconds((int)interval).Millisecond; } } } } } } } break; case DateTimeIntervalType.Auto: for (; position <= VisibleRange.End; position += interval) { if (VisibleRange.Inside(position) && position < actualSeries.DataCount && position > -1) { int pos = ((int)Math.Round(position)); var xValue = xValues[pos].FromOADate(); object obj = GetLabelContent(pos, actualSeries); var dateTimeAxisLabel = new DateTimeAxisLabel(pos, obj, xValues[pos]); dateTimeAxisLabel.IntervalType = ActualIntervalType; dateTimeAxisLabel.IsTransition = DateTimeAxisHelper.GetTransitionState(ref distinctDate, xValue, ActualIntervalType); VisibleLabels.Add(dateTimeAxisLabel); } } break; } } } }