Class ChartTooltipBehavior
ChartTooltipBehavior is often used to specify extra information when the mouse pointer moved over an element.
Inherited Members
Namespace: Syncfusion.UI.Xaml.Charts
Assembly: Syncfusion.Chart.WinUI.dll
Syntax
public class ChartTooltipBehavior : ChartBehavior
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:
LabelStyle - To customize the appearance of the tooltip label, refer to the LabelStyle property.
Style - To customize the appearance of tooltips, refer to the Style property.
Duration - To show the tooltip with delay and indicate how long the tooltip will be visible, refer to the InitialShowDelay, and Duration properties.
EnableAnimation - To indicate the animation for the tooltip, refer to the EnableAnimation property.
Examples
<chart:SfCartesianChart>
<!--omitted for brevity-->
<chart:SfCartesianChart.TooltipBehavior>
<chart:ChartTooltipBehavior/>
</chart:SfCartesianChart.TooltipBehavior>
<chart:LineSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
EnableTooltip="True"/>
</chart:SfCartesianChart>
Constructors
ChartTooltipBehavior()
Initializes a new instance of the ChartTooltipBehavior.
Declaration
public ChartTooltipBehavior()
Fields
DurationProperty
Identifies the Duration dependency property.
Declaration
public static readonly DependencyProperty DurationProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the Duration dependency property. |
EnableAnimationProperty
Identifies the EnableAnimation dependency property.
Declaration
public static readonly DependencyProperty EnableAnimationProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the EnableAnimation dependency property. |
HorizontalAlignmentProperty
Identifies the HorizontalAlignment dependency property.
Declaration
public static readonly DependencyProperty HorizontalAlignmentProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the HorizontalAlignment dependency property. |
HorizontalOffsetProperty
Identifies the HorizontalOffset dependency property.
Declaration
public static readonly DependencyProperty HorizontalOffsetProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the HorizontalOffset dependency property. |
InitialShowDelayProperty
Identifies the InitialShowDelay dependency property.
Declaration
public static readonly DependencyProperty InitialShowDelayProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the InitialShowDelay dependency property. |
LabelStyleProperty
Identifies the LabelStyle dependency property.
Declaration
public static readonly DependencyProperty LabelStyleProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the LabelStyle dependency property. |
StyleProperty
Identifies the Style dependency property.
Declaration
public static readonly DependencyProperty StyleProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the Style dependency property. |
VerticalAlignmentProperty
Identifies the VerticalAlignment dependency property.
Declaration
public static readonly DependencyProperty VerticalAlignmentProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the VerticalAlignment dependency property. |
VerticalOffsetProperty
Identifies the VerticalOffset dependency property.
Declaration
public static readonly DependencyProperty VerticalOffsetProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the VerticalOffset dependency property. |
Properties
Duration
Gets or sets the value that indicates how long the tooltip will be visible.
Declaration
public int Duration { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | It accepts the integer values and the default value is 1000 milliseconds. |
Remarks
This property specifies how long a tooltip remains visible while the user moves the mouse pointer over the chart series area.
Examples
<chart:SfCartesianChart>
<!--omitted for brevity-->
<chart:SfCartesianChart.TooltipBehavior>
<chart:ChartTooltipBehavior Duration ="1500"/>
</chart:SfCartesianChart.TooltipBehavior>
<chart:LineSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
EnableTooltip="True"/>
</chart:SfCartesianChart>
EnableAnimation
Gets or sets the value that indicates whether the animation is enabled when the tooltip is displayed.
Declaration
public bool EnableAnimation { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | It accepts the bool values and the default value is |
Examples
<chart:SfCartesianChart>
<!--omitted for brevity-->
<chart:SfCartesianChart.TooltipBehavior>
<chart:ChartTooltipBehavior EnableAnimation="True"/>
</chart:SfCartesianChart.TooltipBehavior>
<chart:LineSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
EnableTooltip="True"/>
</chart:SfCartesianChart>
HorizontalAlignment
Gets or sets the horizontal alignment for the tooltip.
Declaration
public HorizontalAlignment HorizontalAlignment { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.UI.Xaml.HorizontalAlignment | It accepts the Microsoft.UI.Xaml.HorizontalAlignment value and the default value is Microsoft.UI.Xaml.HorizontalAlignment.Center. |
Examples
<chart:SfCartesianChart>
<!--omitted for brevity-->
<chart:SfCartesianChart.TooltipBehavior>
<chart:ChartTooltipBehavior HorizontalAlignment ="Right"/>
</chart:SfCartesianChart.TooltipBehavior>
<chart:LineSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
EnableTooltip="True"/>
</chart:SfCartesianChart>
HorizontalOffset
Gets or sets the value to position the tooltip horizontally.
Declaration
public double HorizontalOffset { get; set; }
Property Value
Type | Description |
---|---|
System.Double | It accepts the double values and the default value is 0. |
Remarks
The HorizontalOffset and the VerticalOffset property values provide additional adjustment to position the tooltip.
Examples
<chart:SfCartesianChart>
<!--omitted for brevity-->
<chart:SfCartesianChart.TooltipBehavior>
<chart:ChartTooltipBehavior HorizontalOffset ="5"/>
</chart:SfCartesianChart.TooltipBehavior>
<chart:LineSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
EnableTooltip="True"/>
</chart:SfCartesianChart>
InitialShowDelay
Gets or sets the delay in milliseconds to show the tooltip once the user interacts with the series.
Declaration
public int InitialShowDelay { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | It accepts the integer values and the default value is 0 milliseconds. |
Remarks
It specifies the amount of time the user must wait in milliseconds before the tooltip appears when hovering the mouse or touching a chart series.
Note: Initial delay only works for the positive values.
Examples
<chart:SfCartesianChart>
<!--omitted for brevity-->
<chart:SfCartesianChart.TooltipBehavior>
<chart:ChartTooltipBehavior InitialShowDelay ="500"/>
</chart:SfCartesianChart.TooltipBehavior>
<chart:LineSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
EnableTooltip="True"/>
</chart:SfCartesianChart>
LabelStyle
Gets or sets the style to customize the appearance of tooltip label.
Declaration
public Style LabelStyle { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.UI.Xaml.Style | It accepts |
Examples
<chart:SfCartesianChart>
<chart:SfCartesianChart.TooltipBehavior>
<chart:ChartTooltipBehavior>
<chart:ChartTooltipBehavior.LabelStyle>
<Style TargetType = "TextBlock" >
<Setter Property ="FontSize" Value="14"/>
<Setter Property ="Foreground" Value="Red"/>
<Setter Property ="FontStyle" Value="Italic"/>
</Style>
</chart:ChartTooltipBehavior.LabelStyle>
</chart:ChartTooltipBehavior>
</chart:SfCartesianChart.TooltipBehavior>
<chart:LineSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
EnableTooltip="True"/>
</chart:SfCartesianChart>
Style
Gets or sets the style to customize the appearance of tooltip.
Declaration
public Style Style { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.UI.Xaml.Style | It accepts |
Remarks
It's used to customize the fill and stroke of the tooltip.
Examples
<chart:SfCartesianChart>
<chart:SfCartesianChart.TooltipBehavior>
<chart:ChartTooltipBehavior>
<chart:ChartTooltipBehavior.Style>
<Style TargetType = "Path">
<Setter Property="Stroke" Value="Black" />
<Setter Property ="Fill" Value="LightGreen" />
</Style>
</chart:ChartTooltipBehavior.Style>
</chart:ChartTooltipBehavior>
</chart:SfCartesianChart.TooltipBehavior>
<chart:LineSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
EnableTooltip="True"/>
</chart:SfCartesianChart>
VerticalAlignment
Gets or sets the vertical alignment for the tooltip.
Declaration
public VerticalAlignment VerticalAlignment { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.UI.Xaml.VerticalAlignment | It accepts the Microsoft.UI.Xaml.VerticalAlignment value and the default value is Microsoft.UI.Xaml.VerticalAlignment.Top. |
Examples
<chart:SfCartesianChart>
<!--omitted for brevity-->
<chart:SfCartesianChart.TooltipBehavior>
<chart:ChartTooltipBehavior VerticalAlignment ="Center"/>
</chart:SfCartesianChart.TooltipBehavior>
<chart:LineSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
EnableTooltip="True"/>
</chart:SfCartesianChart>
VerticalOffset
Gets or sets the value to position the tooltip vertically.
Declaration
public double VerticalOffset { get; set; }
Property Value
Type | Description |
---|---|
System.Double | It accepts the double values and the default value is 0. |
Remarks
The HorizontalOffset and the VerticalOffset property values provide additional adjustment to position the tooltip.
Examples
<chart:SfCartesianChart>
<!--omitted for brevity-->
<chart:SfCartesianChart.TooltipBehavior>
<chart:ChartTooltipBehavior VerticalOffset ="5"/>
</chart:SfCartesianChart.TooltipBehavior>
<chart:LineSeries ItemsSource="{Binding Data}"
XBindingPath="XValue"
YBindingPath="YValue"
EnableTooltip="True"/>
</chart:SfCartesianChart>