Charts Docs
Menu
Chart Guides
- 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
109 lines · 2 files · 3.2 kB
cases/facets-anscombe/example.tsx61 lines · entry
cases/facets-anscombe/example.tsx
import { Chart } from '@tanstack/charts/react/tooltip'
import { tooltip as exampleTooltip } from '@tanstack/charts/tooltip'
import { anscombe } from '@tanstack/charts-data/anscombe'
import { defineChart, dot, facet } from '@tanstack/charts'
import { scaleLinear } from 'd3-scale'
export const createExampleChart = (input: ChartOptions) =>
defineChart(
{
marks: [
facet(anscombe, {
by: 'series',
columns: 4,
gap: input.preview === true ? 4 : 12,
label: input.preview === true ? false : (series) => String(series),
chart: (facetRows) => ({
marks: [
dot(facetRows, {
x: 'x',
y: 'y',
r: 3.5,
fill: '#2563eb',
}),
],
scales: {
x: {
scale: scaleLinear().domain([3, 20]),
grid: input.preview !== true,
axis: input.preview === true ? false : { ticks: { count: 5 } },
},
y: {
scale: scaleLinear().domain([2, 14]),
grid: input.preview !== true,
axis: input.preview === true ? false : { ticks: { count: 4 } },
},
},
}),
}),
],
scales: {
x: null,
y: null,
},
margin: 0,
},
{ keyboard: true, tooltip: exampleTooltip },
)
export interface ChartOptions {
preview?: boolean
}
export const exampleAriaLabel = "Anscombe's quartet small multiples"
export const chart = createExampleChart({
preview: false,
})
export default function Example() {
return <Chart ariaLabel={exampleAriaLabel} definition={chart} height={480} />
}packages/charts-demo-data/src/anscombe.js48 lines · dependency
packages/charts-demo-data/src/anscombe.js
// Generated by scripts/sync-demo-data.mjs from anscombe.csv.
// Do not edit this file directly.
export const anscombe = [
{series: 1, x: 10, y: 8.04},
{series: 1, x: 8, y: 6.95},
{series: 1, x: 13, y: 7.58},
{series: 1, x: 9, y: 8.81},
{series: 1, x: 11, y: 8.33},
{series: 1, x: 14, y: 9.96},
{series: 1, x: 6, y: 7.24},
{series: 1, x: 4, y: 4.26},
{series: 1, x: 12, y: 10.84},
{series: 1, x: 7, y: 4.81},
{series: 1, x: 5, y: 5.68},
{series: 2, x: 10, y: 9.14},
{series: 2, x: 8, y: 8.14},
{series: 2, x: 13, y: 8.74},
{series: 2, x: 9, y: 8.77},
{series: 2, x: 11, y: 9.26},
{series: 2, x: 14, y: 8.1},
{series: 2, x: 6, y: 6.13},
{series: 2, x: 4, y: 3.1},
{series: 2, x: 12, y: 9.13},
{series: 2, x: 7, y: 7.26},
{series: 2, x: 5, y: 4.74},
{series: 3, x: 10, y: 7.46},
{series: 3, x: 8, y: 6.77},
{series: 3, x: 13, y: 12.74},
{series: 3, x: 9, y: 7.11},
{series: 3, x: 11, y: 7.81},
{series: 3, x: 14, y: 8.84},
{series: 3, x: 6, y: 6.08},
{series: 3, x: 4, y: 5.39},
{series: 3, x: 12, y: 8.15},
{series: 3, x: 7, y: 6.42},
{series: 3, x: 5, y: 5.73},
{series: 4, x: 8, y: 6.58},
{series: 4, x: 8, y: 5.76},
{series: 4, x: 8, y: 7.71},
{series: 4, x: 8, y: 8.84},
{series: 4, x: 8, y: 8.47},
{series: 4, x: 8, y: 7.04},
{series: 4, x: 8, y: 5.25},
{series: 4, x: 19, y: 12.5},
{series: 4, x: 8, y: 5.56},
{series: 4, x: 8, y: 7.91},
{series: 4, x: 8, y: 6.89},
]