Category / Section
How to customize gauge position with Offset
3 mins read
This article explains the steps required to design circular gauge with Offset values.
Circular gauge control can be customized as follow,
- Create a Xamarin application, and initialize the SfCircularGauge control on it. Add Scale with suitable angles for rendering by using StartAngle and SweepAngle. ScaleStartOffset property is used to define where the scale position starts, and ScaleEndOffset property is used to define the position of the scale end.
XAML:
<xForms:SfCircularGauge x:Name="circularGauge" BackgroundColor="White" HeightRequest="160" WidthRequest="80"> <xForms:SfCircularGauge.Scales> <xForms:Scale x:Name="scale" EndValue="100" ScaleStartOffset="1" ScaleEndOffset="0.9" Interval="10" LabelColor="Gray" LabelOffset="0.7" LabelFontSize="15" MinorTicksPerInterval="2" RimColor="LightGray" StartAngle="135" StartValue="0" SweepAngle="270"> </xForms:Scale> </xForms:SfCircularGauge.Scales> </xForms:SfCircularGauge>
- In RangePointer, StartOffset property is used to set the starting position of the pointer and EndOffset property is used to set the ending position of the pointer. For NeedlePointer, KnobRadiusFactor property is used to increase the knob thickness.
XAML:
<xForms:Scale.Pointers> <xForms:NeedlePointer x:Name="needlePointer" KnobColor="LightGray" KnobRadiusFactor="0.05" LengthFactor="0.8" Type="Triangle" Color="LightGray" Value="50”/> <xForms:RangePointer Color="#2bbfb8" Value="50" StartOffset="1" EndOffset="0.9" /> </xForms:Scale.Pointers>
- Ticks can be customized by StartOffset and EndOffset properties. StartOffset is used to set where the ticks start, and EndOffset is used to set where the ticks end.
XAML:
<xForms:Scale.MajorTickSettings> <xForms:TickSettings StartOffset="0.9" EndOffset="0.8" Thickness=”2” Color="#444444" /> </xForms:Scale.MajorTickSettings> <xForms:Scale.MinorTickSettings> <xForms:TickSettings StartOffset="0.9" EndOffset="0.85" Thickness=”1” Color="#444444" /> </xForms:Scale.MinorTickSettings>
- Headers can be customized by Position property.
XAML:
<xForms:SfCircularGauge.Headers> <xForms:Header Font="Bold" ForegroundColor="Black" Position="0.5,0.7" Text="50%" TextSize="40" /> </xForms:SfCircularGauge.Headers>
The following screenshot illustrates the Customized Gauge.