How I can set the needlepointer, range pointer, marker pointer, end value, start value etc from code behind?

How I can set the needlepointer, range pointer, marker pointer, end value, start value etc from code behind?

I would like to add values dynamically from code behind.


1 Reply

ET Eswaran Thirugnanasambandam Syncfusion Team February 1, 2023 12:26 PM UTC

Hi Anoop


The SfCircularGauge control in Xamarin.Forms provides several properties to set the needle, range, marker, and start/end values dynamically from the code-behind. Here's how you can set these values in C#:


NeedlePointer: You can set the value of the needle pointer using the Value property of the NeedlePointer class.

[C#]

NeedlePointer needlePointer = new NeedlePointer();

            needlePointer.Value = 70;

            if (gauge.Scales != null && gauge.Scales.Count > 0 && scale != null)

            {

                scale.Pointers.Add(needlePointer);

            }


Range Pointer: You can set the range of the range pointer using the RangeStart and Value properties of the RangePointer class.

[C#]

RangePointer rangePointer = new RangePointer();

            rangePointer.RangeStart = 15;

            rangePointer.Value = 85;

            if (gauge.Scales != null && gauge.Scales.Count > 0 && scale != null)

            {

                scale.Pointers.Add(rangePointer);

            }


Marker Pointer: You can set the value of the marker pointer using the Value property of the MarkerPointer class.

[C#]

MarkerPointer markerPointer = new MarkerPointer();

            markerPointer.Value = 70;

            markerPointer.MarkerShape = MarkerShape.Triangle;

            if (gauge.Scales != null && gauge.Scales.Count > 0 && scale != null)

            {

                scale.Pointers.Add(markerPointer);

            }


Start/End Values: You can set the start and end values of the gauge scale using the StartValue and EndValue properties.

[C#]

if (scale != null)

{

     scale.StartValue = 20;

     scale.EndValue = 60;

}


We have prepared the sample to achieve your requirement and please get from below attachment. Please refer to the below user guide documentation link for more information.

https://help.syncfusion.com/xamarin/circular-gauge/pointers?cs-save-lang=1&cs-lang=csharp#marker-pointer

https://help.syncfusion.com/xamarin/circular-gauge/scales#setting-the-start-and-end-values-for-scale


Regards,

Eswaran


Attachment: CircularGauge_a9017e9d.zip

Loader.
Up arrow icon