menu

WinUI

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class LinearAxis - WinUI API Reference | Syncfusion

    Show / Hide Table of Contents

    Class LinearAxis

    The LinearAxis is a linear line in which a set of values are displayed along a linear or custom scale based on the design requirements.

    Inheritance
    System.Object
    LinearAxis
    Namespace: Syncfusion.UI.Xaml.Gauges
    Assembly: Syncfusion.Gauge.WinUI.dll
    Syntax
    public class LinearAxis : Control
    Examples

    The below examples shows, how to initialize the linear axis in linear gauge.

    <gauge:SfLinearGauge IsInversed="False"
                         IsMirrored="False"
                         Orientation="Horizontal">
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis Minimum="0"
                              Maximum="100"
                              Interval="20"
                              CornerStyle="BothFlat"
                              UseRangeColorForAxis="True"
                              MinorTicksPerInterval="1"
                              MinorTickLength="4"
                              MajorTickLength="8">
                <gauge:LinearAxis.Ranges>
                    <gauge:LinearGaugeRange StartValue="0"
                                            EndValue="100"
                                            RangePosition="Cross"
                                            StartWidth="5"
                                            EndWidth="5">
                        <gauge:LinearGaugeRange.GradientStops>
                            <gauge:GaugeGradientStop Value="0"
                                                     Color="Green" />
                            <gauge:GaugeGradientStop Value="50"
                                                     Color="Orange" />
                            <gauge:GaugeGradientStop Value="100"
                                                     Color="Red" />
                        </gauge:LinearGaugeRange.GradientStops>
                    </gauge:LinearGaugeRange>
                </gauge:LinearAxis.Ranges>
    
                <gauge:LinearAxis.BarPointers>
                    <gauge:BarPointer Value="50"
                                      PointerSize="10"
                                      Background="Orange" 
                                      CornerStyle="BothFlat"
                                      Offset="-15" />
                </gauge:LinearAxis.BarPointers>
    
                <gauge:LinearAxis.MarkerPointers>
                    <gauge:LinearShapePointer Value="60"
                                        ShapeHeight="15"
                                        ShapeWidth="15"
                                        ShapeType="Circle"
                                        IsInteractive="True" />
    
                    <gauge:LinearContentPointer Value="20">
                        <gauge:LinearContentPointer.Content>
                            <Grid Background="BlueViolet">
                                <TextBlock Text="{Binding Value}" />
                            </Grid>
                        </gauge:LinearContentPointer.Content>
                    </gauge:LinearContentPointer>
                </gauge:LinearAxis.MarkerPointers>
            </gauge:LinearAxis>
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    Constructors

    LinearAxis()

    Initializes a new instance of the LinearAxis class.

    Declaration
    public LinearAxis()
    Examples

    The below examples shows, how to initialize the linear axis in linear gauge.

    <gauge:SfLinearGauge IsInversed="False"
                         IsMirrored="False"
                         Orientation="Horizontal">
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis Minimum="0"
                              Maximum="100"
                              Interval="20"
                              CornerStyle="BothFlat"
                              UseRangeColorForAxis="True"
                              MinorTicksPerInterval="1"
                              MinorTickLength="4"
                              MajorTickLength="8">
                <gauge:LinearAxis.Ranges>
                    <gauge:LinearGaugeRange StartValue="0"
                                            EndValue="100"
                                            RangePosition="Cross"
                                            StartWidth="5"
                                            EndWidth="5">
                        <gauge:LinearGaugeRange.GradientStops>
                            <gauge:GaugeGradientStop Value="0"
                                                     Color="Green" />
                            <gauge:GaugeGradientStop Value="50"
                                                     Color="Orange" />
                            <gauge:GaugeGradientStop Value="100"
                                                     Color="Red" />
                        </gauge:LinearGaugeRange.GradientStops>
                    </gauge:LinearGaugeRange>
                </gauge:LinearAxis.Ranges>
    
                <gauge:LinearAxis.BarPointers>
                    <gauge:BarPointer Value="50"
                                      PointerSize="10"
                                      Background="Orange" 
                                      CornerStyle="BothFlat"
                                      Offset="-15" />
                </gauge:LinearAxis.BarPointers>
    
                <gauge:LinearAxis.MarkerPointers>
                    <gauge:LinearShapePointer Value="60"
                                        ShapeHeight="15"
                                        ShapeWidth="15"
                                        ShapeType="Circle"
                                        IsInteractive="True" />
    
                    <gauge:LinearContentPointer Value="20">
                        <gauge:LinearContentPointer.Content>
                            <Grid Background="BlueViolet">
                                <TextBlock Text="{Binding Value}" />
                            </Grid>
                        </gauge:LinearContentPointer.Content>
                    </gauge:LinearContentPointer>
                </gauge:LinearAxis.MarkerPointers>
            </gauge:LinearAxis>
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    Fields

    AxisLineStrokeProperty

    Identifies the AxisLineStroke dependency property.

    Declaration
    public static readonly DependencyProperty AxisLineStrokeProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for AxisLineStroke dependency property.

    AxisLineStrokeThicknessProperty

    Identifies the AxisLineStrokeThickness dependency property.

    Declaration
    public static readonly DependencyProperty AxisLineStrokeThicknessProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for AxisLineStrokeThickness dependency property.

    AxisLineStyleProperty

    Identifies the AxisLineStyle dependency property.

    Declaration
    public static readonly DependencyProperty AxisLineStyleProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for AxisLineStyle dependency property.

    BarPointersProperty

    Identifies the BarPointers dependency property.

    Declaration
    public static readonly DependencyProperty BarPointersProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for BarPointers dependency property.

    CornerStyleProperty

    Identifies the CornerStyle dependency property.

    Declaration
    public static readonly DependencyProperty CornerStyleProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for CornerStyle dependency property.

    IntervalProperty

    Identifies the Interval dependency property.

    Declaration
    public static readonly DependencyProperty IntervalProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for Interval dependency property.

    LabelFormatProperty

    Identifies the LabelFormat dependency property.

    Declaration
    public static readonly DependencyProperty LabelFormatProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for LabelFormat dependency property.

    LabelOffsetProperty

    Identifies the LabelOffset dependency property.

    Declaration
    public static readonly DependencyProperty LabelOffsetProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for LabelOffset dependency property.

    LabelPositionProperty

    Identifies the LabelPosition dependency property.

    Declaration
    public static readonly DependencyProperty LabelPositionProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for LabelPosition dependency property.

    LabelTemplateProperty

    Identifies the LabelTemplate dependency property.

    Declaration
    public static readonly DependencyProperty LabelTemplateProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for LabelTemplate dependency property.

    MajorTickLengthProperty

    Identifies the MajorTickLength dependency property.

    Declaration
    public static readonly DependencyProperty MajorTickLengthProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for MajorTickLength dependency property.

    MajorTickStyleProperty

    Identifies the MajorTickStyle dependency property.

    Declaration
    public static readonly DependencyProperty MajorTickStyleProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for MajorTickStyle dependency property.

    MarkerPointersProperty

    Identifies the MarkerPointers dependency property.

    Declaration
    public static readonly DependencyProperty MarkerPointersProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for MarkerPointers dependency property.

    MaximumLabelsCountProperty

    Identifies the MaximumLabelsCount dependency property.

    Declaration
    public static readonly DependencyProperty MaximumLabelsCountProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for MaximumLabelsCount dependency property.

    MaximumProperty

    Identifies the Maximum dependency property.

    Declaration
    public static readonly DependencyProperty MaximumProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for Maximum dependency property.

    MinimumProperty

    Identifies the Minimum dependency property.

    Declaration
    public static readonly DependencyProperty MinimumProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for Minimum dependency property.

    MinorTickLengthProperty

    Identifies the MinorTickLength dependency property.

    Declaration
    public static readonly DependencyProperty MinorTickLengthProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for MinorTickLength dependency property.

    MinorTicksPerIntervalProperty

    Identifies the MinorTicksPerInterval dependency property.

    Declaration
    public static readonly DependencyProperty MinorTicksPerIntervalProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for MinorTicksPerInterval dependency property.

    MinorTickStyleProperty

    Identifies the MinorTickStyle dependency property.

    Declaration
    public static readonly DependencyProperty MinorTickStyleProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for MinorTickStyle dependency property.

    RangesProperty

    Identifies the Ranges dependency property.

    Declaration
    public static readonly DependencyProperty RangesProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for Ranges dependency property.

    ShowAxisLineProperty

    Identifies the ShowAxisLine dependency property.

    Declaration
    public static readonly DependencyProperty ShowAxisLineProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for ShowAxisLine dependency property.

    ShowLabelsProperty

    Identifies the ShowLabels dependency property.

    Declaration
    public static readonly DependencyProperty ShowLabelsProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for ShowLabels dependency property.

    ShowTicksProperty

    Identifies the ShowTicks dependency property.

    Declaration
    public static readonly DependencyProperty ShowTicksProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for ShowTicks dependency property.

    TickOffsetProperty

    Identifies the TickOffset dependency property.

    Declaration
    public static readonly DependencyProperty TickOffsetProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for TickOffset dependency property.

    TickPositionProperty

    Identifies the TickPosition dependency property.

    Declaration
    public static readonly DependencyProperty TickPositionProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for TickPosition dependency property.

    UseRangeColorForAxisProperty

    Identifies the UseRangeColorForAxis dependency property.

    Declaration
    public static readonly DependencyProperty UseRangeColorForAxisProperty
    Field Value
    Type Description
    Microsoft.UI.Xaml.DependencyProperty

    The identifier for UseRangeColorForAxis dependency property.

    Properties

    AxisLineStroke

    Gets or sets the Brush that specifies how the axis line is painted.

    Declaration
    public Brush AxisLineStroke { get; set; }
    Property Value
    Type Description
    Microsoft.UI.Xaml.Media.Brush

    A Brush that specifies how the axis line is painted.

    Examples
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis AxisLineStroke="Red" />
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    AxisLineStrokeThickness

    Gets or sets a value to customize the axis line thickness.

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

    It defines the thickness of the axis line. The default value is 6.

    Examples
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis AxisLineStrokeThickness="30" />
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    AxisLineStyle

    Gets or sets the style used by this element when axis line is rendered.

    Declaration
    public Style AxisLineStyle { get; set; }
    Property Value
    Type Description
    Microsoft.UI.Xaml.Style

    Apply when customization required for default axis line. Its default value is null.

    Remarks

    Its target type is Line.

    Examples
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis>
                <gauge:LinearAxis.AxisLineStyle>
                    <Style TargetType="Line">
                        <Setter Property="StrokeDashArray"
                                Value="2,1" />
                    </Style>
                </gauge:LinearAxis.AxisLineStyle>
            </gauge:LinearAxis>
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    BarPointers

    Gets or sets the BarPointer collection to the linear gauge.

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

    The below examples shows, how to add bar pointers to linear axis in linear gauge.

    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis>
                <gauge:LinearAxis.BarPointers>
                    <gauge:BarPointer Value="50"
                                      PointerSize="10"
                                      Background="Orange" 
                                      CornerStyle="BothFlat"
                                      Offset="-15" />
                </gauge:LinearAxis.BarPointers>
            </gauge:LinearAxis>
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    CornerStyle

    Gets or sets a CornerStyle enumeration value that describes the corner/edge style of the axis line.

    Declaration
    public CornerStyle CornerStyle { get; set; }
    Property Value
    Type Description
    CornerStyle

    One of the enumeration values for CornerStyle. The default is BothFlat.

    Examples
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis CornerStyle="BothCurve" />
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    Interval

    Gets or sets the interval value of the axis. Using this, the axis labels 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 LinearAxis. The default value is double.NaN.

    Examples
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis Interval="10" />
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    LabelFormat

    Gets or sets a value to formats the axis 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 axis labels. Its default value is string.Empty.

    Examples
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis LabelFormat="c" />
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    LabelOffset

    Gets or sets a value to adjusts the axis label position from tick end.

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

    It defines distance between ticks and labels in pixels. Its default value is 5.

    Examples
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis LabelOffset="40" />
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    LabelPosition

    Gets or sets the value that indicates the position of the axis labels below/above the axis line for a horizontal linear gauge, or to the right/left of the axis line for a vertical linear gauge.

    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 default is Inside.

    Examples
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis LabelPosition="Outside" />
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    LabelTemplate

    Gets or sets the template for the axis labels.

    Declaration
    public DataTemplate LabelTemplate { get; set; }
    Property Value
    Type Description
    Microsoft.UI.Xaml.DataTemplate

    The template for the axis labels. The registered default is null.

    Remarks

    Its DataContext is AxisLabelData.

    Examples
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis>
                <gauge:LinearAxis.LabelTemplate>
                    <DataTemplate>
                        <Border Background="Gray"
                                CornerRadius="5">
                            <TextBlock Text="{Binding Text}"
                                       Foreground="White"
                                       FontStyle="Normal"
                                       FontWeight="Bold"
                                       Margin="3" />
                        </Border>
                    </DataTemplate>
                </gauge:LinearAxis.LabelTemplate>
            </gauge:LinearAxis>
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    MajorTickLength

    Gets or sets the length of the major tick line.

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

    The length of the major tick line. The default value is 8.

    Examples
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis MajorTickLength="15" />
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    MajorTickStyle

    Gets or sets the style used by this element when major tick line is rendered.

    Declaration
    public Style MajorTickStyle { get; set; }
    Property Value
    Type Description
    Microsoft.UI.Xaml.Style

    The style that is applied to major tick line in LinearAxis.

    Remarks

    To define a Microsoft.UI.Xaml.Style for major ticks, specify a TargetType of Line.

    Examples
    <Page.Resources>
        <Style x:Key="MajorTickLineStyle"
               TargetType="Line">
            <Setter Property="Stroke"
                    Value="Black"></Setter>
            <Setter Property="StrokeThickness"
                    Value="1.5"></Setter>
        </Style>
    </Page.Resources>
    
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis MajorTickStyle="{StaticResource MajorTickLineStyle}" />
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    MarkerPointers

    Gets or sets the MarkerPointer collection to the linear gauge.

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

    The collection of LinearShapePointer and LinearContentPointer to display the current value of the axis. The default value is empty collection.

    Examples

    The below examples shows, how to add marker pointers to linear axis in linear gauge.

    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis>
                <gauge:LinearAxis.MarkerPointers>
                    <gauge:LinearShapePointer Value="60"
                                        ShapeHeight="15"
                                        ShapeWidth="15"
                                        ShapeType="Circle"
                                        IsInteractive="True" />
    
                    <gauge:LinearContentPointer Value="20">
                        <gauge:LinearContentPointer.Content>
                            <Grid Background="BlueViolet">
                                <TextBlock Text="{Binding Value}" />
                            </Grid>
                        </gauge:LinearContentPointer.Content>
                    </gauge:LinearContentPointer>
                </gauge:LinearAxis.MarkerPointers>
            </gauge:LinearAxis>
        </gauge:SfLinearGauge.Axis>
    </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 LinearAxis. The default value is 100.

    Examples
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis Maximum="150" />
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    MaximumLabelsCount

    Gets or sets the maximum number of labels to be displayed in a axis 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>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis MaximumLabelsCount="3" />
        </gauge:SfLinearGauge.Axis>
    </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 LinearAxis. The default value is 0.

    Examples
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis Minimum="10" />
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    MinorTickLength

    Gets or sets the length of the minor tick line.

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

    The length of the minor tick line. The default value is 4.

    Examples
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis MinorTickLength="10" />
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    MinorTicksPerInterval

    Gets or sets the interval of the minor ticks.

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

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

    Examples
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis MinorTicksPerInterval="10" />
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    MinorTickStyle

    Gets or sets the style used by this element when minor tick line is rendered.

    Declaration
    public Style MinorTickStyle { get; set; }
    Property Value
    Type Description
    Microsoft.UI.Xaml.Style

    The style that is applied to minor tick line in LinearAxis.

    Remarks

    To define a Microsoft.UI.Xaml.Style for minor ticks, specify a TargetType of Line.

    Examples
    <Page.Resources>
        <Style x:Key="MinorTickLineStyle"
               TargetType="Line">
            <Setter Property="Stroke"
                    Value="Black"></Setter>
            <Setter Property="StrokeThickness"
                    Value="1.5"></Setter>
        </Style>
    </Page.Resources>
    
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis MinorTickStyle="{StaticResource MinorTickLineStyle}" />
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    Ranges

    Gets or sets the LinearGaugeRange collection to the linear gauge.

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

    The collection of linear range to display the current value of the axis. The default value is empty collection.

    Examples

    The below examples shows, how to add linear ranges to linear axis in linear gauge.

    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis>
                <gauge:LinearAxis.Ranges>
                    <gauge:LinearGaugeRange StartValue="0"
                                            EndValue="100"
                                            RangePosition="Cross"
                                            StartWidth="5"
                                            EndWidth="5">
                        <gauge:LinearGaugeRange.GradientStops>
                            <gauge:GaugeGradientStop Value="0"
                                                     Color="Green" />
                            <gauge:GaugeGradientStop Value="50"
                                                     Color="Orange" />
                            <gauge:GaugeGradientStop Value="100"
                                                     Color="Red" />
                        </gauge:LinearGaugeRange.GradientStops>
                    </gauge:LinearGaugeRange>
                </gauge:LinearAxis.Ranges>
            </gauge:LinearAxis>
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    ShowAxisLine

    Gets or sets a value indicating whether to shows or hides the axis line.

    Declaration
    public bool ShowAxisLine { 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 ShowAxisLine is true, the axis line will be rendered, otherwise not rendered.

    Examples
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis ShowAxisLine="False" />
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    ShowLabels

    Gets or sets a value indicating whether to shows or hides 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>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis ShowLabels="False" />
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    ShowTicks

    Gets or sets a value indicating whether to shows or hides the axis tick lines.

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

    true if axis line ticks 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 axis ticks will be rendered, otherwise not rendered.

    Examples
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis ShowTicks="False" />
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    TickOffset

    Gets or sets the value to adjusts the axis ticks position from the axis line.

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

    It defines distance between axis and ticks in pixels. Its default value is 0.

    Remarks

    It is not applicable for Cross position.

    Examples
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis TickOffset="50" />
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>

    TickPosition

    Gets or sets the value that indicates the position of the ticks below/above the axis line for a horizontal linear gauge, or to the right/left of the axis line for a vertical linear gauge.

    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>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis TickPosition="Outside" />
        </gauge:SfLinearGauge.Axis>
    </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

    true if use range color is enabled; otherwise, false.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>
        <gauge:SfLinearGauge.Axis>
            <gauge:LinearAxis UseRangeColorForAxis="True">
                <gauge:LinearAxis.Ranges>
                    <gauge:LinearGaugeRange StartValue="0"
                                            EndValue="100"
                                            RangePosition="Cross"
                                            StartWidth="5"
                                            EndWidth="5">
                        <gauge:LinearGaugeRange.GradientStops>
                            <gauge:GaugeGradientStop Value="0"
                                                     Color="Green" />
                            <gauge:GaugeGradientStop Value="50"
                                                     Color="Orange" />
                            <gauge:GaugeGradientStop Value="100"
                                                     Color="Red" />
                        </gauge:LinearGaugeRange.GradientStops>
                    </gauge:LinearGaugeRange>
                </gauge:LinearAxis.Ranges>
            </gauge:LinearAxis>
        </gauge:SfLinearGauge.Axis>
    </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#
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <local:LinearAxisExt Minimum="1"
                                 Maximum="10000">
                <local:LinearAxisExt.MarkerPointers>
                    <gauge:LinearShapePointer Value="1000" 
                                        IsInteractive="True"
                                        VerticalAnchor="End"
                                        OffsetPoint="0,-5"/>
                </local:LinearAxisExt.MarkerPointers>
            </local:LinearAxisExt>
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>
    public class LinearAxisExt : LinearAxis
    {
        int labelsCount;
        public override List<AxisLabelData> GenerateVisibleLabels()
        {
            List<AxisLabelData> labelInfos = new List<AxisLabelData>();
            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
                AxisLabelData label = new AxisLabelData()
                {
                    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 interval and range.

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

    The visible label collection.

    Examples
    • XAML
    • C#
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <local:LinearAxisExt Minimum="1"
                                 Maximum="10000">
                <local:LinearAxisExt.MarkerPointers>
                    <gauge:LinearShapePointer Value="1000" 
                                        IsInteractive="True"
                                        VerticalAnchor="End"
                                        OffsetPoint="0,-5"/>
                </local:LinearAxisExt.MarkerPointers>
            </local:LinearAxisExt>
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>
    public class LinearAxisExt : LinearAxis
    {
        int labelsCount;
        public override List<AxisLabelData> GenerateVisibleLabels()
        {
            List<AxisLabelData> labelInfos = new List<AxisLabelData>();
            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
                AxisLabelData label = new AxisLabelData()
                {
                    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));
        }
    }

    MeasureOverride(Size)

    Measures the size in layout required for child elements.

    Declaration
    protected override Size MeasureOverride(Size availableSize)
    Parameters
    Type Name Description
    Windows.Foundation.Size availableSize

    This size give to child elements.

    Returns
    Type Description
    Windows.Foundation.Size

    Return child element size.

    OnApplyTemplate()

    Invoke to render SfLinearGauge class.

    Declaration
    protected override void OnApplyTemplate()

    OnCreateAutomationPeer()

    Declaration
    protected override AutomationPeer OnCreateAutomationPeer()
    Returns
    Type
    Microsoft.UI.Xaml.Automation.Peers.AutomationPeer

    ValueToFactor(Double)

    Converts axis value to factor.

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

    The axis value to convert as factor.

    Returns
    Type Description
    System.Double

    Factor of the provided axis value.

    Examples
    • XAML
    • C#
    <gauge:SfLinearGauge>
        <gauge:SfLinearGauge.Axis>
            <local:LinearAxisExt Minimum="1"
                                 Maximum="10000">
                <local:LinearAxisExt.MarkerPointers>
                    <gauge:LinearShapePointer Value="1000" 
                                        IsInteractive="True"
                                        VerticalAnchor="End"
                                        OffsetPoint="0,-5"/>
                </local:LinearAxisExt.MarkerPointers>
            </local:LinearAxisExt>
        </gauge:SfLinearGauge.Axis>
    </gauge:SfLinearGauge>
    public class LinearAxisExt : LinearAxis
    {
        int labelsCount;
        public override List<AxisLabelData> GenerateVisibleLabels()
        {
            List<AxisLabelData> labelInfos = new List<AxisLabelData>();
            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
                AxisLabelData label = new AxisLabelData()
                {
                    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));
        }
    }
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved