shadcn.io is not affiliated with official shadcn/ui
About
Pick it when each point is a real measurement and the curve only joins them: monthly snapshots, survey waves, sprint results. The dots show people where the data is, which matters with few points. With dozens of points, drop the dots and mark only the hovered one.
A natural curve through six months with a filled dot on each, in the series color. Hovering marks the active month, and the tooltip shows its value alone.
Installation
Usage
import { ChartLineDots } from "@/components/charts/chart-line-dots";<ChartLineDots />Customize
dot={{ fill: "var(--color-desktop)" }}draws a filled marker on every point, outlined in the line's own stroke.activeDot={{ r: 6 }}grows the hovered point.type="natural"andstrokeWidth={2}match the plain Line Chart; only thedotprops differ.<ChartTooltipContent hideLabel />drops the month, andcursor={false}hides the vertical hover line.
FAQ
How do I change the size of the dots?
Put r in the dot object, dot={{ fill: "var(--color-desktop)", r: 4 }}, and in activeDot for the hovered one.
How do I draw hollow dots?
Pass dot={{ fill: "var(--background)", stroke: "var(--color-desktop)", strokeWidth: 2 }} to <Line>.
Can I show the dots only on hover?
Yes. Set dot={false} and keep activeDot={{ r: 6 }}: Recharts then draws a dot only on the hovered point.
Should I keep the dots with a lot of data?
Not past a few dozen points. The dots merge into a thick band and hide the line's shape. Keep them for monthly or weekly data; for daily data, mark only the hovered day.
API Reference
ChartContainer
configChartConfig
Each series by its data key: its label, an icon, and a color (or a * theme color per light and dark), read by the tooltip and legend and set * as --color-<key>.
initialDimension?{ height: number; width: number; }
The size it renders at before it's measured, so the first paint isn't * empty.
- Type
{ height: number; width: number; }- Default
INITIAL_DIMENSION
className?string
Merged with the part's classes.
ChartLegend
ChartLegendContent
<div>
hideIcon?boolean
Hides each series' icon (from config), leaving its color swatch.
- Default
false
nameKey?string
The key in each legend item's data to look its label up by in config. * Defaults to the item's dataKey.
className?string
Merged with the part's classes.
ChartStyle
<style>
configChartConfig
The chart config whose colors it writes as --color-<key> variables.
idstring
The element's id.
ChartTooltip
ChartTooltipContent
<div>
hideIndicator?boolean
Hides each item's color indicator.
- Default
false
hideLabel?boolean
Hides the tooltip's label, the hovered point's.
- Default
false
indicator?"dashed" | "dot" | "line"
The color indicator's shape: a dot, a line or dashed.
- Type
"dashed" | "dot" | "line"- Default
"dot"
labelFormatter?(label: any, payload: TooltipPayload) → React.ReactNode
Formats the tooltip's label; its value is untyped, as in recharts 3.8.
- Type
(label: any, payload: TooltipPayload) → React.ReactNode- Parameters
label– anypayload– TooltipPayload- Returns
React.ReactNode
labelKey?string
The key in the data to read the label from, looked up in config.
nameKey?string
The key in each item's data to look its name up by in config.
className?string
Merged with the part's classes.
Related
Line Chart with Colored Dots
Line chartsA line whose dots each take their category's color.
Line Chart with Custom Dots
Line chartsA line with custom markers in place of plain dots.
Line Chart with Labels
Line chartsEach point's value printed above the line.
Line Chart
Line chartsOne series as a smooth line over six months.
Radar Chart with Dots
Radar chartsA radar with a dot on every value.
Multiple Line Chart
Line chartsTwo series as lines on the same axes.