)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to customize a circular gauge control as a TimeLine gauge?

Platform: Xamarin.Forms |
Control: SfCircularGauge |
Published Date: January 11, 2018 |
Last Revised Date: June 25, 2019

This article explains the steps required to design a custom timeline render. The marker pointer has been customized as image to indicate the time line value. Header is used for displaying the updated value.

Circular gauge control can be customized as follows:

 

  1. Create a Xamarin application and initialize SfCircularGauge control on it.

XAML:

 

<gauge:SfCircularGauge BackgroundColor="#50707A" x:Name="circulargauge">
  <gauge:SfCircularGauge.Scales>
     <gauge:Scale StartAngle="270" StartValue="0" EndValue="100" Interval="10"     SweepAngle="360" ScaleStartOffset="0.85" ScaleEndOffset="0.8"                                 RimColor="#042F3F" MinorTicksPerInterval="0" ShowLabels="false" ShowTicks="false">
     </gauge:Scale>
  </gauge:SfCircularGauge.Scales>
</gauge:SfCircularGauge>

 

  1. Ranges can be used to know the dim value of weather data.

 

XAML:

<gauge:Scale.Ranges>
     <gauge:Range StartValue="5" EndValue="35" OuterStartOffset="0.85" InnerStartOffset="0.8" OuterEndOffset="0.85" InnerEndOffset="0.8"  Color="#94C93D">
     </gauge:Range>
</gauge:Scale.Ranges>

 

  1. Pointers can be used to set images in gauges as per the values. Images can be touched and moved to the respective position.

XAML:

<gauge:Scale.Pointers> 
   <gauge:MarkerPointer MarkerShape="Image"  Value="4" ImageSource="image1.png" MarkerWidth="60" MarkerHeight="60" >        <gauge:MarkerPointer.Offset>
  <OnPlatform x:TypeArguments="x:Double" iOS="0.92" Android="0.95" />  </gauge:MarkerPointer.Offset>
   </gauge:MarkerPointer>
  <gauge:MarkerPointer MarkerShape="Image"  Value="30" ImageSource="image2.png" MarkerWidth="60" MarkerHeight="60" >
 <gauge:MarkerPointer.Offset>
       <OnPlatform x:TypeArguments="x:Double" iOS="0.9" Android="0.95" />
 </gauge:MarkerPointer.Offset>
   </gauge:MarkerPointer>
   <gauge:MarkerPointer MarkerShape="Image"  Value="70" ImageSource="image3.png" MarkerWidth="60" MarkerHeight="60">
      <gauge:MarkerPointer.Offset>
      <OnPlatform x:TypeArguments="x:Double" iOS="0.9" Android="0.95" />
      </gauge:MarkerPointer.Offset>
   </gauge:MarkerPointer>
</gauge:Scale.Pointers>

 

  1. Add Headers to know the weather dim value. By using the header, position can be altered as required.

XAML:

<gauge:SfCircularGauge.Headers>
   <gauge:Header Text="DIM" TextSize="30" ForegroundColor="White" Position="0.5,0.45"/>
   <gauge:Header x:Name="weatherData" TextSize="25" ForegroundColor="White" Position="0.5,0.56"/>
   <gauge:Header Text="78d" TextSize="25" ForegroundColor="White" Position="0.9,0.2"/>
   <gauge:Header Text="1d" TextSize="25" ForegroundColor="White" Position="0.9,0.75"/>
</gauge:SfCircularGauge.Headers>        

 

  1. In code behind, weather dim values can be updated dynamically.

C#:

public partial class CircularTimelinePage : ContentPage
    {
        Random random = new Random();
        public CircularTimelinePage()
        {
 
            InitializeComponent();
            this.BindingContext = this;
            Device.StartTimer(new TimeSpan(0, 0, 0, 0, 1000), TimerElapsed);
        }
        private bool TimerElapsed()
        {
            Device.BeginInvokeOnMainThread(() =>
            {
                Random s = new Random();
                int random = s.Next(0, 100);
                weatherData.Text = "Dim:" + random;
            });
 
            return true;
        }
    }

 

Screenshot:

The following screenshot illustrates the custom timeline render gauge. 

 

Customize SfCircularGauge control as TimeLine gauge

Please find the complete sample for the above document in the link.

 

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon