# Tooltip for Telerik Blazor Chart

The Telerik Chart provides a tooltip for its data points. You can have settings specific to each `<ChartSeries>`, common tooltip settings for all series, or a [shared](https://www.telerik.com/blazor-ui/documentation/components/chart/tooltip/shared) tooltip for all categories.

In this article:

* [Basics](https://www.telerik.com/blazor-ui/documentation/components/chart/tooltip/overview#basics)
* [Common Tooltip](https://www.telerik.com/blazor-ui/documentation/components/chart/tooltip/overview#common-tooltip)
* [Customization](https://www.telerik.com/blazor-ui/documentation/components/chart/tooltip/overview#customization)
  * [Parameter Settings](https://www.telerik.com/blazor-ui/documentation/components/chart/tooltip/overview#parameter-settings)
  * [Template](https://www.telerik.com/blazor-ui/documentation/components/chart/tooltip/overview#template)

## Basics

By default the value of the point will be presented when hovered over.

To enable tooltips for the data points of each individual series:

1. Inside the `<ChartSeries>`, include the `<ChartSeriesTooltip>` tag.
2. Set its `Visible` parameter to `true`.

> caption Enable the tooltip for a specific Chart Series

<demo metaUrl="client/chart/tooltip/overview/single-series/" height="500"></demo>

## Common Tooltip

The Chart allows you to enable and define common tooltip settings for all series at once. It looks like the individual tooltips (the value of the point will be presented when hovered over), but you declare it only once.

A tooltip set to a specific `<ChartSeries>` will take precedence over the common tooltip settings.

To enable the same tooltip for all series:

1. Inside the `<TelerikChart>`, add the `<ChartTooltip>`.
2. Set its `Visible` parameter to `true`.

> caption Set a Common Tooltip for all series at once

<demo metaUrl="client/chart/tooltip/overview/common-tooltip/" height="500"></demo>

## Customization

There are two types of customizations you can do for the tooltips:

* [Parameter Settings](https://www.telerik.com/blazor-ui/documentation/components/chart/tooltip/overview#parameter-settings) - lets you alter cosmetic settings such as borders, colors and padding through simple parameters
* [Template](https://www.telerik.com/blazor-ui/documentation/components/chart/tooltip/overview#template) - lets you control the entire content

### Parameter Settings

You can customize the appearance of the individual series tooltip by using:

* `Background` - control the background color by applying a CSS color string, including HEX and RGB. By default the it will match the color for the category.

* `Color` - control the text color by applying a CSS color string, including HEX and RGB.

* Use the [Template](https://www.telerik.com/blazor-ui/documentation/components/chart/tooltip/overview#template) to take control over what is rendered in the tooltip.

> caption Configuration of the tooltips with applied customization settings

<demo metaUrl="client/chart/tooltip/overview/parameter-settings/" height="500"></demo>

#### Common Tooltip Settings

In a similar fashion, you can declare these settings in the common tooltip section:

* `Background` - control the background color by applying a CSS color string, including HEX and RGB. By default the it will match the color for the category.

* `Color` - control the text color by applying a CSS color string, including HEX and RGB.

* `Opacity` - control the opacity of the tooltip.

* Use the [Template](https://www.telerik.com/blazor-ui/documentation/components/chart/tooltip/overview#template) to take control over what is rendered in the tooltip - the tag name and data it provides is the same as for the specific tooltip, but it affects all series at once.

### Template

The `Template` allows you to take control over the rendering of the tooltip and include additional information to the user.

In the template you can:

* Use business logic and render HTML

* Use the `context` parameter that provides information about the current data point.

The available series data point information in the `context` is:

* `FormattedValue` - maps to the default rendering of the tooltip, formatted as a string.

* Use this when the chart's data is bound by [Independent Series Binding](https://www.telerik.com/blazor-ui/documentation/components/chart/data-bind#independent-series-binding). You can parse this to a numerical value (`int`, `double`, etc.) in order to apply formatting. Otherwise, use the `DataItem` to get the value of the point.

* `DataItem` - provides the data model of the current series item. You need to cast it to the type from your datasource, which needs to be serializable.

  * If you are using a [Date Axis](https://www.telerik.com/blazor-ui/documentation/components/chart/date-axis), the `DataItem` will contain the only the aggregated value in the corresponding y-value field, because it is a collection of more than one items. See the `Category` below for details.

* `Category` - provides information on the category the data point is located in. You need to cast it to the type in your data source, for example `DateTime`, `string`, `int` or another type. The `Category` parameter is applicable to [Categorical Charts](https://www.telerik.com/blazor-ui/documentation/components/chart/data-bind#series-types).

  * When using a [Date Axis](https://www.telerik.com/blazor-ui/documentation/components/chart/date-axis), you can use it, together with the `BaseUnit` value of the axis, to filter the data source and obtain the actual data items from the data source in case you want to provide extra information about them.

* `Percentage` - applicable to [Donut](https://www.telerik.com/blazor-ui/documentation/components/chart/types/donut), [Pie](https://www.telerik.com/blazor-ui/documentation/components/chart/types/pie) and [Stacked 100%](https://www.telerik.com/blazor-ui/documentation/components/chart/stacked-series#stack-100) Charts - the percentage value of the current data point from the whole.

* `SeriesIndex` - provides the index of the `<ChartSeries>` the data point belongs to.

* `SeriesName` - bound to the `Name` parameter of the `<ChartSeries>` the data point belongs to.

* `SeriesColor` - shows the RGB color of the Series the data point belongs to.

* `CategoryIndex` - shows the index of the data point's x-axis category.

> caption Use the Tooltip Template and use the DataItem to get the value of the point and add additional information

<demo metaUrl="client/chart/tooltip/overview/template/" height="500"></demo>

#### Format Tooltip Values

To format a tooltip value, cast `context.DataItem` to the data item type and apply a standard .NET numeric format string. The `C2` format displays the currency symbol and two decimal places according to the current culture.

> caption Format a PieChart tooltip value as currency

```RAZOR
<TelerikChart>
	<ChartSeriesItems>
		<ChartSeries Type="ChartSeriesType.Pie"
					 Data="@PieData"
					 Field="@nameof(PiePoint.Value)"
					 CategoryField="@nameof(PiePoint.Category)">
			<ChartSeriesTooltip Visible="true">
				<Template>
					@{
						var point = (PiePoint)context.DataItem;
					}
					@point.Category: @point.Value.ToString("C2")
				</Template>
			</ChartSeriesTooltip>
		</ChartSeries>
	</ChartSeriesItems>
</TelerikChart>

@code {
	private List<PiePoint> PieData { get; set; } = new List<PiePoint>
	{
		new PiePoint { Category = "Product 1", Value = 1250.50m },
		new PiePoint { Category = "Product 2", Value = 980.00m }
	};

	public class PiePoint
	{
		public string Category { get; set; }
		public decimal Value { get; set; }
	}
}
```

## See Also

* [Chart Overview](https://www.telerik.com/blazor-ui/documentation/components/chart/overview)
* [Chart Shared Tooltip](https://www.telerik.com/blazor-ui/documentation/components/chart/tooltip/shared)
