Tooltips in Python
XY shows a built-in hover tooltip by default. With no tooltip component it
reports the available x/y values and encoded color or size values. Add
tooltip() to choose fields, format values, supply a title template, hide the
tooltip, or register framework-rendered content.
Default Hover Tooltip
With a bare xy.tooltip() (or none at all), hovering a point reports its x and
y values without any further configuration.
Choose Fields and Formats
Named source columns that feed x, y, color, size, or heatmap-value channels can be used as tooltip fields:
Braced field names in title are replaced from the hovered row. format maps
field names to the client's numeric format strings. A source column that is not
bound to a rendered channel is not shipped merely because its name appears in
fields.
Title Templates Across Multiple Series
One tooltip configuration serves every mark in the chart: the braced {day}
title, the field selection, and the per-field number formats apply to both the
dashed forecast line and the margin-sized revenue points below.
Exact and Resident Readout
Standalone HTML composes tooltips from the values resident in its payload.
With a live notebook or framework transport, an immediate client readout can be
replaced by exact canonical f64 values from Python. The on_hover callback
receives that exact row rather than tooltip text.
Hide, Style, or Replace
Use show=False to disable built-in tooltips. class_name and style target
the tooltip container; chart-level slot styling can target tooltip as well.
The last tooltip component supplies the effective configuration.
Like legends, a positional child or render= object is kept opaque for an
adapter and can be retrieved through chart.chrome_components(). It is not
embedded into standalone HTML, and the shipped reflex_xy.chart adapter does
not mount it. With that adapter, disable the built-in tooltip, handle
on_point_hover in Reflex state, and render the framework-owned tooltip beside
or over the chart. See Customize Each Part
for the complete integration boundary.
See Events and callbacks for hover payloads and Marks and components reference for the exact tooltip signature.
API Reference
xy.tooltip
Configure chart tooltip chrome.
Props
| Prop | Type | Description |
|---|---|---|
*children | Any | Optional opaque replacement content. |
show | bool | Whether to display tooltips. |
render | Any | Opaque renderer supplied by an adapter. |
fields | Optional[list[str]] | Data fields shown in each tooltip. |
title | Optional[str] | Optional tooltip title. |
format | Optional[dict[str, str]] | Per-field value formats. |
class_name | Optional[str] | DOM class name applied to the tooltip. |
style | Optional[dict[str, StyleValue]] | Tooltip style overrides. |
FAQ
How do I show values on hover in a Python chart?
XY shows a built-in hover tooltip by default — with no configuration it reports
the available x/y values plus any encoded color or size values. Add
xy.tooltip() as a chart child only when you want to choose fields, formats,
or a title template.
How do I customize which fields a tooltip shows and how numbers are formatted?
Pass fields= and format= to xy.tooltip(), e.g.
xy.tooltip(fields=["revenue", "growth"], format={"revenue": ",.0f", "growth": ".1%"}).
Only source columns bound to a rendered channel (x, y, color, size, or
heatmap value) can be used as tooltip fields.
How do I put data values in the tooltip title?
Use braced field names in title=, e.g. xy.tooltip(title="Month {month}") —
each placeholder is replaced with the value from the hovered row.
How do I disable tooltips on a chart?
Add xy.tooltip(show=False) to the chart. When several tooltip components are
present, the last one supplies the effective configuration, so a final
show=False wins.