shadcn.io is not affiliated with official shadcn/ui
Chart examples · Tooltip
Tooltip - Default Chart for React
The default chart tooltip, with a label, a dot for each series and its value.
The tooltip as it comes: the hovered label as the title, then a dot, a name and a value for each series. The chart opens with the tooltip shown on the second day.
Preview
Installation
FAQ
What does the default tooltip include?
ChartTooltip renders ChartTooltipContent with no extra props. indicator stays dot, a small swatch in the series color. Each row is the label from config, Running or Swimming, and the value passed through toLocaleString in font-mono with tabular-nums.
Why is the tooltip title a raw date?
The title is the XAxis value, the date string, like 2024-07-16. This demo doesn't set labelFormatter. The axis uses tickFormatter={formatWeekday}, which prints a short weekday, so the axis and the tooltip title are formatted differently.
Why is a tooltip open on load?
ChartTooltip sets defaultIndex={1}. That is the second row, 2024-07-16. Hovering another bar moves it. cursor={false} turns the bar's hover cursor off.
How do I change the dot?
Set indicator on ChartTooltipContent. It accepts dot, line, or dashed. line is a narrow bar in the series color. hideIndicator removes it. This demo leaves the default dot.
Related
- Tooltip - Advanced ChartA chart tooltip with a custom row for
- Tooltip - Formatter ChartA chart tooltip that formats each row
- Tooltip - Label Formatter ChartA chart tooltip that formats its date
- A bar chartA bar chart with rounded corners
- Tooltip - Icons ChartA chart tooltip showing each series' icon
- A line chartA line chart drawing one series as a