menu

MAUI

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

    Show / Hide Table of Contents

    Class ChartTrackballBehavior

    Enables the trackball in the Syncfusion.Maui.Charts.ChartTrackballBehavior.CartesianChart.

    Inheritance
    System.Object
    ChartBehavior
    ChartTrackballBehavior
    Namespace: Syncfusion.Maui.Charts
    Assembly: Syncfusion.Maui.Charts.dll
    Syntax
    public class ChartTrackballBehavior : ChartBehavior, IMarkerDependent, IThemeElement

    Constructors

    ChartTrackballBehavior()

    Initializes a new instance of the ChartTrackballBehavior class.

    Declaration
    public ChartTrackballBehavior()

    Fields

    ActivationModeProperty

    Identifies the ActivationMode bindable property.

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

    DisplayModeProperty

    Identifies the DisplayMode bindable property.

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

    LabelStyleProperty

    Identifies the LabelStyle bindable property.

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

    LineStyleProperty

    Identifies the LineStyle bindable property.

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

    MarkerSettingsProperty

    Identifies the MarkerSettings bindable property.

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

    ShowLabelProperty

    Identifies the ShowLabel bindable property.

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

    ShowLineProperty

    Identifies the ShowLine bindable property.

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

    ShowMarkersProperty

    Identifies the ShowMarkers bindable property.

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

    Properties

    ActivationMode

    Gets or sets the value that indicates whether to activate trackball based on the specified touch mode.

    Declaration
    public ChartTrackballActivationMode ActivationMode { get; set; }
    Property Value
    Type Description
    ChartTrackballActivationMode

    It accepts ChartTrackballActivationMode values, with the default value being TouchMove for Windows and Mac, and LongPress for Android and iOS.

    Remarks

    On Windows, LongPress gesture is supported only through touch input, not with a mouse. Consequently, when ActivationMode is set to LongPress, the trackball activates only via touch interaction, not with a mouse interaction.

    Examples
    • Xaml
    • C#
        <chart:SfCartesianChart>
    
              <!--omitted for brevity-->
    
              <chart:SfCartesianChart.TrackballBehavior>
                  <chart:ChartTrackballBehavior ActivationMode="TouchMove"/>
              </chart:SfCartesianChart.TrackballBehavior>
    
              <chart:LineSeries ItemsSource="{Binding Data}"
                                XBindingPath="XValue"
                                YBindingPath="YValue"/>
    
        </chart:SfCartesianChart>
        SfCartesianChart chart = new SfCartesianChart();
        ViewModel viewModel = new ViewModel();
    
       // omitted for brevity 
       chart.TrackballBehavior = new ChartTrackballBehavior()
       {
           ActivationMode = ChartTrackballActivationMode.TouchMove,
       };
    
        LineSeries series = new LineSeries();
        series.ItemsSource = viewModel.Data;
        series.XBindingPath = "XValue";
        series.YBindingPath = "YValue";
        chart.Series.Add(series);

    DisplayMode

    Gets or sets display mode of trackball labels.

    By default, labels for all the series under the current point index value will be shown.

    Declaration
    public LabelDisplayMode DisplayMode { get; set; }
    Property Value
    Type Description
    LabelDisplayMode

    Defaults to FloatAllPoints

    Examples
    • Xaml
    • C#
        <chart:SfCartesianChart>
    
              <!--omitted for brevity-->
    
              <chart:SfCartesianChart.TrackballBehavior>
                  <chart:ChartTrackballBehavior DisplayMode="NearestPoint"/>
              </chart:SfCartesianChart.TrackballBehavior>
    
              <chart:LineSeries ItemsSource="{Binding Data}"
                                XBindingPath="XValue"
                                YBindingPath="YValue"/>
    
        </chart:SfCartesianChart>
        SfCartesianChart chart = new SfCartesianChart();
        ViewModel viewModel = new ViewModel();
    
       // omitted for brevity
       chart.TrackballBehavior = new ChartTrackballBehavior()
       {
           DisplayMode = LabelDisplayMode.NearestPoint,
       };
    
        LineSeries series = new LineSeries();
        series.ItemsSource = viewModel.Data;
        series.XBindingPath = "XValue";
        series.YBindingPath = "YValue";
        chart.Series.Add(series);

    LabelStyle

    Gets or sets the value to customize the appearance of trackball labels.

    Declaration
    public ChartLabelStyle LabelStyle { get; set; }
    Property Value
    Type
    ChartLabelStyle
    Remarks

    To customize the trackball label appearance, you need to create an instance of the ChartLabelStyle class and set to the LabelStyle property.

    Null values are invalid.

    Examples
    • Xaml
    • C#
        <chart:SfCartesianChart>
    
              <!--omitted for brevity-->
    
              <chart:SfCartesianChart.TrackballBehavior>
                  <chart:ChartTrackballBehavior>
                      <chart:ChartTrackballBehavior.LabelStyle>
                          <chart:ChartLabelStyle TextColor="Red" FontSize="14"/>
                      </chart:ChartTrackballBehavior.LabelStyle>
           </chart:ChartTrackballBehavior>
              </chart:SfCartesianChart.TrackballBehavior>
    
              <chart:LineSeries ItemsSource="{Binding Data}"
                                XBindingPath="XValue"
                                YBindingPath="YValue"/>
    
        </chart:SfCartesianChart>
        SfCartesianChart chart = new SfCartesianChart();
        ViewModel viewModel = new ViewModel();
    
       // omitted for brevity 
       var labelStyle = new ChartLabelStyle()
       {
           TextColor = Colors.Red, FontSize = 12,
       };
       chart.TrackballBehavior = new ChartTrackballBehavior()
       {
           LabelStyle = labelStyle,
       };
    
        LineSeries series = new LineSeries();
        series.ItemsSource = viewModel.Data;
        series.XBindingPath = "XValue";
        series.YBindingPath = "YValue";
        chart.Series.Add(series);

    LineStyle

    Gets or sets the value to customize the appearance of the trackball line.

    Declaration
    public ChartLineStyle LineStyle { get; set; }
    Property Value
    Type
    ChartLineStyle
    Remarks

    To customize the trackball line appearance, you need to create an instance of the ChartLineStyle class and set to the LineStyle property.

    Null values are invalid.

    Examples
    • Xaml
    • C#
        <chart:SfCartesianChart>
    
              <!--omitted for brevity-->
    
              <chart:SfCartesianChart.TrackballBehavior>
                  <chart:ChartTrackballBehavior>
                      <chart:ChartTrackballBehavior.LineStyle>
                          <chart:ChartLineStyle Stroke = "Red" StrokeWidth="2"/>
                      </chart:ChartTrackballBehavior.LineStyle>
           </chart:ChartTrackballBehavior>
              </chart:SfCartesianChart.TrackballBehavior>
    
              <chart:LineSeries ItemsSource="{Binding Data}"
                                XBindingPath="XValue"
                                YBindingPath="YValue"/>
    
        </chart:SfCartesianChart>
        SfCartesianChart chart = new SfCartesianChart();
        ViewModel viewModel = new ViewModel();
    
       // omitted for brevity 
       var lineStyle = new ChartLineStyle()
       {
           Stroke = new SolidColorBrush(Colors.Red), StrokeWidth = 2,
       };
       chart.TrackballBehavior = new ChartTrackballBehavior()
       {
           LineStyle = lineStyle,
       };
    
        LineSeries series = new LineSeries();
        series.ItemsSource = viewModel.Data;
        series.XBindingPath = "XValue";
        series.YBindingPath = "YValue";
        chart.Series.Add(series);

    MarkerSettings

    Gets or sets the option for customize the trackball markers.

    Declaration
    public ChartMarkerSettings MarkerSettings { get; set; }
    Property Value
    Type
    ChartMarkerSettings
    Examples
    • Xaml
    • C#
        <chart:SfCartesianChart>
    
              <!--omitted for brevity-->
    
              <chart:SfCartesianChart.TrackballBehavior>
                  <chart:ChartTrackballBehavior>
                      <chart:ChartTrackballBehavior.MarkerSettings>
                          <chart:ChartMarkerSettings Height = "10" Width="10" Fill="Red"/>
                      </chart:ChartTrackballBehavior.MarkerSettings>
           </chart:ChartTrackballBehavior>
              </chart:SfCartesianChart.TrackballBehavior>
    
              <chart:LineSeries ItemsSource="{Binding Data}"
                                XBindingPath="XValue"
                                YBindingPath="YValue"/>
    
        </chart:SfCartesianChart>
        SfCartesianChart chart = new SfCartesianChart();
        ViewModel viewModel = new ViewModel();
    
       // omitted for brevity 
       var markerSettings = new ChartMarkerSettings()
       {
           Height = 10, Width = 10,
           Fill = new SolidColorBrush(Colors.Red),
       };
       chart.TrackballBehavior = new ChartTrackballBehavior()
       {
           MarkerSettings = markerSettings,
       };
    
        LineSeries series = new LineSeries();
        series.ItemsSource = viewModel.Data;
        series.XBindingPath = "XValue";
        series.YBindingPath = "YValue";
        chart.Series.Add(series);

    ShowLabel

    Gets or sets the value that indicates whether to show label for the trackball.

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

    It accepts bool values and its default value is True.

    Examples
    • Xaml
    • C#
        <chart:SfCartesianChart>
    
              <!--omitted for brevity-->
    
              <chart:SfCartesianChart.TrackballBehavior>
                  <chart:ChartTrackballBehavior ShowLabel="False"/>
              </chart:SfCartesianChart.TrackballBehavior>
    
              <chart:LineSeries ItemsSource="{Binding Data}"
                                XBindingPath="XValue"
                                YBindingPath="YValue"/>
    
        </chart:SfCartesianChart>
        SfCartesianChart chart = new SfCartesianChart();
        ViewModel viewModel = new ViewModel();
    
       // omitted for brevity 
       chart.TrackballBehavior = new ChartTrackballBehavior()
       {
           ShowLabel = false,
       };
    
        LineSeries series = new LineSeries();
        series.ItemsSource = viewModel.Data;
        series.XBindingPath = "XValue";
        series.YBindingPath = "YValue";
        chart.Series.Add(series);

    ShowLine

    Gets or sets the value that indicates whether to show the trackball line.

    Declaration
    public bool ShowLine { get; set; }
    Property Value
    Type
    System.Boolean
    Examples
    • Xaml
    • C#
        <chart:SfCartesianChart>
    
              <!--omitted for brevity-->
    
              <chart:SfCartesianChart.TrackballBehavior>
                  <chart:ChartTrackballBehavior ShowLine="False"/>
              </chart:SfCartesianChart.TrackballBehavior>
    
              <chart:LineSeries ItemsSource="{Binding Data}"
                                XBindingPath="XValue"
                                YBindingPath="YValue"/>
    
        </chart:SfCartesianChart>
        SfCartesianChart chart = new SfCartesianChart();
        ViewModel viewModel = new ViewModel();
    
       // omitted for brevity 
       chart.TrackballBehavior = new ChartTrackballBehavior()
       {
           ShowLine = false,
       };
    
        LineSeries series = new LineSeries();
        series.ItemsSource = viewModel.Data;
        series.XBindingPath = "XValue";
        series.YBindingPath = "YValue";
        chart.Series.Add(series);

    ShowMarkers

    Gets or sets the value that indicates whether to show markers for the trackball.

    Declaration
    public bool ShowMarkers { get; set; }
    Property Value
    Type
    System.Boolean
    Examples
    • Xaml
    • C#
        <chart:SfCartesianChart>
    
              <!--omitted for brevity-->
    
              <chart:SfCartesianChart.TrackballBehavior>
                  <chart:ChartTrackballBehavior ShowMarkers="False"/>
              </chart:SfCartesianChart.TrackballBehavior>
    
              <chart:LineSeries ItemsSource="{Binding Data}"
                                XBindingPath="XValue"
                                YBindingPath="YValue"/>
    
        </chart:SfCartesianChart>
        SfCartesianChart chart = new SfCartesianChart();
        ViewModel viewModel = new ViewModel();
    
       // omitted for brevity 
       chart.TrackballBehavior = new ChartTrackballBehavior()
       {
           ShowMarkers = false,
       };
    
        LineSeries series = new LineSeries();
        series.ItemsSource = viewModel.Data;
        series.XBindingPath = "XValue";
        series.YBindingPath = "YValue";
        chart.Series.Add(series);

    Methods

    Hide()

    Hides the trackball that is visible in the chart.

    Declaration
    public void Hide()

    LabelsGenerated(List<TrackballPointInfo>)

    Invokes when the trackball is moved from one data point to another. This helps to customize the trackball label and marker based on the condition.

    Declaration
    protected virtual void LabelsGenerated(List<TrackballPointInfo> pointInfos)
    Parameters
    Type Name Description
    System.Collections.Generic.List<TrackballPointInfo> pointInfos

    OnBindingContextChanged()

    Declaration
    protected override void OnBindingContextChanged()

    OnParentSet()

    Declaration
    protected override void OnParentSet()

    OnTouchDown(ChartBase, Single, Single)

    Declaration
    protected override void OnTouchDown(ChartBase chart, float pointX, float pointY)
    Parameters
    Type Name Description
    ChartBase chart
    System.Single pointX
    System.Single pointY
    Overrides
    ChartBehavior.OnTouchDown(ChartBase, Single, Single)

    OnTouchMove(ChartBase, Single, Single)

    Declaration
    protected override void OnTouchMove(ChartBase chart, float pointX, float pointY)
    Parameters
    Type Name Description
    ChartBase chart
    System.Single pointX
    System.Single pointY
    Overrides
    ChartBehavior.OnTouchMove(ChartBase, Single, Single)

    OnTouchUp(ChartBase, Single, Single)

    Declaration
    protected override void OnTouchUp(ChartBase chart, float pointX, float pointY)
    Parameters
    Type Name Description
    ChartBase chart
    System.Single pointX
    System.Single pointY
    Overrides
    ChartBehavior.OnTouchUp(ChartBase, Single, Single)

    Show(Single, Single)

    Activate the trackball at the nearest point to the specified location.

    Declaration
    public void Show(float pointX, float pointY)
    Parameters
    Type Name Description
    System.Single pointX
    System.Single pointY
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved