.NET MAUI CartesianChart Tooltip
The Telerik UI for .NET MAUI CartesianChart displays a tooltip with information about a data point when you add a ChartTooltipBehavior to the ChartBehaviors collection of the chart. The tooltip works with all Cartesian series: AreaSeries, BarSeries, CandlestickSeries, LineSeries, OhlcSeries, PointSeries, SplineAreaSeries, and SplineSeries.

Enable the Tooltip
The following example demonstrates how to add a ChartTooltipBehavior to the ChartBehaviors collection of the RadCartesianChart. The tooltip opens when you tap a bar and is placed at the data point.
- Define the
RadCartesianChartwith aChartTooltipBehaviorin XAML:
<charts:RadCartesianChart Grid.Row="1">
<charts:RadCartesianChart.BindingContext>
<local:CartesianTooltipViewModel />
</charts:RadCartesianChart.BindingContext>
<charts:RadCartesianChart.ChartBehaviors>
<charts:ChartTooltipBehavior x:Name="tooltipBehavior"
TriggerMode="Tap"
PlacementMode="DataPoint" />
</charts:RadCartesianChart.ChartBehaviors>
<charts:RadCartesianChart.Axes>
<charts:CategoricalAxis />
<charts:NumericalAxis />
</charts:RadCartesianChart.Axes>
<charts:RadCartesianChart.Series>
<charts:BarSeries DisplayName="Revenue"
HorizontalBinding="Category"
VerticalBinding="Value"
ItemsSource="{Binding Data}" />
</charts:RadCartesianChart.Series>
</charts:RadCartesianChart>
- Add the
chartsnamespace. Thelocalnamespace used in the examples points to the namespace in which the data model and theViewModelare defined.
xmlns:charts="clr-namespace:Telerik.Maui.Controls.Charts;assembly=Telerik.Maui.Controls"
- Define the data model. The
CartesianTooltipInforecord is used to pass additional data to the tooltip through theTooltipOpeningevent:
public sealed record CartesianTooltipPoint(string Category, double Value, double Target, string Region, int Units);
public sealed record CartesianTooltipInfo(string VsTarget, Color TrendColor);
- Define the
ViewModel:
public class CartesianTooltipViewModel
{
public ObservableCollection<CartesianTooltipPoint> Data { get; } = new ObservableCollection<CartesianTooltipPoint>
{
new CartesianTooltipPoint("Jan", 42, 50, "North America", 1260),
new CartesianTooltipPoint("Feb", 58, 52, "Europe", 1740),
new CartesianTooltipPoint("Mar", 37, 45, "Asia Pacific", 1110),
new CartesianTooltipPoint("Apr", 71, 60, "North America", 2130),
new CartesianTooltipPoint("May", 64, 65, "Europe", 1920),
new CartesianTooltipPoint("Jun", 88, 70, "Latin America", 2640),
};
}
For a runnable example with the CartesianChart Tooltip scenarios, go to the SDKBrowser Demo Application and navigate to the Charts > Tooltip category.
Display the Tooltip
To open the tooltip, set the TriggerMode (enum of type Telerik.Maui.Controls.Charts.ChartTooltipTriggerMode) property of the ChartTooltipBehavior. The available options are:
Tap—The tooltip opens when you tap a data point. Default on mobile platforms.Hover—The tooltip opens when you hover over a data point. Default on desktop platforms.Hold—The tooltip opens when you press and hold a data point.
To define a delay before the tooltip is shown or hidden, use the following properties of the ChartTooltipBehavior:
HoverDelay(int)—Defines the delay in milliseconds before the tooltip is shown. Applies only to theHovertrigger mode and only to the initial show. The default value is0.HideDelay(int)—Defines the delay in milliseconds before the tooltip is hidden. For theHoldtrigger mode, the delay starts when the press is released. This property has no effect for theHovertrigger mode.
Position the Tooltip
To position the tooltip, use the PlacementMode (enum of type Telerik.Maui.Controls.Charts.ChartTooltipPlacementMode) property. The available options are:
Pointer(default)—Places the tooltip at the pointer or tap position.DataPoint—Places the tooltip at a fixed position relative to the data point.
Format the Tooltip Label
To format the value displayed in the tooltip, use the TooltipLabelFormat (string) property of the ChartTooltipBehavior. The format string is applied to the value of the data point. For example, to display a percentage with two decimal places, set the TooltipLabelFormat to "{0:P2}".
Events
The ChartTooltipBehavior exposes the TooltipOpening event, which is raised before the tooltip opens. The TooltipOpening event provides two parameters:
- The sender, which is of type object.
- The
ChartTooltipOpeningEventArgs, which provides information about theSeries,SeriesIndex,PointIndex,DataItem,Value,Category,FormattedValue, andSeriesColorproperties, and theAdditionalDataproperty.
The following example calculates the difference between the actual value and the target value, picks a trend color, and passes both to the tooltip through the AdditionalData property. The data is then displayed by the TooltipContentTemplate:
private void OnTooltipOpening(object sender, ChartTooltipOpeningEventArgs e)
{
if (e.DataItem is not CartesianTooltipPoint point)
{
return;
}
double percentage = ((point.Value - point.Target) / point.Target) * 100.0;
string sign = percentage >= 0.0 ? "+" : string.Empty;
string formattedPercentage = percentage.ToString("0", CultureInfo.InvariantCulture);
Color trendColor = percentage >= 0.0 ? Color.FromArgb("#00897B") : Color.FromArgb("#A30111");
e.AdditionalData = new CartesianTooltipInfo($"{sign}{formattedPercentage}% vs target", trendColor);
}
Styling the Tooltip
Use the TooltipStyle property of the ChartTooltipBehavior to apply a Style with target type ChartTooltip. Set the following properties to style the tooltip's appearance:
TextColor(Color)—Defines the color of the tooltip text.FontSize(double)—Defines the font size of the tooltip text.FontFamily(string)—Defines the font family of the tooltip text.FontAttributes(FontAttributes)—Defines the font attributes of the tooltip text.BackgroundColor(Color)—Defines the background color of the tooltip.- Border properties (
BorderColor,BorderBrushBorderThickness,CornerRadius)—Define the border of the tooltip. ContentPadding(Thickness)—Defines the padding of the tooltip content.
The following example demonstrates how to style the tooltip and format its label.
- Define the
Stylewith target typeChartTooltipin the page resources:
<Style x:Key="TooltipStyle"
TargetType="charts:ChartTooltip">
<Setter Property="BackgroundColor" Value="#E8F5F4" />
<Setter Property="BorderColor" Value="#00897B" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="CornerRadius" Value="8" />
<Setter Property="ContentPadding" Value="12, 8" />
<Setter Property="TextColor" Value="#00796B" />
<Setter Property="FontSize" Value="15" />
<Setter Property="FontAttributes" Value="Bold" />
</Style>
- Set the style to the
TooltipStyleproperty of theChartTooltipBehavior. The example also sets theTooltipLabelFormatproperty to format the displayed value:
<charts:RadCartesianChart>
<charts:RadCartesianChart.BindingContext>
<local:CartesianTooltipViewModel />
</charts:RadCartesianChart.BindingContext>
<charts:RadCartesianChart.ChartBehaviors>
<charts:ChartTooltipBehavior TooltipStyle="{StaticResource TooltipStyle}"
PlacementMode="DataPoint"
TooltipLabelFormat="Revenue: ${0:N0}K" />
</charts:RadCartesianChart.ChartBehaviors>
<charts:RadCartesianChart.Axes>
<charts:CategoricalAxis />
<charts:NumericalAxis />
</charts:RadCartesianChart.Axes>
<charts:RadCartesianChart.Series>
<charts:BarSeries DisplayName="Revenue"
HorizontalBinding="Category"
VerticalBinding="Value"
ItemsSource="{Binding Data}" />
</charts:RadCartesianChart.Series>
</charts:RadCartesianChart>
Customizing the Tooltip Content
Use the TooltipContentTemplate property to define custom content. The binding context of the template is a ChartTooltipContext object.
The following example displays the series color and name, the category, properties from the business object, the formatted value, and the AdditionalData set in the TooltipOpening event.
- Define the
TooltipStyleand theTooltipContentTemplatein the page resources:
<Style x:Key="TooltipStyle"
TargetType="charts:ChartTooltip">
<Setter Property="BackgroundColor" Value="#FFFFFF" />
<Setter Property="BorderColor" Value="#80CBC4" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="CornerRadius" Value="10" />
<Setter Property="ContentPadding" Value="12" />
<Setter Property="TextColor" Value="#4A4949" />
</Style>
<DataTemplate x:Key="TooltipContentTemplate"
x:DataType="charts:ChartTooltipContext">
<VerticalStackLayout Spacing="6"
MinimumWidthRequest="150">
<HorizontalStackLayout Spacing="8">
<BoxView Color="{Binding SeriesColor}"
WidthRequest="12"
HeightRequest="12"
CornerRadius="6"
VerticalOptions="Center" />
<Label Text="{Binding Series.DisplayName}"
TextColor="#00796B"
FontAttributes="Bold"
VerticalOptions="Center" />
<Label Text="{Binding Category}"
TextColor="#00897B"
VerticalOptions="Center" />
</HorizontalStackLayout>
<BoxView Color="#B2DFDB"
HeightRequest="1" />
<VerticalStackLayout BindingContext="{Binding DataItem}"
x:DataType="local:CartesianTooltipPoint"
Spacing="2">
<Label Text="{Binding Region}"
FontSize="12" />
<Label Text="{Binding Units, StringFormat='Units sold: {0:N0}'}"
FontSize="12" />
</VerticalStackLayout>
<Label Text="{Binding FormattedValue}"
TextColor="#00897B"
FontSize="20"
FontAttributes="Bold" />
<Label BindingContext="{Binding AdditionalData}"
x:DataType="local:CartesianTooltipInfo"
Text="{Binding VsTarget}"
TextColor="{Binding TrendColor}"
FontSize="12"
FontAttributes="Bold" />
</VerticalStackLayout>
</DataTemplate>
- Set the style and the template to the
ChartTooltipBehavior, and subscribe to theTooltipOpeningevent:
<charts:RadCartesianChart>
<charts:RadCartesianChart.BindingContext>
<local:CartesianTooltipViewModel />
</charts:RadCartesianChart.BindingContext>
<charts:RadCartesianChart.ChartBehaviors>
<charts:ChartTooltipBehavior TooltipStyle="{StaticResource TooltipStyle}"
TooltipContentTemplate="{StaticResource TooltipContentTemplate}"
TooltipLabelFormat="${0:N0}K"
TooltipOpening="OnTooltipOpening" />
</charts:RadCartesianChart.ChartBehaviors>
<charts:RadCartesianChart.Axes>
<charts:CategoricalAxis />
<charts:NumericalAxis />
</charts:RadCartesianChart.Axes>
<charts:RadCartesianChart.Series>
<charts:LineSeries DisplayName="Revenue"
HorizontalBinding="Category"
VerticalBinding="Value"
ItemsSource="{Binding Data}" />
</charts:RadCartesianChart.Series>
</charts:RadCartesianChart>
- Add the
TooltipOpeningevent handler that sets theAdditionalData:
private void OnTooltipOpening(object sender, ChartTooltipOpeningEventArgs e)
{
if (e.DataItem is not CartesianTooltipPoint point)
{
return;
}
double percentage = ((point.Value - point.Target) / point.Target) * 100.0;
string sign = percentage >= 0.0 ? "+" : string.Empty;
string formattedPercentage = percentage.ToString("0", CultureInfo.InvariantCulture);
Color trendColor = percentage >= 0.0 ? Color.FromArgb("#00897B") : Color.FromArgb("#A30111");
e.AdditionalData = new CartesianTooltipInfo($"{sign}{formattedPercentage}% vs target", trendColor);
}
Customizing the Tooltip Control Template
To fully change the tooltip appearance, set the ControlTemplate property of the ChartTooltip through the TooltipStyle. Use a ContentPresenter to display the tooltip content, and bind to the ChartTooltip properties, such as the text properties and the Context, through a RelativeSource binding.
The following example displays the category in a header above the tooltip content.
- Define the
ControlTemplateand theStylethat applies it in the page resources:
<ControlTemplate x:Key="TooltipControlTemplate">
<Grid>
<Grid.Resources>
<Style TargetType="Label">
<Setter Property="TextColor"
Value="{Binding TextColor, Source={RelativeSource AncestorType={x:Type charts:ChartTooltip}}, x:DataType=charts:ChartTooltip}" />
<Setter Property="FontSize"
Value="{Binding FontSize, Source={RelativeSource AncestorType={x:Type charts:ChartTooltip}}, x:DataType=charts:ChartTooltip}" />
<Setter Property="FontFamily"
Value="{Binding FontFamily, Source={RelativeSource AncestorType={x:Type charts:ChartTooltip}}, x:DataType=charts:ChartTooltip}" />
<Setter Property="FontAttributes"
Value="{Binding FontAttributes, Source={RelativeSource AncestorType={x:Type charts:ChartTooltip}}, x:DataType=charts:ChartTooltip}" />
</Style>
</Grid.Resources>
<telerik:RadBorder BackgroundColor="#00897B"
BorderColor="#80CBC4"
BorderThickness="2"
CornerRadius="10">
<Grid RowDefinitions="Auto, Auto">
<telerik:RadBorder BackgroundColor="#00796B"
CornerRadius="8, 8, 0, 0"
Padding="12, 6">
<Label Text="{Binding Context.Category, Source={RelativeSource AncestorType={x:Type charts:ChartTooltip}}, x:DataType=charts:ChartTooltip}"
TextColor="#B2DFDB"
FontSize="12"
FontAttributes="None" />
</telerik:RadBorder>
<ContentPresenter Grid.Row="1"
Margin="12, 8" />
</Grid>
</telerik:RadBorder>
</Grid>
</ControlTemplate>
<Style x:Key="TooltipControlTemplateStyle"
TargetType="charts:ChartTooltip">
<Setter Property="ControlTemplate" Value="{StaticResource TooltipControlTemplate}" />
<Setter Property="TextColor" Value="#FFFFFF" />
<Setter Property="FontSize" Value="16" />
<Setter Property="FontAttributes" Value="Bold" />
</Style>
- Set the style to the
TooltipStyleproperty of theChartTooltipBehavior:
<charts:RadCartesianChart>
<charts:RadCartesianChart.BindingContext>
<local:CartesianTooltipViewModel />
</charts:RadCartesianChart.BindingContext>
<charts:RadCartesianChart.ChartBehaviors>
<charts:ChartTooltipBehavior TooltipStyle="{StaticResource TooltipControlTemplateStyle}"
TooltipLabelFormat="${0:N0}K" />
</charts:RadCartesianChart.ChartBehaviors>
<charts:RadCartesianChart.Axes>
<charts:CategoricalAxis />
<charts:NumericalAxis />
</charts:RadCartesianChart.Axes>
<charts:RadCartesianChart.Series>
<charts:AreaSeries DisplayName="Revenue"
HorizontalBinding="Category"
VerticalBinding="Value"
ItemsSource="{Binding Data}" />
</charts:RadCartesianChart.Series>
</charts:RadCartesianChart>
- Add the
teleriknamespace, which is used for theRadBorderin theControlTemplate:
xmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"