Articles in this section
Category / Section

How to design an analog clock using .NET MAUI Radial Gauge (SfRadialGauge)?

5 mins read

This guide will walk you through creating an analog clock using the Syncfusion® .NET MAUI Radial Gauge control.

 

Step 1:  Create the SfRadialGauge control by referring to this getting started documentation, and set the StartAngle and the EndAngle of the RadialAxis to 270 to get the full circular axis.

 

XAML

<gauge:SfRadialGauge>
    <gauge:SfRadialGauge.Axes>
        <gauge:RadialAxis StartAngle="270"
                          EndAngle="270">
        </gauge:RadialAxis>
    </gauge:SfRadialGauge.Axes>
</gauge:SfRadialGauge>

 

Step 2: Set the Minimum and Maximum values of the radial axis to 0 and 12, respectively, with an Interval of 1. Set the ShowFirstLabel to false for a 12-hour clock display.

 

XAML

<gauge:SfRadialGauge>
    <gauge:SfRadialGauge.Axes>
        <gauge:RadialAxis Minimum="0"
                          Maximum="12"
                          Interval="1" 
                          ShowFirstLabel="False">
        </gauge:RadialAxis>
    </gauge:SfRadialGauge.Axes>
</gauge:SfRadialGauge>

 

Step 3: To customize the axis line and labels, use the AxisLineStyle and AxisLabelStyle as shown in the following code sample.

 

XAML

<gauge:RadialAxis.AxisLabelStyle>
    <gauge:GaugeLabelStyle FontSize="12" 
                           TextColor="#355C7D"/>
</gauge:RadialAxis.AxisLabelStyle>
<gauge:RadialAxis.AxisLineStyle>
    <gauge:RadialLineStyle Thickness="3"/>
</gauge:RadialAxis.AxisLineStyle>

 

Step 4: To customize the major and minor ticks, use the MajorTickStyle and MinorTickStyle as shown in the following code sample.

 

XAML

<gauge:RadialAxis.MajorTickStyle>
    <gauge:RadialTickStyle Length="0.08" 
                           LengthUnit="Factor" 
                           StrokeThickness="1.5"/>
</gauge:RadialAxis.MajorTickStyle>
 
<gauge:RadialAxis.MinorTickStyle>
    <gauge:RadialTickStyle Length="0.04" 
                           LengthUnit="Factor"
                           StrokeThickness="1"/>
</gauge:RadialAxis.MinorTickStyle>

 

Step 5: Add the NeedlePointer element for each clock hand to represent hours, minutes, and seconds.

 

XAML

<gauge:RadialAxis.Pointers>
    <gauge:NeedlePointer x:Name="hoursPointer"
                         EnableAnimation="True"
                         AnimationDuration="800"
                         AnimationEasing="{x:Static Easing.BounceOut}"
                         NeedleLength="0.6"
                         NeedleStartWidth="2"
                         NeedleEndWidth="5"
                         NeedleFill="#355C7D"
                         KnobRadius="0">
    </gauge:NeedlePointer>
    <gauge:NeedlePointer x:Name="minutesPointer"  
                         EnableAnimation="True"
                         AnimationDuration="800"
                         AnimationEasing="{x:Static Easing.BounceOut}"
                         NeedleLength="0.85"
                         NeedleStartWidth="1"
                         NeedleEndWidth="3"
                         NeedleFill="#355C7D"
                         KnobFill="#00A8B5"
                         KnobRadius="0.05" />
    <gauge:NeedlePointer x:Name="secondsPointer"
                         EnableAnimation="True"
                         AnimationDuration="800"
                         AnimationEasing="{x:Static Easing.BounceOut}"
                         NeedleLength="0.9"
                         NeedleStartWidth="2"
                         NeedleEndWidth="2"
                         NeedleFill="#00A8B5"
                         TailWidth="2"
                         TailLength="0.15"
                         TailFill="#00A8B5"
                         KnobFill="White"
                         KnobRadius="0.03"/>
</gauge:RadialAxis.Pointers>         
 

 

Output:

Analog clock with the .Net MAUI Radial Gauge

 

 

Download the complete sample on GitHub.

Conclusion

I hope you enjoyed learning how to design an analog clock using the .NET MAUI Radial Gauge (SfRadialGauge).

You can refer to our .NET MAUI Radial Gauge feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. Explore our .NET MAUI Radial Gauge example to understand how to create and manipulate data.

For current customers, check out our components from the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to check out our other controls.

Please let us know in the comments section if you have any queries or require clarification. Contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!


Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied