Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Scatter chart

Individual readings over time, one dot each, so spread and outliers stay visible. jitter spreads dots that share a date into a strip plot.

Charting library: TanStack Charts

Preview

Preview width

Installation

The command adds the example above to components/charts/ and, the first time, the chart kit to components/ui/charts/. Both are source files in your project from then on: read them, change them, delete what you don't use.

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

Usage

The x axis is time: each row has a Date under date and a number for each Scatter. To plot two measures against each other instead, use the density chart's points.

<script setup lang="ts">
import {
  ChartTooltip,
  Grid,
  Scatter,
  ScatterChart,
  XAxis,
  YAxis,
} from "@/components/ui/charts";

const data = [
  { date: new Date(2026, 9, 5), orders: 132 },
  { date: new Date(2026, 9, 6), orders: 158 },
  { date: new Date(2026, 9, 7), orders: 141 },
  { date: new Date(2026, 9, 8), orders: 176 },
  { date: new Date(2026, 9, 9), orders: 169 },
];
</script>

<template>
  <ScatterChart ariaLabel="Orders per day" :data="data">
    <Grid horizontal />
    <Scatter data-key="orders" fill="var(--chart-2)" label="Orders" />
    <XAxis />
    <YAxis />
    <ChartTooltip />
  </ScatterChart>
</template>

Anatomy

A Scatter per series, over the same grid, axes and tooltip as the line chart.

<ScatterChart :data="data">
  <Grid horizontal />
  <Scatter data-key="organic" fill="var(--chart-1)" label="Organic" />
  <Scatter data-key="referral" fill="var(--chart-2)" label="Referral" />
  <XAxis />
  <YAxis />
  <ChartTooltip />
</ScatterChart>
  • ScatterChart: Holds the rows and the date axis, and runs the hover.
  • Grid: Guide lines behind the dots.
  • Scatter: One series of dots, read from dataKey, with optional rings.
  • XAxis: Date labels along the bottom.
  • YAxis: Value labels.
  • ChartTooltip: The hovered date's values, the crosshair and the date pill.

Hover

While a date is hovered, its dots grow and every other dot drops to inactiveOpacity (0.3). inactiveMode="blur" also blurs them, by inactiveBlur pixels. Set :fadeOnHover="false" to leave them alone.

Preview width

Rings and outlines

Rings are off by default. strokeWidth draws one around each dot, ringGap pixels out (2), and radius sets the dot itself (5).

outlineWidth adds a thin outline outside the ring, in outlineColor.

Preview width

Strip plots

When many rows share a date, their dots pile into one. jitter spreads them sideways by seeded offsets, so they land in the same place on every render. true spreads them over 35% of the smallest gap between dates, and { x, y, seed } sets that share, a vertical spread in pixels and the pattern.

With jitter on, hover picks the nearest dot rather than a whole date, and the crosshair is hidden unless you set showCrosshair. formatXLabel relabels the axis, for example with month names.

Preview width

Dense data

Leave the rings off and drop radius to 3 or 4, and two months of daily readings read as one cloud with its outliers clear of it.

Preview width

Thousands of dots

Each dot is an SVG element, which gets slow past about 2,000 dots. Pass :renderer="canvasRenderer" to each <Scatter> and the dots paint on one canvas, with hover, the crosshair and the tooltip as before.

On a canvas the dots appear with the chart's reveal in one sweep and dim together on hover.

Preview width

Customization

The kit is in your project, in components/ui/charts/: your framework's components over a shared core/. Change a default there and every chart picks it up.

class goes on the chart's container, so size and spacing are utility classes.

content doesn't have to start from scratch. Return the kit's TooltipContent with your own title and rows and the panel keeps its usual look.

<ChartTooltip>
  <template #content="{ point }">
    <TooltipContent
      :rows="[
        { color: 'var(--chart-3)', label: 'p95', value: `${point.latency} ms` },
      ]"
      :title="String(point.release)"
    />
  </template>
</ChartTooltip>

Where a part renders content of its own, you pass it in. In Vue:

  • ChartTooltip: <template #content="{ point, index }">

Loading state

The scatter chart has no loading state. Hold its place with a Skeleton at the same aspect ratio until the rows arrive.

Animation

Dots fade in from a slight blur, left to right, so the series is fully drawn after animationDuration (1100 ms). enterBlur sets the starting blur in pixels (2).

:animate="false" on a Scatter shows its dots at once. Change revealSignature to replay the entrance. Reduced motion skips it.

Theming

Every color in the kit is one of your theme's tokens or a mix of them, except --chart-positive, a fixed green. A preset or the .dark class restyles the chart, and overriding a token in your CSS changes it everywhere.

Give each Scatter a fill. Its ring follows the fill unless you set stroke. A series without either takes the next color from your chart palette.

TokenDefaultPaints
--chart-1your theme'sthe first series
--chart-2your theme'sthe second series
--chart-3your theme'sthe third series
--chart-grid--bordergrid lines
--chart-label--muted-foregroundtick labels
--chart-crosshair--muted-foreground at 75%the hover line
--chart-tooltip-background--popoverthe tooltip panel
--chart-date-pill-background--primarythe date pill on hover
globals.css
:root {
  --chart-grid: var(--muted);
  --chart-label: var(--foreground);
}

Accessibility

The chart is announced as an image named by ariaLabel ("Scatter chart" by default). If the point is a cluster or an outlier, say so in ariaDescription.

Tab
Moves focus to the chart.
Arrow Right
Moves to the next date. ArrowDown does the same.
Arrow Left
Moves to the previous date. ArrowUp does the same.
Home
Jumps to the first date.
End
Jumps to the last date.

API reference

Vue takes the same props as React, in camelCase or kebab-case, with class for className. Render props are scoped slots (#content), and callbacks such as onHoverChange can be written as listeners (@hover-change).

ScatterChart

PropType
datareadonly Row[]

The rows to plot. Each row holds the x value under xDataKey and one number per Scatter series under that series' dataKey.

xDataKey?string

Key of the x value in each row. The value must be a Date (or something new Date() accepts, such as a timestamp).

Default
"date"
animationDuration?number

Duration of the entrance reveal in milliseconds. 0 skips the animation. enterTransition.duration overrides it.

Default
1100
margin?Partial<ChartMargin>

Space around the plot area in pixels. Missing sides use the default.

Type
Partial<ChartMargin>
Default
{ top: 40, right: 40, bottom: 40, left: 40 }
aspectRatio?string

CSS aspect ratio of the chart ("width / height" or a number), applied to the container width.

Default
"2 / 1"
class?string

Extra CSS class name for the chart container.

style?CSSProperties

Inline styles for the chart container.

onPhaseChange?(phase: ScatterChartPhase) => void

Called with "revealing" when the entrance starts and "ready" when the chart becomes interactive.

Type
(phase: ScatterChartPhase) => void
animationEasing?string

CSS easing for the per-point entrance, for example "cubic-bezier(0.85, 0, 0.15, 1)". When unset, enterTransition.ease or the default reveal easing is used.

enterTransition?{ readonly duration?: number; readonly ease?: unknown }

Entrance timing: duration (in seconds) sets the length of the reveal and ease (a four-number cubic bezier) the easing.

Type
{ readonly duration?: number; readonly ease?: unknown }
revealSignature?string

Changing this string replays the entrance animation.

jitter?ScatterJitter

Spreads points that share an x value into a strip plot, by seeded offsets that never move between renders. Hover then snaps to the nearest point, the tooltip shows its real values, and ChartTooltip hides its crosshair unless showCrosshair is set. true spreads 0.35 of the band step; see ScatterJitter for the other forms.

formatXLabel?(date: Date) => string

Formats the x-axis ticks and the date pill, for example short month names for monthly data (the tooltip keeps its weekday date). XAxis's formatValue still wins on the axis. Defaults to "Jan 1" style labels.

Type
(date: Date) => string
childrenReactNode

The layers to draw: Grid, one or more Scatter, XAxis, YAxis, ChartTooltip and the other chart children.

ariaLabel?string

Accessible name of the chart.

Default
"Scatter chart"
ariaDescription?string

Longer accessible description of the chart, exposed as aria-description.

Scatter

PropType
dataKeystring

Key of the data field that holds this series' y values.

label?string

Name of the series in the default tooltip row. Defaults to \dataKey\.

yAxisId?string | number

Id of the y scale this series is plotted against.

Type
string | number
Default
"left"
animate?boolean

Whether the dots animate in on entrance.

Default
true
fill?string

Fill color of the dots. Defaults to stroke, then to a color from the chart palette.

stroke?string

Color of the ring around each dot. Defaults to the resolved fill.

strokeWidth?number

Width in px of an offset ring around each dot (ringGap away from it). Rings are opt-in: 0 draws plain dots.

Default
0
ringGap?number

Gap between the dot and its ring in px.

Default
2
radius?number

Radius of the dot in px.

Default
5
yGradient?boolean | Readonly<{ from?: string; to?: string }>

Fills the dots with a color that ends at to (or a default accent color when true). Overrides fill; the ring follows unless stroke is set.

Type
boolean | Readonly<{ from?: string; to?: string }>
fadeOnHover?boolean

Dim the dots that are not hovered while the chart is hovered.

Default
true
inactiveOpacity?number

Opacity of the dimmed dots when fadeOnHover is on.

Default
0.3
inactiveMode?ScatterInactiveMode

How the dots that are not hovered step back while the chart is hovered: "opacity" fades them to inactiveOpacity, "blur" also blurs them by inactiveBlur.

Default
"opacity"
inactiveBlur?number

Blur in px of the dimmed dots when inactiveMode is "blur".

Default
2
enterBlur?number

Blur in px the dots start from while they fade in on entrance.

Default
2
showActiveHighlight?boolean

Draw the hovered dot 1.35 times larger.

Default
true
outlineWidth?number

Width in px of an optional outline drawn outside the ring. 0 draws none.

Default
0
outlineColor?string

Color of the outline. Defaults to the ring color.

renderer?ChartMarkRenderer

Where the dots draw: "svg", one element per dot, or canvasRenderer, one bitmap for the series, for thousands of dots (the axes, grid, hover indicator and tooltip stay SVG). On a canvas the dots appear with the chart's reveal as one sweep, not one by one.

Default
"svg"

Grid

PropType
horizontal?boolean

Show horizontal grid lines.

Default
true
vertical?boolean

Show vertical grid lines.

Default
false
numTicksRows?number

Number of horizontal grid lines. Ignored when rowTickValues is set.

Default
5
numTicksColumns?number

Number of vertical grid lines.

Default
10
rowTickValues?number[]

Explicit y values for the horizontal grid lines. Overrides numTicksRows.

stroke?string

Color of the grid lines.

Default
"var(--chart-grid)"
loadingStroke?string

Grid color while the chart is loading. Falls back to stroke.

strokeOpacity?number

Opacity of the grid lines.

Default
1
strokeWidth?number

Width of the grid lines in px.

Default
1
strokeDasharray?string

Dash pattern of the grid lines.

Default
"4,4"
highlightRowValues?number[]

Y values of horizontal lines drawn with the highlight styling, for example a zero baseline.

highlightRowStroke?string

Color of the highlighted rows.

Default
"var(--chart-foreground-muted)"
highlightRowStrokeOpacity?number

Opacity of the highlighted rows.

Default
1
highlightRowStrokeWidth?number

Width of the highlighted rows in px.

Default
1
highlightRowStrokeDasharray?string

Dash pattern of the highlighted rows.

Default
"0"
fadeHorizontal?boolean

Fade the horizontal lines toward transparent at the left and right edges.

Default
true
fadeVertical?boolean

Fade the vertical lines toward transparent at the top and bottom edges.

Default
false
hideHorizontalEdgeLines?boolean

Drop the first and last horizontal line (kept when two or fewer remain).

Default
false
hideVerticalEdgeLines?boolean

Drop the first and last vertical line (kept when two or fewer remain).

Default
false
shimmer?boolean

While the chart is loading, sweep a bright band across the grid.

Default
false
shimmerStroke?string

Color of the shimmer band.

Default
"color-mix(in oklch, var(--bkm-foreground) 68%, transparent)"
shimmerSpeed?number

Speed multiplier of the shimmer sweep. 2 is twice as fast.

Default
1

XAxis

PropType
numTicks?number | ResponsiveChartLabelCount

Target number of tick labels along the x axis, or one per chart width: { base, sm, md, lg, xl } takes the count of the widest breakpoint the chart reaches (640, 768, 1024 and 1280 px).

Type
number | ResponsiveChartLabelCount
Default
5
labels?readonly string[]

The tick text of each data row, in row order: it replaces the date formatting (pair it with ChartTooltip dateLabels).

tickerHalfWidth?number

Half-width in px of the zone around the date pill inside which tick labels are hidden. Line, area and composed charts widen it to the pill's half-width plus the widest tick label's, so no label sits half under the pill.

Default
50
tickMode?"domain" | "data"

Where ticks fall: "data" places them on evenly spaced data rows, "domain" places them at evenly spaced time values across the x domain.

Type
"domain" | "data"
Default
"data"
formatValue?(value: Readonly<Date>) => string

Formats a tick date into its label. Defaults to a short month and day such as "Jan 5".

Type
(value: Readonly<Date>) => string

YAxis

PropType
yAxisId?string | number

Id of the y scale this axis labels. Must match the yAxisId of the series that use it.

Type
string | number
Default
"left"
orientation?"left" | "right"

Side of the plot the axis sits on. The primary axis is on the left; additional axes default to the right.

Type
"left" | "right"
Default
"left"
numTicks?number

Target number of tick labels. The primary axis also sets the number of horizontal grid lines.

Default
5
formatLargeNumbers?boolean

Abbreviate values of 1000 and above as thousands, with one decimal where needed, for example 2k or 1.5k.

Default
true
formatValue?(value: number) => string

Formats a tick value into its label. Overrides formatLargeNumbers.

Type
(value: number) => string

ChartTooltip

PropType
showDatePill?boolean

Show the date pill that rides along the bottom of the plot.

Default
true
showCrosshair?boolean

Show the vertical crosshair line. Bar charts leave it off unless this is true (the dots and the category pill mark the bar).

Default
true
showDots?boolean

Show a dot on every series at the hovered position.

Default
true
dotVariant?"dot" | "ring"

Dot style: a filled "dot" or a transparent "ring" square. Read by BarChart only.

Type
"dot" | "ring"
Default
"dot"
dotSize?number

Dot radius in px.

Default
5
dotRadiusFraction?number

Corner radius of the "ring" variant as a fraction of its side (0 is square, 0.5 is a circle). Read by BarChart only.

Default
0.25
dotScale?number

Multiplier applied to the dot or ring size. Read by BarChart and LiveLineChart.

Default
1
dotStrokeWidth?number

Stroke width of the dots in px.

Default
2
indicatorColor?string | ((point: Record<string, unknown>) => string)

Color of the crosshair. Only a string is applied; the function form that bklit-ui accepts is ignored and the default is used.

Type
string | ((point: Record<string, unknown>) => string)
Default
"var(--chart-crosshair)"
#content?slot: { point, index }

Replaces the default tooltip panel body. Receives the hovered data row and its index; with pinnable, also whether the panel is pinned and a dismiss that unpins it (for a close button in a pinned panel's detail).

pinnable?boolean

A click (or Enter, or Space) on the chart pins the tooltip where it is: the panel takes the pointer, so its content can grow into detail and hold controls, until another click, Escape or dismiss lets it go.

Default
false
rows?(point: Record<string, unknown>) => { readonly color: string; readonly label: string; readonly value: string | number }[]

Replaces the default rows (one per series) with your own list of { color, label, value }.

Type
(point: Record<string, unknown>) => { readonly color: string; readonly label: string; readonly value: string | number }[]
dotColor?string | ((point: Record<string, unknown>, line: ChartLineConfig) => string)

Fill of the tooltip dots. A function receives the hovered row and the series config, and is called again each time the hovered row changes. Defaults to each series' color; a ProfitLossLine's dot takes the color of the hovered value's sign.

Type
string | ((point: Record<string, unknown>, line: ChartLineConfig) => string)
#default?slot

Extra content rendered below the rows in the default panel, for example marker details. Without it, a chart with ChartMarkers lists the markers on the hovered date there.

class?string

Extra class name for the tooltip panel.

springConfig?SpringConfig

Spring for the floating panel when matchCrosshair is on. Defaults to the chart's tooltip spring.

matchCrosshair?boolean

Make the floating panel follow the pointer with the same spring as the crosshair instead of damping.

Default
false
damping?number

Spring damping for the floating panel when matchCrosshair is off, on bklit's 0 to 100 scale: lower is bouncier, higher slower, 0 moves the panel instantly. The default, 20, is the snappy hover spring (stiffness 3600, damping 120); every other value is bklit's spring for it played six times faster.

Default
20
indicatorDasharray?string

Dash pattern of the crosshair. Omit for a solid line.

indicatorFadeEdges?IndicatorFadeEdges

Vertical fade of the crosshair: both ends, the top, the bottom, or none (solid).

Default
"both"
indicatorFadeLength?number

Size of the crosshair's fade, as a percentage of its height (2 to 40).

Default
10
indicatorEndColor?string

Bottom colour of the crosshair: it ramps from indicatorColor at the top to this at the bottom (composes with the fade).

indicatorEnd?"plot" | "point"

How far down the crosshair reaches: the whole plot, or down to the hovered point of the first series.

Type
"plot" | "point"
Default
"plot"
dotHaloBlur?number

Blur in px on the dots' halo, for a soft glow.

Default
0
topOffset?number

Extra gap in px between the top of the plot and the tooltip panel.

Default
0
dateLabels?readonly string[]

The date pill's text for each data row, in row order (pair it with XAxis labels).

boxSpringConfig?SpringConfig

Spring for the floating panel. Takes priority over matchCrosshair and damping.

indicatorWidth?IndicatorWidth

Thickness of the crosshair: a width in px, or "line" (1px), "thin" (2px), "medium" (4px) or "thick" (8px).

Default
"line"

Examples

6 examples on Vue, each live with its code and its own install command.