- 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
Lines and Areas
Lines answer how a value changes across an ordered domain. Areas add a second meaning: distance from a baseline or the span between two boundaries. Use that extra area only when the reader should compare magnitude, accumulation, or an interval—not merely because a filled chart looks stronger.
Choose the comparison#
| Reader question | Start with |
|---|---|
| How does one measure change over time? | One line with an explicit temporal scale |
| How do several measures change together? | Several lines with direct labels or a legend |
| Where does one measure exceed another? | A difference mark with distinct positive and negative fills |
| What is the local trend after reducing short-term noise? | A raw line plus a clearly named rolling statistic |
| What range surrounds a central estimate? | An area with explicit lower and upper channels |
| Which observations deserve explanation? | A line plus selected text, dots, rules, or bands |
| How does composition change over time? | A stacked or normalized area in Stacked and Composed Charts |
The x domain must have a meaningful order. Do not connect nominal categories just because they appear in an array.
Start with one ordered series#
Use one line when the first task is reading change over a shared sequence. Points keep the individual observations available for focus and tooltips.
import { defineChart, lineY } from '@tanstack/charts'
import { scaleLinear } from '@tanstack/charts/scales/linear'
import { scalePoint } from '@tanstack/charts/scales/point'
const rows = [
{ month: 'Jan', downloads: 42 },
{ month: 'Feb', downloads: 58 },
{ month: 'Mar', downloads: 51 },
{ month: 'Apr', downloads: 73 },
{ month: 'May', downloads: 81 },
]
const chart = defineChart({
marks: [
lineY(rows, {
x: 'month',
y: 'downloads',
points: true,
stroke: '#2563eb',
lineCap: 'butt',
}),
],
scales: {
x: { scale: () => scalePoint<string>().padding(0.2) },
y: {
scale: scaleLinear,
nice: true,
grid: true,
axis: { label: 'Downloads (thousands)' },
},
},
})
export default chartlineCap: 'butt' ends the stroke at each path endpoint. Omit it to retain the default round endpoints. lineX accepts the same lineCap and lineJoin options.
Compare several series from a common baseline#
Indexing each series to its first observation compares relative change when the original magnitudes are not directly comparable. Direct end labels reduce the work of matching line colors to a separate legend.
Prepare the indexed values in the application, state the baseline, and retain the original values for exact-value disclosure. Use a stable series channel so color, path grouping, focus, and updates agree on identity. Data and Channels covers series grouping, while Legends and Color explains when a separate legend is the better choice.
Show a derived trend honestly#
A moving average is a derived series, not a visual curve setting. Prepare the rolling values with the public rollingWindow transform beside the definition, keep the original time domain, and name the rolling window in surrounding text or a legend.
Changing interpolation only changes the path between observations. It does not perform smoothing or create evidence between samples. See Data Transforms for rolling windows and reducers.
Compare two boundaries at their exact crossings#
A difference chart separates the intervals where a primary series is above or below a comparison. Keep any rolling statistic or forecast calculation in data preparation, then give both boundaries to differenceY:
differenceY(rows, {
x: 'Date',
y1: 'average',
y2: 'Close',
positiveFill: '#16a34a',
negativeFill: '#dc2626',
comparisonStroke: '#475569',
})The mark finds each sign change, interpolates the exact crossing, and owns the positive area, negative area, comparison line, and primary line. Application code does not need to prepare sign runs or duplicate boundary rows.
The Overview shows the complete rendered Apple closing-price example. See Difference Marks for transposed differenceX, gap behavior, fill suppression, lineage, and interaction.
Add context with an interval#
A Bollinger band combines a rolling center line with an interval derived from local variation. The band is context for the observed series; it is not a confidence interval unless the underlying calculation actually defines one.
Compute the rolling statistics once and share those rows between the interval and center line:
const bands = rollingWindow(aapl, {
size: 20,
orderBy: 'Date',
anchor: 'end',
partial: false,
outputs: {
meanClose: { value: 'Close', reduce: 'mean' },
closeDeviation: { value: 'Close', reduce: deviation },
},
})
areaY(bands, {
x: 'Date',
y1: (row) => row.meanClose - row.closeDeviation * 2,
y2: (row) => row.meanClose + row.closeDeviation * 2,
})
lineY(bands, { x: 'Date', y: 'meanClose' })The rolling-window length, estimator, and multiplier are authored statistical meaning. The transform owns ordering and source lineage; the area owns interval geometry. See Line and Area Marks for the channel contracts.
Annotate selected observations#
Annotations should explain a small number of meaningful points. Selecting the minimum and maximum in data preparation makes the intent auditable and avoids placing a text label on every observation.
Layer dots and text over the same scales rather than baking labels into a line renderer. Marks and Layering explains why separate layers remain easier to update and extend.
Production checks#
- Preserve missing values when a gap is meaningful. The Quick Start demonstrates an explicit line gap.
- Use a temporal scale for dates and define the domain in application data semantics, as described in Scales.
- Preserve row IDs or unique positions across updates, and group series with z; supply key only when the mark cannot infer identity. See Dynamic Data and Animation.
- Let automatic layout measure tick labels, then verify the smallest container in Responsive Charts.
- Use position, labels, or line treatment in addition to color when a distinction is essential. See Accessibility.