Class ChartTooltipBehavior
ChartTooltipBehavior is often used to specify extra information when the mouse pointer moved over an element.
Inherited Members
Namespace: Syncfusion.Maui.Charts
Assembly: Syncfusion.Maui.Charts.dll
Syntax
public class ChartTooltipBehavior : ChartBehavior, IParentThemeElement, IThemeElement
Remarks
The tooltip displays information while tapping or mouse hovering on the segment. To display the tooltip on the chart, you need to set the EnableTooltip property as true in chart series.
Create an instance of the ChartTooltipBehavior and set it to the chart’s TooltipBehavior property.
It provides the following options to customize the appearance of the tooltip:
Label Customization - To customize the appearance of the tooltip, refer to the TextColor, FontSize, FontAttributes, and FontFamily properties.
Duration - To show the tooltip with delay and indicate how long the tooltip will be visible, refer to the Duration property.
Examples
<chart:SfCartesianChart>
<chart:SfCartesianChart.ChartBehaviors>
<chart:ChartTooltipBehavior />
</chart:SfCartesianChart.ChartBehaviors>
</chart:SfCartesianChart>
Constructors
ChartTooltipBehavior()
Initializes a new instance of the ChartTooltipBehavior class.
Declaration
public ChartTooltipBehavior()
Fields
BackgroundProperty
Identifies the Background bindable property.
Declaration
public static readonly BindableProperty BackgroundProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
DurationProperty
Identifies the Duration bindable property.
Declaration
public static readonly BindableProperty DurationProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
FontAttributesProperty
Identifies the FontAttributes bindable property.
Declaration
public static readonly BindableProperty FontAttributesProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
FontFamilyProperty
Identifies the FontFamily bindable property.
Declaration
public static readonly BindableProperty FontFamilyProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
FontSizeProperty
Identifies the FontSize bindable property.
Declaration
public static readonly BindableProperty FontSizeProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
MarginProperty
Identifies the Margin bindable property.
Declaration
public static readonly BindableProperty MarginProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
TextColorProperty
Identifies the TextColor bindable property.
Declaration
public static readonly BindableProperty TextColorProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Properties
Background
Gets or sets the brush value to customize the tooltip background.
Declaration
public Brush Background { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Controls.Brush | It accepts the Microsoft.Maui.Controls.Brush value and the default value is Black. |
Examples
<chart:SfCartesianChart>
<!--omitted for brevity-->
<chart:SfCartesianChart.TooltipBehavior>
<chart:ChartTooltipBehavior Background ="Red"/>
</chart:SfCartesianChart.TooltipBehavior>
<chart:LineSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
EnableTooltip="True"/>
</chart:SfCartesianChart>
Duration
Gets or sets a value to specify the duration time in seconds for which tooltip will be displayed.
Declaration
public int Duration { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | It accepts the integer values and the default value is 2. |
Examples
<chart:SfCartesianChart>
<!--omitted for brevity-->
<chart:SfCartesianChart.TooltipBehavior>
<chart:ChartTooltipBehavior Duration ="3"/>
</chart:SfCartesianChart.TooltipBehavior>
<chart:LineSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
EnableTooltip="True"/>
</chart:SfCartesianChart>
FontAttributes
Gets or sets a value to specify the FontAttributes for the tooltip label.
Declaration
public FontAttributes FontAttributes { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Controls.FontAttributes | It accepts Microsoft.Maui.Controls.FontAttributes values and the default value is Microsoft.Maui.Controls.FontAttributes.None. |
FontFamily
Gets or sets a value to specify the FontFamily for the tooltip label.
Declaration
public string FontFamily { get; set; }
Property Value
Type | Description |
---|---|
System.String | It accepts string values. |
FontSize
Gets or sets a value to change the label's text size.
Declaration
public float FontSize { get; set; }
Property Value
Type | Description |
---|---|
System.Single | It accepts the float values and the default value is 14. |
Examples
<chart:SfCartesianChart>
<!--omitted for brevity-->
<chart:SfCartesianChart.TooltipBehavior>
<chart:ChartTooltipBehavior FontSize ="20"/>
</chart:SfCartesianChart.TooltipBehavior>
<chart:LineSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
EnableTooltip="True"/>
</chart:SfCartesianChart>
Margin
Gets or sets a thickness value to adjust the tooltip margin.
Declaration
public Thickness Margin { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Thickness | It accepts the Microsoft.Maui.Thickness values and the default value is 0. |
Examples
<chart:SfCartesianChart>
<!--omitted for brevity-->
<chart:SfCartesianChart.TooltipBehavior>
<chart:ChartTooltipBehavior Margin ="5"/>
</chart:SfCartesianChart.TooltipBehavior>
<chart:LineSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
EnableTooltip="True"/>
</chart:SfCartesianChart>
TextColor
Gets or sets the color value to customize the text color of the tooltip label.
Declaration
public Color TextColor { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Graphics.Color | It accepts the Microsoft.Maui.Graphics.Color values and the default value is White. |
Examples
<chart:SfCartesianChart>
<!--omitted for brevity-->
<chart:SfCartesianChart.TooltipBehavior>
<chart:ChartTooltipBehavior TextColor ="Red"/>
</chart:SfCartesianChart.TooltipBehavior>
<chart:LineSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
EnableTooltip="True"/>
</chart:SfCartesianChart>
Methods
Hide()
Hides the tooltip view.
Declaration
public void Hide()
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
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
Show(Single, Single, Boolean)
Method used to show tooltip view at nearest datapoint for given x and y value.
Declaration
public void Show(float pointX, float pointY, bool canAnimate)
Parameters
Type | Name | Description |
---|---|---|
System.Single | pointX | |
System.Single | pointY | |
System.Boolean | canAnimate |