Skip to content
h v3.13.3
Search the docs
Find a component, section or page.

Area chart

Stacked or layered areas with a crosshair, soft edges and an entrance sweep.

$8,100 Revenue$3,600 Cost
Aug

Jan to Aug. Revenue: first $3,200, last $8,100, low $3,200, high $8,100. Cost: first $1,800, last $3,600, low $1,800, high $3,600.

Area chart
monthRevenueCost
Jan$3,200$1,800
Feb$4,100$2,100
Mar$3,800$2,400
Apr$5,300$2,600
May$6,100$3,000
Jun$7,200$3,300
Jul$6,900$3,100
Aug$8,100$3,600

Installation

pnpm add @heyramzi/ui

Usage

import { AreaChart } from "@heyramzi/ui/charts";
<AreaChart
  data={[{ month: "Jan", revenue: 3200, cost: 1800 }]}
  xKey="month"
  series={[
    { key: "revenue", label: "Revenue", color: "var(--chart-1)" },
    { key: "cost", label: "Cost", color: "var(--chart-3)" },
  ]}
  height={260}
/>

Examples

Two value axes

Set axis: "right" on a series to give it its own scale on the right. Both axes share one grid, each axis takes its series' colour, and the tooltip shows every series for the hovered day.

3,674 Clicks139,360 Impressions
Last 28 days

Oct 6 to Nov 2. Clicks: first 112, last 143, low 87, high 166. Impressions: first 4,410, last 5,330, low 3,710, high 6,030.

Search clicks and impressions
dateClicksImpressions
Oct 61124,410
Oct 71284,890
Oct 81415,230
Oct 91365,120
Oct 10983,980
Oct 11873,710
Oct 121194,620
Oct 131335,010
Oct 141525,540
Oct 151475,390
Oct 161585,810
Oct 171044,170
Oct 18963,920
Oct 191314,980
Oct 201445,360
Oct 211395,240
Oct 221615,920
Oct 231555,710
Oct 241094,300
Oct 251014,060
Oct 261385,150
Oct 271495,480
Oct 281575,770
Oct 291666,030
Oct 301515,600
Oct 311124,420
Nov 11074,210
Nov 21435,330

Keyboard and accessibility

Key Does
Tab Moves focus to the plot.
Arrow Right Arrow Down Shows the next point's tooltip.
Arrow Left Arrow Up Shows the previous point's tooltip.
Home End Shows the first or last point.
Esc Hides the tooltip.
  • The plot is named by label, "Area chart" by default. A summary follows the name: the range, then each series' first, last, low and high value.
  • The keys read out the point they land on and show the same tooltip as hover.
  • A hidden table lists every point for a screen reader to browse.
  • With reduced motion on, the area draws in place without the reveal.

API reference

data required TData[]
xKey required keyof TData & string
yKey keyof TData & string
series Series[]
color string
Default "var(--chart-series-1)"
height number
Default 240
stacked boolean
Default false
smooth boolean
Default true
edgeFade boolean | number
Default true
Softens the left and right ends of the filled area instead of cutting them off at the plot edge.
formatValue (v: number) => string
Default (v) => v.toLocaleString()
formatX (v: unknown) => string
Default (v) => String(v)
xTicks number
Default 6
reference ChartReference
A target drawn across the plot, like the deal a cost runs up to.
resting { value?: number; values?: Partial<Record<keyof TData & string, number>>; label: string; }
The headline while no point is hovered, like a period total. Defaults to the last point. `values`, keyed by series, shows one figure per series side by side in its colour, so it also reads as the legend.
smoothing Smoothing
Smooths the drawn line by the window shown; the resting figure stays the caller's total.
label string
Default "Area chart"
The chart's accessible name. Its data range and values are read after it.
class string
Prop Type Default
data required TData[]
xKey required keyof TData & string
yKey keyof TData & string
series Series[]
color string "var(--chart-series-1)"
height number 240
stacked boolean false
smooth boolean true
edgeFade

Softens the left and right ends of the filled area instead of cutting them off at the plot edge.

boolean | number true
formatValue (v: number) => string (v) => v.toLocaleString()
formatX (v: unknown) => string (v) => String(v)
xTicks number 6
reference

A target drawn across the plot, like the deal a cost runs up to.

ChartReference
resting

The headline while no point is hovered, like a period total. Defaults to the last point. `values`, keyed by series, shows one figure per series side by side in its colour, so it also reads as the legend.

{ value?: number; values?: Partial<Record<keyof TData & string, number>>; label: string; }
smoothing

Smooths the drawn line by the window shown; the resting figure stays the caller's total.

Smoothing
label

The chart's accessible name. Its data range and values are read after it.

string "Area chart"
class string