menu

MAUI

  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class SfLinearGauge - MAUI API Reference | Syncfusion

    Show / Hide Table of Contents

    Class SfLinearGauge

    Creates a linear gauge control to displays the values on a linear scale horizontally or vertically. It has a rich set of features such as axis, ranges, and pointers that are fully customizable and extendable.

    Inheritance
    System.Object
    SfLinearGauge
    Implements
    Microsoft.Maui.IContentView
    Microsoft.Maui.IView
    Microsoft.Maui.IElement
    Microsoft.Maui.ITransform
    Microsoft.Maui.IPadding
    Microsoft.Maui.ICrossPlatformLayout
    Microsoft.Maui.IVisualTreeElement
    Namespace: Syncfusion.Maui.Gauges
    Assembly: Syncfusion.Maui.Gauges.dll
    Syntax
    public class SfLinearGauge : View, IContentView, IView, IElement, ITransform, IPadding, ICrossPlatformLayout, IVisualTreeElement, ITouchListener, IParentThemeElement, IThemeElement
    Examples
     <gauge:SfLinearGauge >
                <gauge:SfLinearGauge.Ranges>
                    <gauge:LinearRange/>
                </gauge:SfLinearGauge.Ranges>
                <gauge:SfLinearGauge.MarkerPointers>
                    <gauge:LinearShapePointer Value="70" />
                    <gauge:LinearContentPointer Value="80" >
                         <gauge:LinearContentPointer.Content>
                            <Grid WidthRequest="30" HeightRequest="25">
                                <RoundRectangle Stroke="Black"
                                                StrokeThickness="2"
                                                CornerRadius="5"/>
                                <Label Text = "70" TextColor="Black" HorizontalOptions="Center"
                                       VerticalOptions="Center"/>
                            </Grid>
                        </gauge:LinearContentPointer.Content>
                    </gauge:LinearContentPointer>
                </gauge:SfLinearGauge.MarkerPointers>
                <gauge:SfLinearGauge.BarPointers>
                    <gauge:BarPointer Value="60" />
                </gauge:SfLinearGauge.BarPointers>
            </gauge:SfLinearGauge>

    Constructors

    SfLinearGauge()

    Initializes a new instance of the SfLinearGauge class.

    Declaration
    public SfLinearGauge()
    Examples
     <gauge:SfLinearGauge>
         <gauge:SfLinearGauge.Ranges>
             <gauge:LinearRange/>
         </gauge:SfLinearGauge.Ranges>
         <gauge:SfLinearGauge.MarkerPointers>
             <gauge:LinearShapePointer Value="70" />
             <gauge:LinearContentPointer Value="80" >
                  <gauge:LinearContentPointer.Content>
                     <Grid WidthRequest="30" HeightRequest="25">
                         <RoundRectangle Stroke="Black"
                                         StrokeThickness="2"
                                         CornerRadius="5"/>
                         <Label Text="70" TextColor="Black" HorizontalOptions="Center"
                                VerticalOptions="Center"/>
                     </Grid>
                 </gauge:LinearContentPointer.Content>
             </gauge:LinearContentPointer>
         </gauge:SfLinearGauge.MarkerPointers>
         <gauge:SfLinearGauge.BarPointers>
             <gauge:BarPointer Value="60" />
         </gauge:SfLinearGauge.BarPointers>
    </gauge:SfLinearGauge>

    Fields

    AnimationDurationProperty

    Identifies the AnimationDuration bindable property.

    Declaration
    public static readonly BindableProperty AnimationDurationProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for AnimationDuration bindable property.

    BarPointersProperty

    Identifies the BarPointers bindable property.

    Declaration
    public static readonly BindableProperty BarPointersProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for BarPointers bindable property.

    EnableAxisAnimationProperty

    Identifies the EnableAxisAnimation bindable property.

    Declaration
    public static readonly BindableProperty EnableAxisAnimationProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for EnableAxisAnimation bindable property.

    EnableRangeAnimationProperty

    Identifies the EnableRangeAnimation bindable property.

    Declaration
    public static readonly BindableProperty EnableRangeAnimationProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for EnableRangeAnimation bindable property.

    IntervalProperty

    Identifies the Interval bindable property.

    Declaration
    public static readonly BindableProperty IntervalProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for Interval bindable property.

    IsInversedProperty

    Identifies the IsInversed bindable property.

    Declaration
    public static readonly BindableProperty IsInversedProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for IsInversed bindable property.

    IsMirroredProperty

    Identifies the IsMirrored bindable property.

    Declaration
    public static readonly BindableProperty IsMirroredProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for IsMirrored bindable property.

    LabelFormatProperty

    Identifies the LabelFormat bindable property.

    Declaration
    public static readonly BindableProperty LabelFormatProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for LabelFormat bindable property.

    LabelOffsetProperty

    Identifies the LabelOffset bindable property.

    Declaration
    public static readonly BindableProperty LabelOffsetProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for LabelOffset bindable property.

    LabelPositionProperty

    Identifies the LabelPosition bindable property.

    Declaration
    public static readonly BindableProperty LabelPositionProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for LabelPosition bindable property.

    LabelStyleProperty

    Identifies the LabelStyle bindable property.

    Declaration
    public static readonly BindableProperty LabelStyleProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for LabelStyle bindable property.

    LineStyleProperty

    Identifies the LineStyle bindable property.

    Declaration
    public static readonly BindableProperty LineStyleProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for LineStyle bindable property.

    MajorTickStyleProperty

    Identifies the MajorTickStyle bindable property.

    Declaration
    public static readonly BindableProperty MajorTickStyleProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for MajorTickStyle bindable property.

    MarkerPointersProperty

    Identifies the MarkerPointers bindable property.

    Declaration
    public static readonly BindableProperty MarkerPointersProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for MarkerPointers bindable property.

    MaximumLabelsCountProperty

    Identifies the MaximumLabelsCount bindable property.

    Declaration
    public static readonly BindableProperty MaximumLabelsCountProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for MaximumLabelsCount bindable property.

    MaximumProperty

    Identifies the Maximum bindable property.

    Declaration
    public static readonly BindableProperty MaximumProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for Maximum bindable property.

    MinimumProperty

    Identifies the Minimum bindable property.

    Declaration
    public static readonly BindableProperty MinimumProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for Minimum bindable property.

    MinorTicksPerIntervalProperty

    Identifies the MinorTicksPerInterval bindable property.

    Declaration
    public static readonly BindableProperty MinorTicksPerIntervalProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for MinorTicksPerInterval bindable property.

    MinorTickStyleProperty

    Identifies the MinorTickStyle bindable property.

    Declaration
    public static readonly BindableProperty MinorTickStyleProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for MinorTickStyle bindable property.

    OrientationProperty

    Identifies the Orientation bindable property.

    Declaration
    public static readonly BindableProperty OrientationProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for Orientation bindable property.

    RangesProperty

    Identifies the Ranges bindable property.

    Declaration
    public static readonly BindableProperty RangesProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for Ranges bindable property.

    ShowLabelsProperty

    Identifies the ShowLabels bindable property.

    Declaration
    public static readonly BindableProperty ShowLabelsProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for ShowLabels bindable property.

    ShowLineProperty

    Identifies the ShowLine bindable property.

    Declaration
    public static readonly BindableProperty ShowLineProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for ShowLine bindable property.

    ShowTicksProperty

    Identifies the ShowTicks bindable property.

    Declaration
    public static readonly BindableProperty ShowTicksProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for ShowTicks bindable property.

    TickOffsetProperty

    Identifies the TickOffset bindable property.

    Declaration
    public static readonly BindableProperty TickOffsetProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for TickOffset bindable property.

    TickPositionProperty

    Identifies the TickPosition bindable property.

    Declaration
    public static readonly BindableProperty TickPositionProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for TickPosition bindable property.

    UseRangeColorForAxisProperty

    Identifies the UseRangeColorForAxis bindable property.

    Declaration
    public static readonly BindableProperty UseRangeColorForAxisProperty
    Field Value
    Type Description
    Microsoft.Maui.Controls.BindableProperty

    The identifier for UseRangeColorForAxis bindable property.

    Properties

    AnimationDuration

    Gets or sets a value that specifies the load time animation duration in milliseconds.

    Declaration
    public double AnimationDuration { get; set; }
    Property Value
    Type Description
    System.Double

    The default value is 1000 milliseconds.

    Remarks

    It specifies how long the loading time animation will take.

    Examples
    <gauge:SfLinearGauge EnableAxisAnimation="true" AnimationDuration="2000">
    </gauge:SfLinearGauge>

    BarPointers

    Gets or sets the BarPointer collection to the linear gauge.

    Declaration
    public ObservableCollection<BarPointer> BarPointers { get; set; }
    Property Value
    Type Description
    System.Collections.ObjectModel.ObservableCollection<BarPointer>

    Customizes each pointer by adding it to the BarPointers collection. The default value is empty collection.

    Examples
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.BarPointers>
            <gauge:BarPointer Value="50" Position="Outside" Fill="Red" />
        </gauge:SfLinearGauge.BarPointers>
    </gauge:SfLinearGauge>

    EnableAxisAnimation

    Gets or sets a value indicating whether to animate the axis elements such as axis line, ticks, and labels on load time.

    Declaration
    public bool EnableAxisAnimation { get; set; }
    Property Value
    Type Description
    System.Boolean

    The default value is false.

    Examples
    <gauge:SfLinearGauge EnableAxisAnimation="true">
    </gauge:SfLinearGauge>

    EnableRangeAnimation

    Gets or sets a value indicating whether to animate linear range on load time.

    Declaration
    public bool EnableRangeAnimation { get; set; }
    Property Value
    Type Description
    System.Boolean

    The default value is false.

    Examples
    <gauge:SfLinearGauge EnableAxisAnimation="True"
                         EnableRangeAnimation="True">
        <gauge:SfLinearGauge.Ranges>
            <gauge:LinearRange/>
        </gauge:SfLinearGauge.Ranges>
    </gauge:SfLinearGauge>

    Interval

    Gets or sets the interval value of the axis. Using this, the axis labels and major ticks can be displayed after a certain interval value.

    Declaration
    public double Interval { get; set; }
    Property Value
    Type Description
    System.Double

    It defines the interval of the SfLinearGauge. The default value is double.NaN.

    Examples
    <gauge:SfLinearGauge Interval="50">
    </gauge:SfLinearGauge>

    IsInversed

    Gets or sets a value indicating whether inverts the axis from right to left for a horizontal linear gauge or top to bottom for a vertical linear gauge.

    Declaration
    public bool IsInversed { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if axis is inversed; otherwise, false.The default value is false.

    Remarks

    IsInversed decides whether the axis will be inversed or not.

    Examples
    <gauge:SfLinearGauge IsInversed="true">
    </gauge:SfLinearGauge>

    IsMirrored

    Gets or sets a value indicating whether to mirror the linear gauge.

    Declaration
    public bool IsMirrored { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if scale is mirrored; otherwise, false.The default value is false.

    Remarks

    IsMirrored decides whether the linear gauge elements will be rendered in the opposite direction.

    Examples
    <gauge:SfLinearGauge IsMirrored="true">
    </gauge:SfLinearGauge>

    LabelFormat

    Gets or sets a value to formats the scale labels with globalized string formats.

    Declaration
    public string LabelFormat { get; set; }
    Property Value
    Type Description
    System.String

    The string that specifies the globalized string formats for the scale labels. Its default value is string.Empty.

    Examples
    <gauge:SfLinearGauge LabelFormat="c">
    </gauge:SfLinearGauge>

    LabelOffset

    Gets or sets a value to adjusts the axis label position from tick end to the custom position. Specify values in the logical pixel.

    Declaration
    public double LabelOffset { get; set; }
    Property Value
    Type Description
    System.Double

    It defines the offset of the axis labels. The default value is double.NaN.

    Examples
    <gauge:SfLinearGauge LabelOffset="10">
    </gauge:SfLinearGauge>

    LabelPosition

    Gets or sets the value that indicates the position of the scale labels inside or outside the axis line.

    Declaration
    public GaugeLabelsPosition LabelPosition { get; set; }
    Property Value
    Type Description
    GaugeLabelsPosition

    One of the enumeration values that specifies the position of labels in the linear gauge. The registered default vlaue is Inside.

    Examples
    <gauge:SfLinearGauge LabelPosition="Outside">
    </gauge:SfLinearGauge>

    LabelStyle

    Gets or sets a value to customize the style of default axis labels.

    Declaration
    public GaugeLabelStyle LabelStyle { get; set; }
    Property Value
    Type
    GaugeLabelStyle
    Examples
     <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.LabelStyle>
            <gauge:GaugeLabelStyle TextColor="Red"/>
        </gauge:SfLinearGauge.LabelStyle>
    </gauge:SfLinearGauge>

    LineStyle

    Gets or sets a value to customize the style of default axis line.

    Declaration
    public LinearLineStyle LineStyle { get; set; }
    Property Value
    Type
    LinearLineStyle
    Examples
     <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.LineStyle>
            <gauge:LinearLineStyle Thickness="15" />
        </gauge:SfLinearGauge.LineStyle>
    </gauge:SfLinearGauge>

    MajorTickStyle

    Gets or sets a value to customize the style of default major ticks.

    Declaration
    public LinearTickStyle MajorTickStyle { get; set; }
    Property Value
    Type
    LinearTickStyle
    Examples
     <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.MajorTickStyle>
           <gauge:LinearTickStyle Stroke="Red"/>
        </gauge:SfLinearGauge.MajorTickStyle>
    </gauge:SfLinearGauge>

    MarkerPointers

    Gets or sets the marker pointers collection to the linear gauge.

    Declaration
    public ObservableCollection<LinearMarkerPointer> MarkerPointers { get; set; }
    Property Value
    Type Description
    System.Collections.ObjectModel.ObservableCollection<LinearMarkerPointer>

    Customizes each pointer by adding it to the MarkerPointers collection. The default value is empty collection.

    Examples
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.MarkerPointers>
            <gauge:LinearShapePointer Position="Outside"
                                  Value="70" Alignment="Start"/>
        </gauge:SfLinearGauge.MarkerPointers>
    </gauge:SfLinearGauge>

    Maximum

    Gets or sets the maximum value of the axis. The axis ends at this value.

    Declaration
    public double Maximum { get; set; }
    Property Value
    Type Description
    System.Double

    It defines the maximum value of the SfLinearGauge. The default value is 100.

    Examples
    <gauge:SfLinearGauge Maximum="200">
    </gauge:SfLinearGauge>

    MaximumLabelsCount

    Gets or sets the maximum number of labels to be displayed in 100 logical pixels.

    Declaration
    public int MaximumLabelsCount { get; set; }
    Property Value
    Type Description
    System.Int32

    Maximum number of labels to be displayed in a axis in 100 logical pixels. Its default value is 3.

    Examples
    <gauge:SfLinearGauge MaximumLabelsCount="5">
    </gauge:SfLinearGauge>

    Minimum

    Gets or sets the minimum value of the axis. The axis starts from this value.

    Declaration
    public double Minimum { get; set; }
    Property Value
    Type Description
    System.Double

    It defines the minimum values of the SfLinearGauge. The default value is 0.

    Examples
    <gauge:SfLinearGauge Minimum="10">
    </gauge:SfLinearGauge>

    MinorTicksPerInterval

    Gets or sets the minor ticks count per interval in an axis..

    Declaration
    public int MinorTicksPerInterval { get; set; }
    Property Value
    Type Description
    System.Int32

    It defines the number of minor ticks will be rendered between the major ticks. The default value is 1.

    Examples
    <gauge:SfLinearGauge MinorTicksPerInterval="5">
    </gauge:SfLinearGauge>

    MinorTickStyle

    Gets or sets a value to customize the style of default minor ticks.

    Declaration
    public LinearTickStyle MinorTickStyle { get; set; }
    Property Value
    Type
    LinearTickStyle
    Examples
     <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.MinorTickStyle>
            <gauge:LinearTickStyle Stroke="Red"/>
        </gauge:SfLinearGauge.MinorTickStyle>
    </gauge:SfLinearGauge>

    Orientation

    Gets or sets a value that indicates whether to show the linear gauge horizontally or vertically.

    Declaration
    public GaugeOrientation Orientation { get; set; }
    Property Value
    Type Description
    GaugeOrientation

    Orientation of the linear gauge. The default is GaugeOrientation.Horizontal".

    Remarks

    Orientation decides whether the linear gauge will be rendered in horizontal or vertical direction.

    Examples
    <gauge:SfLinearGauge Orientation="Vertical">
    </gauge:SfLinearGauge>

    Ranges

    Gets or sets the LinearRange collection to the linear gauge.

    Declaration
    public ObservableCollection<LinearRange> Ranges { get; set; }
    Property Value
    Type Description
    System.Collections.ObjectModel.ObservableCollection<LinearRange>

    Customizes each range by adding it to the ranges collection. The default value is empty collection.

    Examples
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Ranges>
            <gauge:LinearRange/>
        </gauge:SfLinearGauge.Ranges>
    </gauge:SfLinearGauge>

    ShowLabels

    Gets or sets a value indicating whether to show or hide the axis labels.

    Declaration
    public bool ShowLabels { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if axis labels are displayed; otherwise, false.The default value is true.

    Remarks

    It decides whether the axis labels will be rendered or not. If ShowLabels is true, the axis labels will be rendered, otherwise not rendered.

    Examples
    <gauge:SfLinearGauge ShowLabels="false">
    </gauge:SfLinearGauge>

    ShowLine

    Gets or sets a value indicating whether to show or hide the axis line.

    Declaration
    public bool ShowLine { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if axis line is displayed; otherwise, false.The default value is true.

    Remarks

    It decides whether the axis line will be rendered or not. If ShowLine is true, the axis line will be rendered, otherwise not rendered.

    Examples
    <gauge:SfLinearGauge ShowLine="false">
    </gauge:SfLinearGauge>

    ShowTicks

    Gets or sets a value indicating whether to show or hide the axis ticks.

    Declaration
    public bool ShowTicks { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if axis ticks lines are displayed; otherwise, false.The default value is true.

    Remarks

    It decides whether the axis ticks will be rendered or not. If ShowTicks is true, the scale ticks will be rendered, otherwise not rendered.

    Examples
    <gauge:SfLinearGauge ShowTicks="false">
    </gauge:SfLinearGauge>

    TickOffset

    Gets or sets the value to adjusts the scale ticks position from the scale line to the custom position. Specify values in the logical pixels.

    Declaration
    public double TickOffset { get; set; }
    Property Value
    Type Description
    System.Double

    It defines the offset of the ticks. The default value is double.NaN.

    Examples
    <gauge:SfLinearGauge TickOffset="10">
    </gauge:SfLinearGauge>

    TickPosition

    Gets or sets the value that indicates the position of the ticks inside, or center, or outside the axis line.

    Declaration
    public GaugeElementPosition TickPosition { get; set; }
    Property Value
    Type Description
    GaugeElementPosition

    One of the enumeration values that specifies the position of ticks in the linear gauge. The default is Inside.

    Examples
    <gauge:SfLinearGauge TickPosition="Outside">
    </gauge:SfLinearGauge>

    UseRangeColorForAxis

    Gets or sets a value indicating whether to use the range color for axis elements such as labels and ticks.

    Declaration
    public bool UseRangeColorForAxis { get; set; }
    Property Value
    Type Description
    System.Boolean

    The default value is false.

    Remarks

    It decides whether the corresponding range color will be applied to the axis elements like labels and ticks or not. If UseRangeColorForAxis is true, the corresponding range colors will be applied, otherwise not.

    Examples
    <gauge:SfLinearGauge UseRangeColorForAxis="true">
        <gauge:SfLinearGauge.Ranges>
            <gauge:LinearRange StartValue="0" EndValue="50"/>
        </gauge:SfLinearGauge.Ranges>
    </gauge:SfLinearGauge>

    Methods

    FactorToValue(Double)

    Converts factor to axis value.

    Declaration
    public virtual double FactorToValue(double factor)
    Parameters
    Type Name Description
    System.Double factor

    The factor to convert as axis value.

    Returns
    Type Description
    System.Double

    Axis value of the provided factor.

    Examples
    • XAML
    • C#
    <local:LinearGauge Minimum="1" Maximum="10000">
        <gauge:SfLinearGauge.MarkerPointers>
            <gauge:LinearShapePointer Value="1000" />
        </gauge:SfLinearGauge.MarkerPointers>
    </local:LinearGauge>
    public class LinearGauge : SfLinearGauge
    {
        int labelsCount;
        public override List<GaugeLabelInfo> GenerateVisibleLabels()
        {
            List<GaugeLabelInfo> labelInfos = new List<GaugeLabelInfo>();
            int minimum = (int)LogBase(this.Minimum, 10);
            int maximum = (int)LogBase(this.Maximum, 10);
            for (int i = minimum; i <= maximum; i++)
            {
                double value = Math.Floor(Math.Pow(10, i)); // logBase  value is
                GaugeLabelInfo label = new GaugeLabelInfo()
                {
                    Value = value,
                    Text = value.ToString()
                };
                labelInfos.Add(label);
            }
    
            labelsCount = labelInfos.Count;
            return labelInfos;
        }
    
        private double LogBase(double value, int baseValue)
        {
            return Math.Log(value) / Math.Log(baseValue);
        }
    
        public override double ValueToFactor(double value)
        {
            return LogBase(value, 10) / (labelsCount - 1);
        }
    
        public override double FactorToValue(double factor)
        {
            return Math.Pow(Math.E, factor * (labelsCount - 1) * Math.Log(10));
        }
    }

    GenerateVisibleLabels()

    Calculates the visible labels based on scale interval and range.

    Declaration
    public virtual List<GaugeLabelInfo> GenerateVisibleLabels()
    Returns
    Type Description
    System.Collections.Generic.List<GaugeLabelInfo>

    The visible label collection.

    Examples
    • XAML
    • C#
    <local:LinearGauge Minimum="1" Maximum="10000">
        <gauge:SfLinearGauge.MarkerPointers>
            <gauge:LinearShapePointer Value="1000" />
        </gauge:SfLinearGauge.MarkerPointers>
    </local:LinearGauge>
    public class LinearGauge : SfLinearGauge
    {
        int labelsCount;
        public override List<GaugeLabelInfo> GenerateVisibleLabels()
        {
            List<GaugeLabelInfo> labelInfos = new List<GaugeLabelInfo>();
            int minimum = (int)LogBase(this.Minimum, 10);
            int maximum = (int)LogBase(this.Maximum, 10);
            for (int i = minimum; i <= maximum; i++)
            {
                double value = Math.Floor(Math.Pow(10, i)); // logBase  value is
                GaugeLabelInfo label = new GaugeLabelInfo()
                {
                    Value = value,
                    Text = value.ToString()
                };
                labelInfos.Add(label);
            }
    
            labelsCount = labelInfos.Count;
            return labelInfos;
        }
    
        private double LogBase(double value, int baseValue)
        {
            return Math.Log(value) / Math.Log(baseValue);
        }
    
        public override double ValueToFactor(double value)
        {
            return LogBase(value, 10) / (labelsCount - 1);
        }
    
        public override double FactorToValue(double factor)
        {
            return Math.Pow(Math.E, factor * (labelsCount - 1) * Math.Log(10));
        }
    }

    OnBindingContextChanged()

    Invoked whenever the binding context of the View changes.

    Declaration
    protected override void OnBindingContextChanged()

    ValueToFactor(Double)

    Converts scale value to linear factor value.

    Declaration
    public virtual double ValueToFactor(double value)
    Parameters
    Type Name Description
    System.Double value

    The scale value to convert as factor.

    Returns
    Type Description
    System.Double

    Linear factor of the provided value.

    Examples
    • XAML
    • C#
    <local:LinearGauge Minimum="1" Maximum="10000">
        <gauge:SfLinearGauge.MarkerPointers>
            <gauge:LinearShapePointer Value="1000" />
        </gauge:SfLinearGauge.MarkerPointers>
    </local:LinearGauge>
    public class LinearGauge : SfLinearGauge
    {
        int labelsCount;
        public override List<GaugeLabelInfo> GenerateVisibleLabels()
        {
            List<GaugeLabelInfo> labelInfos = new List<GaugeLabelInfo>();
            int minimum = (int)LogBase(this.Minimum, 10);
            int maximum = (int)LogBase(this.Maximum, 10);
            for (int i = minimum; i <= maximum; i++)
            {
                double value = Math.Floor(Math.Pow(10, i)); // logBase  value is
                GaugeLabelInfo label = new GaugeLabelInfo()
                {
                    Value = value,
                    Text = value.ToString()
                };
                labelInfos.Add(label);
            }
    
            labelsCount = labelInfos.Count;
            return labelInfos;
        }
    
        private double LogBase(double value, int baseValue)
        {
            return Math.Log(value) / Math.Log(baseValue);
        }
    
        public override double ValueToFactor(double value)
        {
            return LogBase(value, 10) / (labelsCount - 1);
        }
    
        public override double FactorToValue(double factor)
        {
            return Math.Pow(Math.E, factor * (labelsCount - 1) * Math.Log(10));
        }
    }

    Events

    LabelCreated

    Called when an axis label is created

    Declaration
    public event EventHandler<LabelCreatedEventArgs> LabelCreated
    Event Type
    Type
    System.EventHandler<LabelCreatedEventArgs>

    Implements

    Microsoft.Maui.IContentView
    Microsoft.Maui.IView
    Microsoft.Maui.IElement
    Microsoft.Maui.ITransform
    Microsoft.Maui.IPadding
    Microsoft.Maui.ICrossPlatformLayout
    Microsoft.Maui.IVisualTreeElement
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved