Charts - Tooltip
Show data details on hover with mode, snap strategy, crosshair, custom content, OHLC layout, position control, and delays.
#Usage
import { ChartSvg, ChartTooltip } from '@primeui/vue-chart';<ChartSvg>
<!-- series and axes -->
<ChartTooltip />
</ChartSvg>Hover details are opt-in: add ChartTooltip to show a tooltip on hover; remove it and hover produces nothing. It works across all chart types with no additional wiring. Mode, snap strategy, crosshair, and custom content are all configured on the same component.
#Basic
Add ChartTooltip to display a tooltip when hovering over data elements. The default mode="item" shows details for the specific element under the cursor: one series, one value.
#Shared Mode
Set mode="shared" to show all series values at the hovered position in a single tooltip. This works for multi-series charts where comparing values at the same anchor is the main interaction. The tooltip snaps to the nearest anchor regardless of where the cursor is off-axis.
#Snap Strategy
Use snap to control how the hovered point is selected. category snaps to the nearest category (bar/column default), x snaps along the X axis (line/area default), xy picks the Euclidean-nearest point (scatter/bubble default), y snaps along the Y axis, and none disables neighborhood search so the tooltip only appears on exact shape hover. When unset, each chart type uses its natural default. Heatmap is the exception that snaps without being asked: its cells tile the plot, so the spacing between them is decoration rather than background, and the cursor resolves to the cell whose band it falls in. Pass none there for exact hover on the painted cell only.
#Crosshair
Set crosshair to display a reference line at the hovered position. Pass true for default styling or a CrosshairConfig object for fine control. Set x/y to show vertical or horizontal lines independently, and dashArray, color, width to customize their appearance.
#Position
Set position to control where the tooltip appears relative to the hovered element. cursor (default) follows the mouse, top and bottom pin it to the chart edges, left and right align it to the sides. Use offsetX and offsetY to adjust placement after the position is applied.
#Custom Tooltip
Set render to replace the default tooltip with custom content. The callback receives a TooltipRenderContext object containing all series items at the hovered position, the chart type, and theme information. Return a VNode.
Security. The built-in tooltip renders values as text (textContent), so raw data cannot inject markup. It is XSS-safe by default. When you supply a customrender, you control the VNode tree: never build it from untrusted strings viav-html/innerHTML. Bind values as text ({{ value }}) and your tooltip stays safe.
#OHLC Layout
On candlestick charts, the tooltip renders open, high, low, and close values in a structured layout with no configuration. Use render to replace this layout with custom content if needed.
#API
#ChartTooltip
| Prop | Type | Default | Description |
|---|---|---|---|
mode | 'item' | 'shared' | 'item' | item = tooltip for the specific hovered element. shared = tooltip for all series at the snapped anchor |
snap | 'x' | 'y' | 'xy' | 'category' | 'none' | type default | Point selection strategy. none disables neighborhood search (exact shape hover only). When unset, each chart type uses its natural default (scatter=xy, line/area=x, bar/column=category). Heatmap snaps to the cell whose band contains the cursor unless set to none. |
crosshair | boolean | CrosshairConfig | false | Show a reference line or band at the hovered position. Pass true for defaults or a CrosshairConfig object for fine control |
position | 'cursor' | 'top' | 'bottom' | 'left' | 'right' | 'cursor' | Tooltip placement relative to the chart |
offsetX | number | - | Horizontal offset in pixels applied after position |
offsetY | number | - | Vertical offset in pixels applied after position |
followCursor | boolean | true | Tooltip tracks cursor movement when position is cursor |
showDelay | number | 0 | Milliseconds to wait before showing the tooltip. Raise to hold the tooltip back while the cursor sweeps across dense hit targets |
hideDelay | number | 0 | Milliseconds the tooltip lingers after the cursor leaves a point. The crosshair and the colour-legend indicator linger with it, so the three never disagree |
render | (context: TooltipRenderContext) => unknown | - | Custom tooltip renderer. Replaces the default layout entirely |
#CrosshairConfig
Pass to crosshair for fine-grained control over the reference line appearance.
| Field | Type | Default | Description |
|---|---|---|---|
x | boolean | true | Show vertical reference line (X axis position) |
y | boolean | true | Show horizontal reference line (Y axis position) |
dashArray | number[] | [4, 4] | Dash pattern [dashLength, gapLength] |
color | string | theme | Crosshair line color |
width | number | 1 | Crosshair line width in pixels |
#TooltipRenderContext
Passed to the render callback. Represents the primary hovered item. Use allSeries to access all series values at the hovered position.
| Field | Type | Description |
|---|---|---|
datasetId | string | The series identifier |
index | number | Data index of the hovered element |
label | string | Category or data point label |
value | number | Raw data value |
percentage | number | undefined | Percentage of total. Populated for pie, donut, and polar charts |
color | string | Series color |
x | number | undefined | Pixel X coordinate of the hovered point |
y | number | undefined | Pixel Y coordinate of the hovered point |
ohlc | { open, high, low, close } | undefined | OHLC prices. Populated for candlestick charts |
allSeries | TooltipItem[] | All series values at the hovered position. Use for multi-series tooltips with mode="shared" |
#TooltipItem
Each entry in TooltipRenderContext.allSeries.
| Field | Type | Description |
|---|---|---|
datasetId | string | Dataset identifier. Stable key for list rendering |
name | string | undefined | Human-readable series name from the name prop on the series component |
label | string | Category label at the hovered position. Same for all items in the list |
color | string | Series color |
value | number | Raw numeric value |
formattedValue | string | Pre-formatted value string. Respects axis tick format, stacking mode, and display units. Use this for display, not value |
percentage | number | undefined | Percentage of total (0–100). Populated for percent-stacked bar charts |
ohlc | { open, high, low, close } | undefined | OHLC prices. Populated for candlestick series |