elements
Demos UI Feed Discuss Install
Style System
  • Style
  • Themes
  • Behaviors
Forms
  • Button
  • ButtonGroup
  • Checkbox
  • ColorPicker
  • Combobox
  • Field
  • FileUpload
  • Input
  • InputGroup
  • InputOTP
  • Label
  • NativeSelect
  • NumberInput
  • PasswordInput
  • RadioGroup
  • Select
  • Slider
  • Switch
  • TagsInput
  • Textarea
  • Toggle
  • ToggleGroup
Overlays
  • AlertDialog
  • Command
  • ContextMenu
  • Dialog
  • Drawer
  • DropdownMenu
  • HoverCard
  • Menubar
  • NavigationMenu
  • Popover
  • Sheet
  • Toast
  • Tooltip
Display
  • Accordion
  • Alert
  • AspectRatio
  • Avatar
  • Badge
  • Breadcrumb
  • Card
  • Collapsible
  • Empty
  • Item
  • Kbd
  • Pagination
  • Progress
  • Separator
  • Skeleton
  • Spinner
  • Table
  • Tabs
  • Tree
Layout
  • Carousel
  • Resizable
  • ScrollArea
  • Sidebar
Dates
  • Calendar
  • DatePicker
  • DateRangePicker
  • TimePicker
Data
  • AreaChart
  • BarChart
  • Chart
  • DataTable
  • Kanban
  • LineChart
  • PieChart
  • RadarChart
  • RadialChart
  • VirtualList
Chat
  • Attachment
  • Message
  • MessageList
  • PromptInput
Elements UI / Data / AreaChart

AreaChart

Filled areas, stacked or expanded, solid or gradient, with a crosshair tooltip.

Default

A natural curve over a wash of the series color.

Area Chart

Showing total visitors for the last 6 months

JanFebMarAprMayJun
Area chart
MonthDesktop
January186
February305
March237
April73
May209
June214
Trending up by 5.2% this month
January - June 2024
Code
<AreaChart data={rows} config={{ desktop: { label: "Desktop", color: "var(--chart-1)" } }}
           x="month" curve="natural" margin={{ left: 12, right: 12 }}
           categoryAxis={{ tickFormatter: (v) => String(v).slice(0, 3) }}
           tooltip={{ indicator: "line", cursor: false }} />

Usage

import { AreaChart } from "@elements/ui/chart-area";
import type { ChartConfig } from "@elements/ui/chart";

<AreaChart data={rows} {config} x="month" curve="natural" />
<AreaChart data={rows} {config} x="month" series={["mobile", "desktop"]}
           stack="normal" fill="gradient" legend />

Examples

Linear

curve=linear: straight edges.

Area Chart - Linear

Showing total visitors for the last 6 months

JanFebMarAprMayJun
Area chart
MonthDesktop
January186
February305
March237
April73
May209
June214
Code
<AreaChart data={rows} {config} x="month" series={["desktop"]} curve="linear"
           tooltip={{ indicator: "dot", hideLabel: true, cursor: false }} />

Step

curve=step: a held value between categories.

Area Chart - Step

Showing total visitors for the last 6 months

JanFebMarAprMayJun
Area chart
MonthDesktop
January186
February305
March237
April73
May209
June214
Code
<AreaChart data={rows} {config} x="month" series={["desktop"]} curve="step"
           tooltip={{ hideLabel: true, cursor: false }} />

Legend

Stacked areas with a legend under the plot.

Area Chart - Legend

Showing total visitors for the last 6 months

JanFebMarAprMayJun
  • Mobile
  • Desktop
Area chart
MonthMobileDesktop
January80186
February200305
March120237
April19073
May130209
June140214
Code
<AreaChart data={rows} {config} x="month" series={["mobile", "desktop"]}
           curve="natural" stack="normal" legend tooltip={{ indicator: "line", cursor: false }} />

Stacked

stack=normal: each area sits on the one below.

Area Chart - Stacked

Showing total visitors for the last 6 months

JanFebMarAprMayJun
Area chart
MonthMobileDesktop
January80186
February200305
March120237
April19073
May130209
June140214
Code
<AreaChart data={rows} {config} x="month" series={["mobile", "desktop"]}
           curve="natural" stack="normal" tooltip={{ indicator: "dot", cursor: false }} />

Stacked expanded

stack=expand: the stack fills the plot, each area is its share.

Area Chart - Stacked Expanded

Showing total visitors for the last 6 months

JanFebMarAprMayJun
Area chart
MonthOtherMobileDesktop
January4580186
February100200305
March150120237
April5019073
May100130209
June160140214
Code
<AreaChart data={rows} config={{ desktop, mobile, other }} x="month"
           series={["other", "mobile", "desktop"]} curve="natural" stack="expand"
           margin={{ left: 12, right: 12, top: 12 }} tooltip={{ indicator: "line", cursor: false }} />

Icons

A config icon replaces the swatch in the legend and tooltip.

Area Chart - Icons

Showing total visitors for the last 6 months

JanFebMarAprMayJun
  • Mobile
  • Desktop
Area chart
MonthMobileDesktop
January80186
February200305
March120237
April19073
May130209
June140214
Code
const config = {
  desktop: { label: "Desktop", color: "var(--chart-1)", icon: "monitor" },
  mobile: { label: "Mobile", color: "var(--chart-2)", icon: "smartphone" },
};

<AreaChart data={rows} {config} x="month" series={["mobile", "desktop"]}
           curve="natural" stack="normal" legend tooltip={{ indicator: "line", cursor: false }} />

Gradient

fill=gradient fades each area from the line down.

Area Chart - Gradient

Showing total visitors for the last 6 months

JanFebMarAprMayJun
Area chart
MonthMobileDesktop
January80186
February200305
March120237
April19073
May130209
June140214
Code
<AreaChart data={rows} {config} x="month" series={["mobile", "desktop"]}
           curve="natural" stack="normal" fill="gradient" tooltip={{ cursor: false }} />

Axes

A value axis with three ticks; a negative left margin pulls the plot to the card edge.

Area Chart - Axes

Showing total visitors for the last 6 months

JanFebMarAprMayJun0300600
Area chart
MonthMobileDesktop
January80186
February200305
March120237
April19073
May130209
June140214
Code
<AreaChart data={rows} {config} x="month" series={["mobile", "desktop"]}
           curve="natural" stack="normal" margin={{ left: -20, right: 12 }}
           valueAxis={{ tickCount: 3 }} tooltip={{ cursor: false }} />

Interactive

A time range picks the rows; stacked gradient areas with a legend.

Area Chart - Interactive

Showing total visitors for the last 3 months

Apr 3Apr 14Apr 25May 6May 17May 28Jun 8Jun 30
  • Mobile
  • Desktop
Area chart
DateMobileDesktop
2024-04-01356286
2024-04-02222136
2024-04-03333267
2024-04-04489121
2024-04-05293326
2024-04-06448204
2024-04-07152353
2024-04-08219289
2024-04-09186359
2024-04-10325314
2024-04-11141160
2024-04-12527466
2024-04-13307138
2024-04-14199472
2024-04-15351258
2024-04-16238359
2024-04-17534158
2024-04-18218268
2024-04-19259309
2024-04-20445151
2024-04-21267231
2024-04-22509122
2024-04-23491185
2024-04-24219278
2024-04-25289331
2024-04-26394394
2024-04-27214144
2024-04-28158270
2024-04-29293109
2024-04-30392362
2024-05-01256472
2024-05-02328265
2024-05-03472266
2024-05-04305270
2024-05-05219196
2024-05-06175387
2024-05-07442198
2024-05-08527433
2024-05-09481461
2024-05-10389389
2024-05-11130312
2024-05-12270219
2024-05-13285176
2024-05-14430364
2024-05-15522197
2024-05-1627193
2024-05-17305324
2024-05-18536126
2024-05-19486273
2024-05-20317325
2024-05-21453140
2024-05-22231449
2024-05-23185100
2024-05-24413373
2024-05-25485354
2024-05-26469182
2024-05-27136157
2024-05-28129123
2024-05-29469305
2024-05-30181427
2024-05-31142288
2024-06-01325202
2024-06-02269116
2024-06-03244182
2024-06-04177406
2024-06-05120156
2024-06-06156340
2024-06-07166251
2024-06-08294281
2024-06-0943893
2024-06-10430271
2024-06-11511225
2024-06-12388377
2024-06-13271197
2024-06-14490121
2024-06-15149123
2024-06-16248165
2024-06-17372102
2024-06-18278266
2024-06-19501306
2024-06-20297301
2024-06-21498138
2024-06-22330355
2024-06-23405453
2024-06-24526273
2024-06-25295444
2024-06-26415289
2024-06-27504405
2024-06-28536308
2024-06-29468344
2024-06-30152266
Code
<select value={state.range}>...</select>

<AreaChart data={inRange(state.range)} config={dailyConfig} x="date"
           series={["mobile", "desktop"]} curve="natural" stack="normal" fill="gradient"
           legend class="chart-demo-wide"
           categoryAxis={{ tickFormatter: shortDate, minTickGap: 32 }}
           tooltip={{ indicator: "dot", cursor: false, labelFormatter: (_, row) => shortDate(row.date) }} />

Missing values

A null breaks the area; connectNulls fills across it.

JanFebMarAprMayJun
Area chart
MonthDesktop
January186
February305
March
April73
May209
June214
JanFebMarAprMayJun
Area chart
MonthDesktop
January186
February305
March
April73
May209
June214
Code
<!-- a null breaks the area unless connectNulls -->
<AreaChart data={rowsWithNulls} {config} x="month" series={["desktop"]} />
<AreaChart data={rowsWithNulls} {config} x="month" series={["desktop"]} connectNulls />

Labels

Each point's value above the area.

JanFebMarAprMayJun18630523773209214
Area chart
MonthDesktop
January186
February305
March237
April73
May209
June214
Code
<AreaChart data={rows} {config} x="month" series={["desktop"]} curve="natural"
           margin={{ top: 20, left: 12, right: 12 }}
           labels={{ position: "top", offset: 8 }} tooltip={{ cursor: false }} />

Dots, opacity and toggles

Dots on every point, a lighter fill, a thicker line, and a legend that hides series.

JanFebMarAprMayJun
Area chart
MonthDesktopMobile
January18680
February305200
March237120
April73190
May209130
June214140
hidden: none
Code
<AreaChart data={rows} {config} x="month" dots fillOpacity={0.15} strokeWidth={3}
           legend={{ toggle: true, position: "top" }} hidden={state.hidden} />

Controlled and keyboard

Areas with no stroke. Tab to the chart, then arrows, Home, End and Escape.

JanFebMarAprMayJun
Area chart
MonthDesktopMobile
January18680
February305200
March237120
April73190
May209130
June214140
active: -1 changes: 0 clicked: -1
Code
<AreaChart data={rows} {config} x="month" stack="normal" stroke={false}
           active={state.active} onActiveChange={() => state.changes++}
           onItemClick={(i) => state.clicked = i} />

Vertical layout

Months run down the chart and the stacked values across it.

0150300450600JanFebMarAprMayJun
Area chart
MonthDesktopMobile
January18680
February305200
March237120
April73190
May209130
June214140
Code
<!-- months down the chart, values across -->
<AreaChart data={rows} {config} x="month" layout="vertical" stack="normal" valueAxis />

Two value axes

Desktop on the left axis, mobile on its own right axis, each scaled to its data.

JanFebMarAprMayJun080160240320050100150200
  • Desktop
  • Mobile
Area chart
MonthDesktopMobile
January18680
February305200
March237120
April73190
May209130
June214140
Code
<!-- mobile on a second value axis on the right -->
<AreaChart data={rows} {config} x="month" valueAxis={[{}, { orientation: "right", series: ["mobile"] }]} />

Base value

baseValue 200 fills between the line and a target of 200, above and below it.

JanFebMarAprMayJun080160240320
Area chart
MonthDesktop
January186
February305
March237
April73
May209
June214
Code
<!-- fill toward a target of 200 rather than down to zero;
     "dataMin" and "dataMax" fill to the bottom or the top of the axis -->
<AreaChart data={rows} {config} x="month" series={["desktop"]} baseValue={200} valueAxis />

Streamgraph

stack wiggle and silhouette center the layers instead of stacking them on zero.

JanFebMarAprMayJun-1500150300450
Area chart
MonthDesktopMobile
January18680
February305200
March237120
April73190
May209130
June214140
JanFebMarAprMayJun-300-1500150300
Area chart
MonthDesktopMobile
January18680
February305200
March237120
April73190
May209130
June214140
Code
<!-- a streamgraph: layers around a moving center line -->
<AreaChart data={rows} {config} x="month" stack="wiggle" curve="basis" valueAxis />
<AreaChart data={rows} {config} x="month" stack="silhouette" curve="monotone" valueAxis />

Animation timing

animation sets when the marks start moving, how long they take and their easing: a CSS easing name, a cubic-bezier, spring, or a function of progress.

JanFebMarAprMayJun
Area chart
MonthDesktopMobile
January18680
February305200
March237120
April73190
May209130
June214140
Code
<!-- wait 150ms, then take 900ms to enter or move to new data -->
<AreaChart data={rows} {config} x="month" stack="normal"
           animation={{ begin: 150, duration: 900, easing: "linear" }} />

Legend and tooltip types

legendType on a config entry sets that series' legend icon, and none leaves a drawn series out of the legend; tooltipType none leaves it out of the tooltip.

JanFebMarAprMayJun
  • Desktop
  • Mobile
Area chart
MonthDesktopMobileOther
January1868045
February305200100
March237120150
April7319050
May209130100
June214140160
Code
<!-- desktop's legend icon is a line; mobile is left out of the tooltip, other out of the legend -->
<AreaChart data={rows} x="month" legend config={{
  desktop: { label: "Desktop", color: "var(--chart-1)", legendType: "line" },
  mobile: { label: "Mobile", color: "var(--chart-2)", tooltipType: "none" },
  other: { label: "Other", color: "var(--chart-3)", legendType: "none" },
}} />

Dashed edge

strokeDasharray and strokeOpacity on a config entry dash that area's edge and fade it; the other edges stay solid.

JanFebMarAprMayJun
Area chart
MonthDesktopMobile
January18680
February305200
March237120
April73190
May209130
June214140
Code
<!-- strokeDasharray and strokeOpacity on a config entry style that area's edge -->
<AreaChart data={rows} x="month" config={{
  desktop: { label: "Desktop", color: "var(--chart-1)" },
  mobile: { label: "Mobile", color: "var(--chart-2)", strokeDasharray: "4 4", strokeOpacity: 0.5 },
}} />

Reverse stack order

reverseStackOrder stacks the last series first, so the first sits on top; the legend and tooltip keep series order.

JanFebMarAprMayJun
  • Desktop
  • Mobile
Area chart
MonthDesktopMobile
January18680
February305200
March237120
April73190
May209130
June214140
Code
<!-- desktop stacks on top; legend and tooltip keep series order -->
<AreaChart data={rows} {config} x="month" stack="normal" reverseStackOrder legend />

Data table

The data as a table; showTable shows it.

JanFebMarAprMayJun
Area chart
MonthDesktopMobile
January18680
February305200
March237120
April73190
May209130
June214140
Code
<AreaChart data={rows} {config} x="month" showTable={state.table} />

Moving to new data

animation matchBy pairs old and new items by a key, so each month slides to its new place; interpolate draws every frame with a function of your own, here one that starts each point after the one before.

JanFebMarAprMayJun
Area chart
MonthDesktop
January186
February305
March237
April73
May209
June214
JanFebMarAprMayJun
Area chart
MonthDesktop
January186
February305
March237
April73
May209
June214
Code
<!-- each month keeps its point: the window slides instead of every point changing value -->
<AreaChart data={rows} {config} x="month" animation={{ matchBy: matchByDataKey("month") }} />
<!-- (items, t) => the items to draw: each matched item from prev to next, started one after another -->
<AreaChart data={rows} {config} x="month" animation={{ interpolate: stagger }} />
Reference AreaChart in the manual Every part, attribute, slot, key and data attribute.
Prev TimePickerNext BarChart
Product
Manual Pricing Compare
Company
History Contact
Legal
Privacy Policy Acceptable Use Terms License Agreement
© Elements Dev Corporation 2026