WPF Charting Documentation - SciChart WPF Charts SDK v5.x
Axis Ranging - AutoRange and VisibleRange

Axis AutoRanging

The AxisCore.AutoRange property defines how the axis autoranges when data is added.

           The axis will never autorange. Use this to solve issues at startup caused by AutoRange.Once

 

Setting Axis.VisibleRange Programmatically

To programmatically range an axis, set the property AxisCore.VisibleRange with an IRange derived type.

DateTimeAxis

DateTimeAxis
Copy Code
var dateTimeAxis = new DateTimeAxis();
dateTimeAxis.VisibleRange = new DateRange(DateTime.Now, DateTime.Now.AddDays(10));

NumericAxis and LogarithmicNumericAxis

NumericAxis and LogarithmicNumericAxis
Copy Code
var numericAxis = new NumericAxis(); // or LogarithmicNumericAxis
numericAxis.VisibleRange = new DoubleRange(10.0, 100.0);

TimeSpanAxis

TimeSpanAxis
Copy Code
var timespanAxis = new TimeSpanAxis();
timespanAxis.VisibleRange = new TimeSpanRange(TimeSpan.Zero, TimeSpan.FromSeconds(10));

CategoryDateTimeAxis

The CategoryDateTimeAxis is a little different. The VisibleRange defines the indices displayed on the axis, e.g. an IndexRange of 0 to 100 means ‘display data-points with indices 0 to 100 inclusive’.

CategoryDateTimeAxis
Copy Code
var categoryDateTimeAxis = new CategoryDateTimeAxis();
categoryDateTimeAxis.VisibleRange = new IndexRange(0, 100);

Binding to VisibleRange in MVVM

VisibleRange is a DependencyProperty, so you can bind to it. The TwoWay binding is advisable to prevent issues with DependencyProperty Precedence, since we set the VisibleRange property internally in code.

Binding to VisibleRange
Copy Code
<!-- View -->
<s:DateTimeAxis VisibleRange="{Binding XVisibleRange, Mode=TwoWay}"/>

// ViewModel
private IRange _xVisibleRange;
public IRange XVisibleRange
{
   get { return _xVisibleRange; }
   set
   {
       if (_xVisibleRange != value)
          {
              _xVisibleRange = value;
                OnPropertyChanged("XVisibleRange");
          }
   }
} 
See Also

 

 


SCICHART ® is a Registered Trademark in the UK, US and EEC. Copyright SciChart Ltd 2011-2018.

Email us to give feedback!