shadcn.io is not affiliated with official shadcn/ui
Chart examples · Tooltip
Tooltip - Line Indicator Chart for React
A chart tooltip with line indicators instead of dots.
The tooltip with indicator="line": a thin bar in each series' color instead of a dot, next to its name and value.
Preview
Installation
FAQ
What does indicator line draw?
ChartTooltipContent sets indicator="line". That is a narrow bar, w-1, painted with the series color, beside Running and Swimming. The default is dot, a size-2.5 swatch. The same prop accepts dashed.
Where does that bar's color come from?
The indicator uses the series color. config sets running to var(--chart-1) and swimming to var(--chart-2), and the bars fill var(--color-running) and var(--color-swimming). The row name is the label from config.
Does this tooltip still have a title?
Yes. This demo doesn't set hideLabel, so the title is the raw date, like 2024-07-16. XAxis shows a short weekday through tickFormatter={formatWeekday}. The rows under the title are the two series and their values.
Why is a tooltip open on load?
ChartTooltip sets defaultIndex={1} and cursor={false}. Index 1 is the second row. cursor={false} turns the hover cursor off. BarChart sets accessibilityLayer.
Related
- Tooltip - Default ChartThe default chart tooltip, with a label
- Tooltip - No Indicator ChartA chart tooltip without color indicators
- A line chartA line chart drawing one series as a
- A simple area chartA single-series area chart with a smooth
- Tooltip - Formatter ChartA chart tooltip that formats each row
- A horizontal bar chartA bar chart laid out horizontally, with