Tooltips

The Chart supports three types of tooltips.

The Chart tooltip types are:

Series Tooltip

The series tooltip is displayed when the user hovers over a point and is used to show the point values or any additional information. By default, the color of the tooltip matches the color of the point to help associate the tooltip with that point. It is also possible to set it to a specific color by using the background and border options.

Tooltip configuration

To enable and configure the tooltip for all series, use the ChartTooltip component. To enable and configure the tooltip for a specific series, use the ChartSeriesItemTooltip component.

The following example demonstrates how to configure the tooltip globally and to override an option for a specific series.

Example
View Source
Change Theme:

Customizing Content

By default, the content of the tooltip is determined based on the point type. To customize the tooltip content, either:

  • Use the format prop, or
  • Specify a template through the render prop.

Using the format Option

The following example demonstrates how to customize the content of the tooltip through the format configuration.

Example
View Source
Change Theme:

Specifying a Template

To specify a template, use the render prop of the ChartTooltip or ChartSeriesItemTooltip components.

The callback passed to the render props receives a single parameter - the context of the tooltip. When the render prop is defined on the ChartTooltip component, the context could be either of type SharedTooltipContext or TooltipContext depending on whether the tooltip is shared or not. The type of of context when defined on the ChartSeriesItemTooltip is always of type TooltipContext.

The following example demonstrates how to customize the content by using a render prop.

Example
View Source
Change Theme:

Shared Tooltip

Default Content

The shared tooltip is displayed when the user hovers over a category and is used for Categorical charts. The shared tooltip shows a summary of all points in the hovered category. To enable the shared tooltip, use the shared option of the ChartTooltip component.

The following example demonstrates how to enable the shared tooltip.

Example
View Source
Change Theme:

Customizing Content

By default, the shared tooltip displays the category as a title and an item for each point in that category. To customize the content that is displayed for the points of a specific series, use the format option, or the template for the series. To customize the entire content, add a render prop to the ChartTooltip component.

The callback function receives a single parameter of type SharedTooltipContext.

Example
View Source
Change Theme:

Crosshair Tooltip

The crosshair tooltips are displayed next to the axes crosshairs and show the current value of the crosshairs. To enable the crosshair tooltip, use the specific axis crosshair-tooltip component.

Using in Categorical Charts

The following example demonstrates how to enable the crosshair tooltips for the Categorical charts.

Example
View Source
Change Theme:

Using in Scatter Charts

The following example demonstrates how to enable the crosshair tooltips for the Scatter charts.

Example
View Source
Change Theme: