- Overview
- shadcn/ui Charts
- Lines and Areas
- Bars and Rankings
- Scatterplots and Relationships
- Distributions
- Heatmaps and Densities
- Intervals and Financial Charts
- Stacked and Composed Charts
- Facets and Multiple Views
- Networks and Hierarchies
- Maps and Spatial Charts
- Polar and Radar Charts
- Annotations and Overlays
- Interactive Charts
- Themes and Motion
Individual Charts
- Apple stock line with seasonal gaps
- Industry unemployment with end labels
- San Francisco temperature range band
- Industry unemployment stacked area
- Sorted vertical bars
- Horizontal ranking with long labels
- Grouped bars
- Stacked bars
- Bubble scatterplot
- Histogram
- Labeled ordinal heatmap
- Anscombe quartet small multiples
- Open-to-close price intervals
- Point estimates with error bars
- Grouped boxplot
- Ranked lollipop chart
- Dumbbell comparison
- Cumulative histogram
- San Francisco temperature moving averages
- Industry share of unemployment
- Streamgraph
- Bollinger band
- Quantitative binned heatmap
- Precipitation calendar heatmap
- Diverging Likert responses
- Parallel coordinates
- Candlestick chart
- Annual gasoline-price waterfall
- Two-period slopegraph
- Scatterplot with linear regression
- Metro inequality change arrows
- Apple close versus moving average
- Pointer-selected tooltip
- Grouped X tooltip
- Tidy hierarchy tree
- Delaunay spatial network
- Filled wind-speed contours
- Point density contours
- Westport House floor plan
- Les Misérables character network
- English letter frequency waffle
- Two-dimensional vector field
- Hexagonally binned density
- Framed guide-free scatterplot
- Empirical cumulative distribution
- Faceted distributions
- Beeswarm distribution
- Log-scale Flare class sizes
- Industry unemployment bump chart
- Indexed industry unemployment
- Directed connected scatterplot
- Scatterplot with marginal histograms
- Annotated AAPL extrema
- Mean penguin mass reducer bars
- AAPL lag-one autocorrelation
- Industry unemployment percentile ribbon
- Ridgeline density comparison
- Violin distribution comparison
- Marimekko survey composition
- Voronoi nearest-point interaction
- Seattle weather with three y axes
- Palmer penguins by species and sex
- Stacked and adjacent Seattle weather bars
- Automobile specifications scatter
- Flare analytics treemap
- Simple radar chart
- English letter frequency pie
- English letter frequency donut
- Survey agreement share gauge
- Snapped axis pointer with grouped tooltip
- Interactive series legend
- Linked chart and data table selection
- Focus and context time window
- Expanding pinned energy tooltip
- Scrollable resource timeline lanes
- Streaming window preservation
- Synchronized cursors across views
- Free cursor over car measurements
- Observed monthly AAPL brush selection
- Wheel zoom and pan over AAPL closes
- AAPL close playback scrubber
- Editable event range
- Letter frequency pie with labels
- Letter frequency donut with total
- Rounded letter frequency donut
- Nested Flare package sizes
- English letter frequency rose
- County unemployment gauge
- Comparative radar chart
- Concentric letter frequency bars
- Flare analytics sunburst
- World learning-poverty choropleth
- World population bubble map
- Orthographic globe with graticule
- HMS Beagle voyage
- Seattle daily high-temperature polar line
- Surface wind polar scatter
- World population-density choropleth
- United States county unemployment choropleth
- Standard world projection gallery
- Basic Sankey
- Sankey
- Staggered entrance motion
- Interrupted spring updates
- Spring line updates
- Definition-owned motion
- Cross-chart geometry morph
- Focus and crosshair motion
- Token use calendar heatmap
- Stacked bars with band and rule cursors
- Themed interactive area card
- Active bar dashboard
- Premium KPI sparklines
- Active donut metric
- Theme palette matrix
- Sales conversion funnel
- Drillable Flare sunburst
- shadcn dashboard
- shadcn Bar Chart - Multiple
- shadcn Pie Chart - Donut with Text
- shadcn Radar Chart - Multiple
- shadcn Radial Chart - Text
- shadcn Tooltip - Advanced
- shadcn Area Chart - Axes
- shadcn Area Chart
- shadcn Area Chart - Gradient
- shadcn Area Chart - Icons
- shadcn Area Chart - Interactive
- shadcn Area Chart - Legend
- shadcn Area Chart - Linear
- shadcn Area Chart - Stacked Expanded
- shadcn Area Chart - Stacked
- shadcn Area Chart - Step
- shadcn Bar Chart - Active
- shadcn Bar Chart
- shadcn Bar Chart - Horizontal
- shadcn Bar Chart - Interactive
- shadcn Bar Chart - Custom Label
- shadcn Bar Chart - Label
- shadcn Bar Chart - Mixed
- shadcn Bar Chart - Negative
- shadcn Bar Chart - Stacked + Legend
- shadcn Line Chart
- shadcn Line Chart - Dots Colors
- shadcn Line Chart - Custom Dots
- shadcn Line Chart - Dots
- shadcn Line Chart - Interactive
- shadcn Line Chart - Custom Label
- shadcn Line Chart - Label
- shadcn Line Chart - Linear
- shadcn Line Chart - Multiple
- shadcn Line Chart - Step
- shadcn Pie Chart - Donut Active
- shadcn Pie Chart - Donut
- shadcn Pie Chart - Interactive
- shadcn Pie Chart - Custom Label
- shadcn Pie Chart - Label List
- shadcn Pie Chart - Label
- shadcn Pie Chart - Legend
- shadcn Pie Chart - Separator None
- shadcn Pie Chart
- shadcn Pie Chart - Stacked
- shadcn Radar Chart
- shadcn Radar Chart - Dots
- shadcn Radar Chart - Grid Circle Filled
- shadcn Radar Chart - Grid Circle - No lines
- shadcn Radar Chart - Grid Circle
- shadcn Radar Chart - Grid Custom
- shadcn Radar Chart - Grid Filled
- shadcn Radar Chart - Grid None
- shadcn Radar Chart - Icons
- shadcn Radar Chart - Custom Label
- shadcn Radar Chart - Legend
- shadcn Radar Chart - Lines Only
- shadcn Radar Chart - Radius Axis
- shadcn Radial Chart - Grid
- shadcn Radial Chart - Label
- shadcn Radial Chart - Shape
- shadcn Radial Chart
- shadcn Radial Chart - Stacked
- shadcn Tooltip - Default
- shadcn Tooltip - Formatter
- shadcn Tooltip - Icons
- shadcn Tooltip - Line Indicator
- shadcn Tooltip - No Indicator
- shadcn Tooltip - Custom label
- shadcn Tooltip - Label Formatter
- shadcn Tooltip - No Label
Scatterplots and Relationships
Scatterplots answer how two quantitative measures vary together. Position carries the primary evidence. Color, radius, a fitted line, or chronological connections should add one clearly stated dimension rather than compete with that relationship.
Choose the comparison#
| Reader question | Start with |
|---|---|
| Do two quantitative measures move together? | A scatterplot |
| What linear tendency summarizes that relationship? | Scatterplot plus linearRegressionY |
| How does the relationship evolve in a known order? | A connected scatterplot |
| Does a series depend on its previous observation? | A lag plot |
| Which dense point is closest to the pointer or keyboard cursor? | A scatterplot with a spatial focus strategy |
Do not infer causation from proximity or a fitted trend. Show the model and preparation only when they answer the stated question.
Start with two quantitative measures#
A plain scatterplot should establish the relationship before adding a fitted model, chronology, or spatial partition.
import { defineChart, dot } from '@tanstack/charts'
import { scaleLinear } from '@tanstack/charts/scales/linear'
const rows = [
{ temperature: 12, sales: 18 },
{ temperature: 16, sales: 25 },
{ temperature: 20, sales: 31 },
{ temperature: 24, sales: 46 },
{ temperature: 29, sales: 52 },
{ temperature: 32, sales: 61 },
]
const chart = defineChart({
marks: [
dot(rows, {
x: 'temperature',
y: 'sales',
r: 5,
fill: '#2563eb',
}),
],
scales: {
x: {
scale: scaleLinear,
grid: true,
axis: { label: 'Temperature (°C)' },
},
y: {
scale: scaleLinear,
grid: true,
axis: { label: 'Daily sales' },
},
},
})
export default chartAdd a linear regression#
Pass the observations directly to linearRegressionY. The mark owns the least-squares fit, semantic-domain samples, optional confidence band, and aggregate source lineage. Keep the dot layer separate so each observation remains independently focusable.
Set ci: 0 when only the fitted line is needed. The default 0.95 band uses a Student-t interval for the fitted mean. See the linear regression mark for grouping, sampling, and degenerate-fit behavior. The dot layer still preserves every observation while the regression mark owns only its derived model geometry.
Connect observations only when order matters#
A connected scatterplot turns sequence into a path through two-dimensional measure space. Chronological labels and direction arrows make that additional ordering visible.
Without an explicit order, connecting points invents a relationship. Keep the path, arrow, selected labels, and points as separate layers so each can use the same scales without sharing renderer-specific state.
Compare each observation with its predecessor#
A lag plot moves time out of the axis and into data preparation. Each point pairs a current value with the previous value; an identity rule shows where those values would be equal.
Make the lag length explicit and decide how the first observation is handled. The chart should receive the resulting pairs rather than conceal the shift inside a mark.
Separate visible cells from nearest-point focus#
Voronoi cells make each point's nearest region visible. The optional voronoi mark paints those cells but deliberately adds no focus candidates. A layered dot mark remains the semantic source for pointer focus, keyboard navigation, and tooltips.
See the voronoi mark for final-screen cell geometry and stable identity. Tooltips and Focus defines the focus and formatting model. Use a ChartSpatialIndexFactory when lookup performance matters but the cells should not be painted.
Production checks#
- Use quantitative scales with intentional domains on both axes. Use a logarithmic scale only when multiplicative distance is the intended reading; see Scales.
- Map magnitude through an area-preserving radial scale when point size carries a third quantitative value.
- Control opacity or aggregate spatially before thousands of overlapping dots obscure the distribution. See Large Data.
- Keep lag pairs in data preparation. Keep lookup-only spatial indexes in interaction capabilities; use voronoi only when cells are part of the visible encoding.
- Provide keyboard-equivalent focus and a textual value path, as described in Accessibility.
The channel and styling contracts for points are in Dot and Hexagon Marks.