# .NET MAUI Gauge Axis

The axis provides options for you to control all its displayed elements including ticks, labels, appearance, and axis range.

## Axis Range

Presently, the axis does not have an auto-range mechanism so it is mandatory that you set the `Minimum`, `Maximum`, and `Step` properties.

```XAML
<telerik:GaugeLinearAxis Maximum="4"
					     Minimum="0"
					     Step="0.5" />
```

The following image shows the end result.

![Gauge Axis Range](https://www.telerik.com/maui-ui/documentation/assets/ddf0e00b73cdab4dfdcc0d08ebbe9982/gauge-axis-range.png)

## Axis Line Stroke and Ticks

You can control the stroke of the axis line and ticks through the `Stroke` property. To set a different color for the ticks, use the `TickStroke` property. Similarly, setting the `StrokeThickness` affects both the axis line and ticks. To set a different stroke thickness for the ticks, use the `TickThickness` property.

```XAML
<telerik:GaugeLinearAxis Maximum="4"
					     Minimum="0"
					     Step="0.5"
					     Stroke="#FFDD789B"
					     StrokeThickness="1"
					     TextColor="#FF4062AD"
					     TickStroke="#FFAAC271"
					     TickThickness="2" />
```

The following image shows the end result.

![Gauge Appearance](https://www.telerik.com/maui-ui/documentation/assets/cad9ed857e92644d4664a5f94a164fc0/gauge-axis-appearance.png)

## Font Style

You can control the appearance of the labels with the `FontSize`, `FontFamily` and `FontAttributes` properties.

```XAML
<telerik:GaugeLinearAxis FontAttributes="Bold"
                               FontSize="30"
                               Maximum="4"
                               Minimum="0"
                               Step="0.5" />
```

The following image shows the end result.

![Gauge Font Style](https://www.telerik.com/maui-ui/documentation/assets/ebd7587b520ba52c2b884b1c01d949c7/gauge-axis-fontstyle.png)

## Font Family

The `FontFamily` property is of type `string` and you need to pass the name of the font family. Remember that the different platforms work with different fonts so you may need to use the `OnPlatform` method.

The following image shows the end result.

![Gauge Font Family](https://www.telerik.com/maui-ui/documentation/assets/1999df70b0abdf6ba7432846330291c3/gauge-axis-fontfamily.png)

## Label Format

You can control the numeric format of the content of the labels. The default label format is `"G7"`.

```XAML
<telerik:GaugeLinearAxis LabelFormat="N2"
					     Maximum="4"
					     Minimum="0"
					     Step="0.5" />
```

The following image shows the end result.

![Gauge label format](https://www.telerik.com/maui-ui/documentation/assets/6390fb616b3bd833d41c30e1aa5e540d/gauge-axis-label-format.png)

## Label Formatter

The Gauge Axis exposes a `LabelFormatter` property that allows you to set a custom function for formatting the axis labels. The function overrides the default label format. The function receives the axis tick value and returns a string representing the formatted label.

> caption Example with LabelFormatter

1. Define the Gauge in XAML:

```XAML
<telerik:RadRadialGauge>
    <telerik:RadRadialGauge.Axis>
        <telerik:GaugeLinearAxis x:Name="axis" 
                                 Maximum="90" 
                                 TickLength="0"
                                 LabelOffset="{OnPlatform Android=0, iOS=0}"
                                 Minimum="0"
                                 Step="30" />
    </telerik:RadRadialGauge.Axis>
    <telerik:RadRadialGauge.Ranges>
        <telerik:GaugeRangesDefinition>
            <telerik:GaugeRange Color="Green"
                                From="0"
                                To="50" />
            <telerik:GaugeGradientRange From="50" To="90">
                <telerik:RadGradientStop Offset="60" Color="Yellow" />
                <telerik:RadGradientStop Offset="90" Color="Red" />
            </telerik:GaugeGradientRange>
        </telerik:GaugeRangesDefinition>
    </telerik:RadRadialGauge.Ranges>
    <telerik:RadRadialGauge.Indicators>
        <telerik:GaugeNeedleIndicator Offset="30" Value="60" />
        <telerik:GaugeShapeIndicator Value="65" />
    </telerik:RadRadialGauge.Indicators>
</telerik:RadRadialGauge>
```

2. Set the `LabelFormatter` function to the Gauge axis:

```C#
this.axis.LabelFormatter = value => $"{value}mph";
```

The following image shows the end result.

![Gauge label formatter](https://www.telerik.com/maui-ui/documentation/assets/41c5c62647eeb596d4b6dd002c218708/gauge-label-formatter.png)

## Label and Tick Position

In the Radial Gauge, the Gauge elements can be positioned on the inside or on the outside of the axis line. Some of the elements, such as the ticks, can also be centered on the axis line. This behavior is controlled by the `Position` property of the specific element.

```XAML
<telerik:GaugeLinearAxis LabelPosition="Start"
					     Maximum="4"
					     Minimum="0"
					     Step="0.5"
					     TickPosition="Start" />
```

The following image shows the end result.

![Gauge label and tick position](https://www.telerik.com/maui-ui/documentation/assets/57b3c1b6c44a1a55d60701d72726fc4f/gauge-axis-label-and-tick-position.png)

## Offset and Length

The distance between the specific element and the axis line is defined by the `Offset`, `TickOffset`, and `LabelOffset` properties. You can also specify the length of the ticks.

```XAML
<telerik:GaugeLinearAxis LabelOffset="8"
					     Maximum="4"
					     Minimum="0"
					     Step="0.5"
					     TickLength="3"
					     TickOffset="3" />
```

The following image shows the end result.

![Gauge Offset and Length](https://www.telerik.com/maui-ui/documentation/assets/f5a84978f57c40565ce4b58a53c77fd1/gauge-axis-offset-and-length.png)

## Label Visibility

You can change axis label visibility by setting the `ShowLabels = "False"`. The default value is `True`.

```XAML
<telerik:GaugeLinearAxis ShowLabels="False"
						  Maximum="250"
						  Minimum="0"
						  Step="25" />
```

The following image shows the end result.

![Gauge Label and Tick Visibility](https://www.telerik.com/maui-ui/documentation/assets/eb122a0a9b4aef4247b6b7e75fc72ca7/gauge-axis-label-hidden.png)

## Tick Thickness

Change the thickness of the axis ticks using the `TickThickness` property.

If you want to remove the ticks set `TickThickness="0"`.

```XAML
<telerik:GaugeLinearAxis Maximum="250"
					   Minimum="0"
					   Step="25" 
					   TickThickness="0" />
```

The following image shows the end result.

![Gauge Tick Visibility](https://www.telerik.com/maui-ui/documentation/assets/bad12190f8a3684cdab47d4db5945b65/gauge-axis-tick-hidden.png)

In scenario when Labels are hidden and the `TickThickness` is 0:

```XAML
<telerik:GaugeLinearAxis Maximum="250"
					   Minimum="0"
					   Step="25" 
					   TickThickness="0" 
					   ShowLabels="False" />
```

![Gauge Label and Tick Visibility](https://www.telerik.com/maui-ui/documentation/assets/6bf5326b12848ef7fbadaaba1ca997a0/gauge-axis-label-tick-hidden.png)

## See Also

* [Indicators](https://www.telerik.com/maui-ui/documentation/controls/gauge/indicators)
* [Positioning](https://www.telerik.com/maui-ui/documentation/controls/gauge/positioning)
* [Ranges](https://www.telerik.com/maui-ui/documentation/controls/gauge/ranges)
