- 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
Maps and Spatial Charts
Spatial charts encode values in a coordinate system whose geometry already has meaning. A geographic map uses a projection and feature boundaries. A vector field uses position, direction, and magnitude. Neither should be treated as an ordinary categorical chart with decorative shapes.
Choose the spatial encoding#
| Reader question | Start with |
|---|---|
| How does an aggregate differ across named regions? | Choropleth |
| Where did individual events occur? | Projected point layer |
| How do direction and magnitude vary over a sampled plane? | Vector field |
| How does a path move through space? | Projected line with directional context |
| Must small regions be compared precisely by value? | Sorted bars or a table beside the map |
The application chooses the projection and spatial sampling policy. The opt-in @tanstack/charts/geo entry uses d3-geo to turn GeoJSON into shared scene paths and interaction points. See Scales.
Compare regional aggregates#
A choropleth joins one value to each named geographic feature and maps that value through a color scale.
The join is part of data preparation. Match features through stable IDs, report unmatched records, and distinguish missing values from zero. Keep the color domain and legend explicit so one filtered region cannot silently rescale the meaning of every other fill.
Area draws attention. A large region can appear important even when its value is ordinary. Pair the map with a sorted table or bars when precise ranking is part of the task.
Legends and Color covers sequential, diverging, and threshold choices.
Prepare atlas boundaries#
TanStack accepts GeoJSON and does not bundle a political boundary dataset. Convert an application-owned TopoJSON atlas once, validate its feature count and IDs, then keep that geometry stable while values change.
import { feature } from 'topojson-client'
import worldAtlas from 'world-atlas/countries-110m.json'
import type {
GeometryCollection,
Objects,
Topology,
} from 'topojson-specification'
interface AtlasProperties {
name: string
}
type WorldObjects = Objects<AtlasProperties> & {
countries: GeometryCollection<AtlasProperties>
}
const topology = worldAtlas as unknown as Topology<WorldObjects>
const countries = feature<AtlasProperties>(topology, topology.objects.countries)world-atlas redistributes Natural Earth boundaries; us-atlas provides Census-derived state geometry. topojson-client.feature performs the standard conversion to GeoJSON consumed by geoShape. These remain application dependencies, so neither their data nor the converter enters ordinary Cartesian or geo-only consumer bundles.
Project GeoJSON responsively#
Give geoShape a projection factory and an explicit fit target. This self-contained example uses a small planar floor plan. The mark fits the projection to the final plot bounds again whenever the chart resizes.
import { defineChart } from '@tanstack/charts'
import { geoShape } from '@tanstack/charts/geo'
import { geoIdentity } from 'd3-geo'
import { floorPlan } from './data'
export default defineChart({
marks: [
geoShape(floorPlan.features, {
key: (feature) => feature.properties.id,
projection: {
type: geoIdentity,
fit: floorPlan,
},
fill: '#dbeafe',
stroke: '#2563eb',
strokeWidth: 1.5,
}),
],
scales: {
x: null,
y: null,
},
margin: 12,
})Support files
interface FloorPlanFeature {
type: 'Feature'
properties: { id: number; name: string }
geometry: {
type: 'Polygon'
coordinates: [number, number][][]
}
}
interface FloorPlan {
type: 'FeatureCollection'
features: FloorPlanFeature[]
}
export const floorPlan: FloorPlan = {
type: 'FeatureCollection',
features: [
{
type: 'Feature',
properties: { id: 1, name: 'Studio' },
geometry: {
type: 'Polygon',
coordinates: [
[
[0, 0],
[48, 0],
[48, 28],
[0, 28],
[0, 0],
],
],
},
},
{
type: 'Feature',
properties: { id: 2, name: 'Office' },
geometry: {
type: 'Polygon',
coordinates: [
[
[52, 0],
[84, 0],
[84, 28],
[52, 28],
[52, 0],
],
],
},
},
],
}geoShape uses geoPath for each feature and D3 centroids for focus. The floor plan's source properties.id supplies stable identity. Supply anchor only when a geographic feature needs a different semantic longitude/latitude than its spherical centroid. The complete option contract is in Geo Shape Mark.
Open the complete 121-polygon Westport House catalog example.
Project points by magnitude#
Point and MultiPoint features use D3 geoPath().pointRadius(). The r channel can carry pixels directly; rScale maps a quantitative value first.
Change the projection#
The same GeoJSON can use any D3 projection factory. Sphere and graticule geometry are ordinary geoShape layers.
Layer routes over geography#
Polygon, LineString, and Point features can share one responsive projection.
Show direction and magnitude#
A vector field places an arrow at each sampled position. Direction uses angle; magnitude can use length, color, or both.
Choose a sampling density that remains legible at the smallest container. More arrows can obscure the flow instead of adding evidence. When pixel length encodes magnitude, define a bounded scale and disclose whether vectors were normalized.
Vector channel and anchor options are listed in Rules, Links, Arrows, Vectors, and Ticks.
Projection and responsive layout#
A projection turns geographic coordinates into planar geometry. Fit it to the resolved plot bounds, not the viewport, and recompute when the chart container changes. Preserve source longitude and latitude alongside projected coordinates for tooltips and selection.
When a custom spatial shape must render beside geoShape:
- Keep path generation deterministic and DOM-free.
- Emit stable scene keys for each feature.
- Clip only when geometry should not extend beyond the plot.
- Emit interaction points or application overlays only where they carry honest semantic anchors.
- Keep projection and geo dependencies behind the spatial chart import.
See Custom Marks and Renderers and Responsive Charts.
Color, boundaries, and missing data#
- Use a sequential scale for ordered magnitude with one direction.
- Use a diverging scale only around a meaningful center.
- Use threshold colors when bins have defined policy meaning.
- Keep boundary strokes visible in light and dark themes without overpowering fill.
- Give missing, suppressed, and out-of-domain features distinct treatment.
- Avoid a categorical palette for high-cardinality numeric values.
A legend is required whenever fill or vector color carries quantitative meaning.
Accessibility and interaction#
A map should not be the only route to critical regional values. Provide a table or list with the same feature names, values, units, and current selection.
For interactive maps:
- Focus and selection should resolve stable feature IDs.
- Zoom and pan state belongs to the application.
- Reset, keyboard, and touch paths should reach equivalent extents.
- Wheel capture should not trap page scrolling unexpectedly.
- Tooltips should name the region or sample, value, and unit.
Interactions and Selections defines the controlled gesture loop.
Production checks#
- Validate feature joins and report unmatched IDs.
- State projection, aggregation unit, date range, and denominator.
- Keep color domains comparable across views and revisions.
- Test antimeridian, empty, missing, and extremely small features where applicable.
- Bound projected point and vector counts.
- Verify labels and legends at narrow widths.
- Provide a non-spatial exact-value path through Accessibility.