- 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
Heatmaps and Densities
Heatmaps and density charts answer where values concentrate across two dimensions. A matrix uses explicit row and column categories or intervals. Contours summarize a regular scalar grid or an estimated point field; spatial bins summarize local observations. Choose the representation that preserves the question instead of defaulting to one color per raw observation.
Choose the comparison#
| Reader question | Start with |
|---|---|
| How does daily activity vary by week and weekday? | Token use calendar heatmap |
| How many observations fall in each quantitative x-y interval? | Binned quantitative heatmap |
| What regions of a regular scalar grid cross selected levels? | Scalar-grid contours |
| What smooth regions enclose similar point density? | Density contours |
| Where are dense clusters while retaining local bin shape? | Hexagonal bins |
| What value belongs to each pair of named categories? | An ordinal cell matrix |
Data and Channels explains interval and color channels. Legends and Color covers continuous color meaning and accessible legend design.
Start with a labeled matrix#
An ordinal matrix uses categories on both axes and one quantitative value for each cell. Direct labels preserve exact values while color makes broad patterns visible.
import { cell, colorGradientLegend, defineChart, text } from '@tanstack/charts'
import { scaleBand } from '@tanstack/charts/scales/band'
import { scaleLinear } from 'd3-scale'
import { quarters, scores, teams } from './data'
export default defineChart({
marks: [
cell(scores, {
x: 'quarter',
y: 'team',
color: 'score',
key: (row) => `${row.team}-${row.quarter}`,
inset: 1,
}),
text(scores, {
x: 'quarter',
y: 'team',
text: (row) => row.score.toFixed(0),
fill: '#0f172a',
fontWeight: 650,
}),
],
scales: {
x: {
scale: () => scaleBand<string>().domain(quarters).padding(0.04),
axis: { label: 'Quarter' },
},
y: {
scale: () => scaleBand<string>().domain(teams).padding(0.04),
axis: { label: 'Team' },
},
},
color: {
scale: () =>
scaleLinear<string>().domain([60, 100]).range(['#eff6ff', '#60a5fa']),
legend: colorGradientLegend({ label: 'Score', steps: 8 }),
},
})Support files
export const quarters = ['Q1', 'Q2', 'Q3', 'Q4']
export const teams = ['Core', 'Cloud', 'Mobile']
export const scores = [
{ team: 'Core', quarter: 'Q1', score: 72 },
{ team: 'Core', quarter: 'Q2', score: 78 },
{ team: 'Core', quarter: 'Q3', score: 84 },
{ team: 'Core', quarter: 'Q4', score: 88 },
{ team: 'Cloud', quarter: 'Q1', score: 66 },
{ team: 'Cloud', quarter: 'Q2', score: 74 },
{ team: 'Cloud', quarter: 'Q3', score: 81 },
{ team: 'Cloud', quarter: 'Q4', score: 86 },
{ team: 'Mobile', quarter: 'Q1', score: 82 },
{ team: 'Mobile', quarter: 'Q2', score: 79 },
{ team: 'Mobile', quarter: 'Q3', score: 91 },
{ team: 'Mobile', quarter: 'Q4', score: 94 },
]Bin events into a calendar#
A contribution-style calendar exposes both long-term activity and weekday rhythm without drawing one long daily time axis. This example aggregates raw, session-level token events into a complete twelve-month UTC day domain, then maps Sunday weeks to columns and weekdays to rows.
The example uses binTimeX with D3's utcDay interval and an explicit twelve-month domain. Each output row contains the day interval, the summed token count, the session count, and source lineage. Empty bins become real zero-value days and share one consistent neutral treatment.
Calendar placement is a second, explicit step: utcSunday.count produces the week column and date.getUTCDay() selects the row. A categorical usage scale creates contribution-style levels, while the accessible chart description and cell color explain the zero-to-high usage range. The compact focus tooltip keeps the visible detail to the exact token total and date. Keep all calendar calculations in one time basis—UTC here—to avoid moving events between days around daylight-saving transitions.
Aggregate into quantitative cells#
A two-dimensional binned heatmap makes density bounded: the number of rendered cells depends on the chosen grid, not directly on the number of raw points.
Prepare explicit x and y interval endpoints plus the aggregate value. Use thresholds that are stable across comparable views and a color domain that states whether absolute count or normalized density is being shown. See Scales for binning and scale ownership.
Trace levels through a scalar grid#
A scalar-grid contour shows where a sampled field crosses chosen values. The input is a regular row-major grid rather than a set of x/y observations.
The optional contour mark accepts the raw grid, dimensions, value channel, and levels. It owns marching-squares topology and structured polygons; the chart definition retains the metric and threshold choices. Keep grid orientation and dimensions explicit when changing the sample window.
Estimate point concentration with density contours#
Density contours turn many points into nested level sets. They are useful for revealing cluster shape and overlap when raw dots would occlude one another.
Bandwidth and thresholds change the visible shape. Treat them as analytical parameters, keep them stable for comparisons, and explain them when they affect interpretation. The optional densityContour mark maps the source channels through final scales, owns responsive estimation, and emits structured polygons and holes without case-owned path construction.
Retain local structure with hexagonal bins#
Hexagonal bins aggregate nearby points in pixel space and encode each bin's count or statistic. They provide a compact alternative when a rectangular grid would impose stronger horizontal and vertical edges.
Pixel-space binning is responsive work: a changed container changes the spatial layout. The optional hexbin mark owns that resolved-layout step, reducer channels, source lineage, and hexagon scene output without a duplicated scale.
Production checks#
- State whether color represents count, proportion, rate, or another aggregate.
- Choose a sequential, diverging, or threshold scale that matches the data semantics.
- Keep missing, zero, and out-of-domain cells visually distinct.
- Add direct labels only when cells remain large enough to read. A labeled ordinal matrix is demonstrated in Themes and Styling.
- Prefer aggregation over rendering an unbounded raw point layer. See Large Data.