# Controlling Axis Range

The chart continuous axes have a notion of range which, by default, is calculated automatically based on the plotted data. The RadChartView axes allow to access information about the range or adjust the range manually.

Continuous axes are `LinearAxis`, `LogarithmicAxis` and `DateTimeContinuousAxis`. The `CategoricalAxis` and `DateTimeCategoricalAxis` don't have notion of range and the following information is not relevant for them.
The examples in the article work mostly with numeric values, but if you use the `DateTimeContinuousAxis` you will need to use `DateTime`.

## Actual Range

The actual range is a read-only information that tells what are the real minimum and maximum properties of the axis. This concept exists to ensure that the axis range can be accessed regardless if it is calculated automatically or set manually.

To get the actual range, use the `ActualRange` property of the axis.

To get the actual range when the axis is zoom-in, use the `ActualVisibleRange` property of the axis. This gives information about the currently visible minimum and maximum.

To get the actual major step, use the `ActualMajorStep` property of the axis.

**Getting the actual range of a LinearAxis**

```C#
ValueRange<double> actualRange = linearAxis.ActualRange;
ValueRange<double> actualVisibleRange = linearAxis.ActualVisibleRange;
double actualMajorStep = linearAxis.ActualMajorStep;
```

The axis also provides a couple of **events raised when the range changes**.

* `ActualRangeChanged`
* `ActualVisibleRangeChanged`
* `ActualMajorStepChanged`

**Actual range and step changed event handlers**

```C#
private void LinearAxis_ActualMajorStepChanged(object sender, EventArgs e)
{
    var axis = (LinearAxis)sender;
    double majorStep = axis.ActualMajorStep;
}

private void LinearAxis_ActualVisibleRangeChanged(object sender, NumericalRangeChangedEventArgs e)
{
    ValueRange<double> newRange = e.NewRange;
    ValueRange<double> oldRange = e.PreviousRange;
}

private void LinearAxis_ActualRangeChanged(object sender, NumericalRangeChangedEventArgs e)
{
    ValueRange<double> newRange = e.NewRange;
    ValueRange<double> oldRange = e.PreviousRange;
}
```

## Setting the Range Manually

The axis range can be adjusted manually by setting the `Minimum` and `Maximum` properties of the axis.

**Setting axis range in XAML**

```XAML
<telerik:LinearAxis Minimum="100" Maximum="1000" />

<telerik:DateTimeContinuousAxis Minimum="05/13/2024" Maximum="06/13/2024" />
```

**Setting axis range in C#**

```XAML
<telerik:RadCartesianChart>
    <telerik:RadCartesianChart.HorizontalAxis>
        <telerik:CategoricalAxis />
    </telerik:RadCartesianChart.HorizontalAxis>
    <telerik:RadCartesianChart.VerticalAxis>
        <telerik:LinearAxis />
    </telerik:RadCartesianChart.VerticalAxis>
</telerik:RadCartesianChart>
```

![Telerik UI for WPF RadChartView Axis with Manually Set Minimum and Maximum Range](https://www.telerik.com/products/wpf/documentation/assets/c65517609517d356d579b128647a3c0d/radchartview-axis-range-0.png)

## Scrolling a Fixed-Span Y Axis

For a complete live depth-chart example with a moving 150-unit Y-axis window, fixed tick alignment, and unchanged historical samples, see [Create a Live Depth Chart with a Fixed-Span Y Axis](https://www.telerik.com/products/wpf/documentation/knowledge-base/kb-chartview-scroll-fixed-span-y-axis).

## Setting the Step

The chart axes allow you to manually set the major and minor step, which determines the value distance between two adjacent ticks.

To set the major step, use the `MajorStep` property of the axis.

**Setting major step**

```XAML
<telerik:LinearAxis Minimum="100" TickOrigin="500" MajorStep="150" Maximum="1000" />
```

![Telerik UI for WPF RadChartView Axis with a Manually Set Major Step](https://www.telerik.com/products/wpf/documentation/assets/8a381567c7d5a941e7136823ac5bf1b4/radchartview-axis-range-1.png)

To get the actual major step, use the `ActualMajorStep` property of the axis. This is helpful if you don't assign the `MajorStep` property and rely on the automatically calculated one.

The minor step can be set with the `MinorTicksPerMajor` property of the axis. This determines how many minor ticks should be drawn between two adjacent major ticks. Read more about this feature in the [Minor Ticks and Strips](https://www.telerik.com/products/wpf/documentation/controls/radchartview/features/minor-ticks-and-stripes) article.

The step in the `DateTimeContinuousAxis` works with two properties - the `MajorStep` and the `MajorStepUnit` which determines the time interval of the step. Read more in the [Date Time Axes](https://www.telerik.com/products/wpf/documentation/controls/radchartview/axes/datetimeaxes) article.

The first major tick can be offset by setting the `MajorTickOffset` property of the axis. This determines which tick (by index) should be shown first. For example, setting the offset to 3 will skip three ticks before start rendering the ticks.

## Setting the Tick Origin

The tick origin determines the value where the ticks originate. The positions of the ticks are determined based on the combination of the major step and tick origin values.

To set the origin, use the `TickOrigin` property of the axis (available in `LinearAxis` and `DateTimeContinuousAxis`).

**Setting major step**

```XAML
<telerik:LinearAxis Minimum="100" TickOrigin="500" MajorStep="150" Maximum="1000" />
```

![Telerik UI for WPF RadChartView Axis with a Custom Tick Origin](https://www.telerik.com/products/wpf/documentation/assets/1e3c869697fd5b46cc95b4bc5befddb9/radchartview-axis-range-2.png)

## Setting the Desired Ticks Count

The axis allows you to set the desired tick count via the `DesiredTickCount` property. The axis will try to calculate a proper step based on the axis range and the desired number of ticks. Note, that the actual number of ticks may be slightly higher or lower since the automatic range calculation takes into account different factors and it tries to display a reasonable step between the ticks. For example, if the `DesiredTickCount` is 7, then 6 or 8 ticks may be drawn, depending on the range of the axis.

**Setting desired number of ticks**

```XAML
<telerik:LinearAxis DesiredTickCount="5" />
```

![Telerik UI for WPF RadChartView Axis with a Desired Tick Count](https://www.telerik.com/products/wpf/documentation/assets/64d40c89824f27cf8e391a983831ad12/radchartview-axis-range-3.png)

## See Also

* [Getting Started](https://www.telerik.com/products/wpf/documentation/controls/radchartview/getting-started/introduction)
* [Events](https://www.telerik.com/products/wpf/documentation/controls/radchartview/events)
* [Create Data-Bound Chart](https://www.telerik.com/products/wpf/documentation/controls/radchartview/populating-with-data/series-databinding)
