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.
Unfortunately, activation email could not send to your email. Please try again.

How to design a fuel meter using Circular Gauge?

How to design a fuel meter using Circular Gauge?

 

This article explains you to design a fuel meter using Circular Gauge.

 

To design a fuel meter using Circular Gauge,

 

Create a Xamarin application and initialize SfCircularGauge control in it. Add Scale with suitable angles for Fuel Meter using StartAngle and SweepAngle

 

C#

 

 

 

In fuel meter, the variations in fuel level can be identified by differentiating the Scale of Circular Gauge using Range in Circular Gauge. Fuel levels can be split up using range of different colors.

C#

                List<Range> range = new List<Range>();

 

                Range range1 = new Range();

                range1.StartValue = 0;

                range1.EndValue = 40;

                range1.Thickness = 20;

                range1.Color = Color.FromHex("#006000");

 

                Range range2 = new Range();

                range2.StartValue = 40;

                range2.EndValue = 80;

                range2.Thickness = 20;

                range2.Color = Color.FromHex("#8D8F00");

 

 

                Range range3 = new Range();

                range3.StartValue = 80;

                range3.EndValue = 100;

                range3.Thickness = 20;

                range3.Color = Color.Red;

 

                range.Add(range1);

                range.Add(range2);

                range.Add(range3);

               

                scale.Ranges = range;

 

Add Major ticks and Minor ticks, which can be used to indicate the total number of fuel readings.

C#

                //Minor Ticks

                TickSettings minor = new TickSettings();

                minor.Length = 80;

                minor.Color = Color.Black;

                minor.Thickness = 10;

                minor.Offset = Device.OnPlatform(0.05, -0.1, 0.3);

                scale.MinorTickSettings = minor;

 

                //Major Ticks

                TickSettings major = new TickSettings();

                major.Length = 80;

                major.Color = Color.Black;

                major.Thickness = 10;

                major.Offset = Device.OnPlatform(0.05, -0.1, 0.3);

                                scale.MajorTickSettings = major;

 

 

In order to identify the exact level of fuel available, Range Pointer in Circular Gauge can be used as follows.

C#

 

   List<Pointer> pointers = new List<Pointer>();

                RangePointer rangePointer = new RangePointer();

                rangePointer.Value = 60;

                rangePointer.Color = Color.Gray;

                rangePointer.Thickness = 4;

                rangePointer.Offset = Device.OnPlatform(0.05, 0.1, 0.3);

                pointers.Add(rangePointer);

 

 

 

 

Headers in Circular Gauge can be used to render Text in Fuel Meter. Since positioning is possible with Header, different Texts can be positioned in the needed position.

C#

Header header = new Header();

                header.Text = "Fuel Meter";

                header.TextSize = 20;

                header.Position = Device.OnPlatform(iOS: new Point(.5, .6), Android: new Point(0.5, 0.5), WinPhone: new Point(0.32, 0.7));

                header.ForegroundColor = Color.Gray;

 

 

                Header full = new Header();

                full.Text = "F";

                full.TextSize = 40;

                full.Position = Device.OnPlatform(iOS: new Point(.5, .6), Android: new Point(0.9, 0.5), WinPhone: new Point(0.32, 0.7));

                full.ForegroundColor = Color.Gray;

 

 

                Header empty = new Header();

           

                empty.Text = "E";

                empty.TextSize = 40;

                empty.Position = Device.OnPlatform(iOS: new Point(.5, .6), Android: new Point(0.1,0.5), WinPhone: new Point(0.32, 0.7));

                empty.ForegroundColor = Color.Gray;

 

                Header value = new Header();

                value.Text = "60%";

                value.TextSize = 60;

                value.Position = Device.OnPlatform(iOS: new Point(.5, .6), Android: new Point(0.5, 0.4), WinPhone: new Point(0.32, 0.7));

                value.ForegroundColor = Color.Gray;

 

 

                circularGauge.Headers.Add(full);

            circularGauge.Headers.Add(empty);

            circularGauge.Headers.Add(value);

            circularGauge.Headers.Add(header);

 

 

 

 

 

 

 

 

 

The following screenshot displays the Fuel Meter using CircularGauge.

 

C:\Users\Swathi.Gopal\Desktop\KB\swathi\Fuel_Meter_XformsAndroid.png

 

 

 

Article ID: Published Date: Last Revised Date: Platform: Control:
6618 04/12/2016 04/12/2016 Xamarin.Android SfCircularGauge
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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.