Area Chart

Documentation Index

Fetch the complete documentation index at: /llms.txt. Use this file to discover all available pages before exploring further.

Static, beautifully designed area charts

Basic Chart

Installation

npx shadcn@latest add @evilcharts/recharts-area-chart

Usage

The area chart is composable. <EvilAreaChart> is the container; drop in only the parts you need — <EvilAreaChart.Grid>, <EvilAreaChart.XAxis>, <EvilAreaChart.YAxis>, <EvilAreaChart.Legend>, <EvilAreaChart.Tooltip>, and one or more <EvilAreaChart.Area> — as children. Each <EvilAreaChart.Area> owns its variant, strokeVariant, and isClickable, so one chart can mix fills, strokes, and per-series interactivity.

import { EvilAreaChart } from "@/components/evilcharts/charts/recharts-area-chart";
import { type ChartConfig } from "@/components/evilcharts/ui/recharts-chart";
<EvilAreaChart data={data} config={chartConfig} stackType="stacked">
  <EvilAreaChart.Grid />
  <EvilAreaChart.XAxis dataKey="month" />
  <EvilAreaChart.YAxis />
  <EvilAreaChart.Legend isClickable />
  <EvilAreaChart.Tooltip />
  <EvilAreaChart.Area dataKey="desktop" variant="gradient" strokeVariant="dashed" isClickable>
    <EvilAreaChart.Dot variant="border" />
    <EvilAreaChart.ActiveDot variant="colored-border" />
  </EvilAreaChart.Area>
  <EvilAreaChart.Area dataKey="mobile" variant="hatched" strokeVariant="solid" isClickable>
    <EvilAreaChart.ActiveDot variant="colored-border" />
  </EvilAreaChart.Area>
</EvilAreaChart>

Interactive Selection

Add isClickable to any <Area> (and to <Legend>) to make series selectable, then handle events with the onSelectionChange callback on <EvilAreaChart>:

<EvilAreaChart
  data={data}
  config={chartConfig}
  onSelectionChange={(selectedDataKey) => {
    if (selectedDataKey) {
      console.log("Selected:", selectedDataKey);
    } else {
      console.log("Deselected");
    }
  }}
>
  <EvilAreaChart.XAxis dataKey="month" />
  <EvilAreaChart.Legend isClickable />
  <EvilAreaChart.Tooltip />
  <EvilAreaChart.Area dataKey="desktop" variant="gradient" isClickable />
  <EvilAreaChart.Area dataKey="mobile" variant="gradient" isClickable />
</EvilAreaChart>

Loading State

isLoading='true'

Examples

Examples across different variants — mix stackType, curveType, strokeVariant, and areaVariant.

Gradient Colors

gradient colors
gradient colors - bump

Curve Types

curveType='bump'
curveType='step'
curveType='monotoneY'

Stack Types

stackType='default'
stackType='stacked'
stackType='expanded'

Stroke Variants

strokeVariant='solid'
strokeVariant='dashed'
strokeVariant='animated-dashed'

Area Variants

areaVariant='gradient'
areaVariant='gradient-reverse'
areaVariant='solid'
areaVariant='dotted'
areaVariant='lines'
areaVariant='hatched'

API Reference

The chart has several parts. Props below are grouped by component.

EvilAreaChart

The root container. Owns the data, shared selection state, loading skeleton, and optional brush; everything visual is composed as children.

PropTypeDefaultDescription
data*TData[]

The chart data — an array of objects, one per data point (TData extends Record<string, unknown>).

config*Record<string, ChartConfig[string]>

Defines the series — each key matches a data key with a color or color array.

children*ReactNode

The composed chart parts — <Grid />, <XAxis />, <YAxis />, <Legend />, <Tooltip />, and one or more <Area />.

classNamestring

Additional CSS classes for the chart container.

curveType"linear" | "bump" | "natural" | "monotone" | "step" | …"linear"

Default curve interpolation inherited by every <Area />.

animationTypenone|left-to-right|right-to-left|center-out|edges-in"left-to-right"

Direction of the intro reveal inherited by every <Area />. "none" disables it; the OS reduce-motion preference forces "none" automatically.

stackTypedefault|expanded|stacked"default"

How multiple areas combine — independent, stacked, or normalized to 100%.

defaultSelectedDataKeystring | nullnull

The series selected on first render.

onSelectionChange(key: string | null) => void

Fires when a series is selected or deselected via a clickable <Area /> or <Legend />.

isLoadingbooleanfalse

Shows the animated loading skeleton.

loadingPointsnumber14

Number of points in the loading skeleton.

xDataKeykeyof TData & string

X-axis key — only needed by the brush footer.

chartPropsComponentProps<typeof AreaChart>

Escape hatch forwarded to the underlying Recharts AreaChart. See the Recharts AreaChart documentation.

Area

A single area series. Each <Area /> is self-contained, generating its own gradient/pattern definitions, so a chart can hold any number — each with its own variant, stroke, and clickability.

PropTypeDefaultDescription
dataKey*string

The series key. Must exist on both the data rows and the chart config.

variantgradient|gradient-reverse|solid|dotted|lines|hatched"gradient"

The fill style for this area.

strokeVariantsolid|dashed|animated-dashed"dashed"

The stroke style for this area.

strokeWidthnumber0.8

Stroke thickness for this area, in pixels.

curveType"basis" | "bump" | "linear" | "natural" | "monotone" | "step" | …

The curve interpolation for this area. Falls back to the chart's curveType when omitted.

animationTypenone|left-to-right|right-to-left|center-out|edges-in

The intro reveal animation for this area. Falls back to the chart's animationType when omitted.

connectNullsbooleanfalse

Whether to connect line segments across null or missing values.

isClickablebooleanfalse

Lets this area be selected on click. When any area is selected, the rest dim to semi-transparent.

childrenReactNode

Optional <Dot /> and <ActiveDot /> composition that adds point markers to this area.

areaPropsComponentProps<typeof Area>

Escape hatch for raw props forwarded to the underlying Recharts Area component.

Dot and ActiveDot

Point markers composed inside an <Area />. <Dot /> is the resting marker; <ActiveDot /> is the hovered marker. They render nothing on their own — the parent <Area /> reads their variant.

PropTypeDefaultDescription
variantdefault|border|colored-border

The visual style of the point marker.

XAxis and YAxis

The category and value axes. Both use the chart's flat default styling and forward every Recharts axis prop — dataKey, tickFormatter, tickMargin, and the rest pass straight through. Both hide while the chart loads, and <YAxis /> formats ticks as percentages when stackType="expanded".

PropTypeDefaultDescription
dataKeystring

The data key for the axis values.

…axisProps

Every other Recharts XAxis / YAxis prop is forwarded as-is. See the Recharts XAxis and Recharts YAxis documentation.

Grid

The background grid lines. Defaults to horizontal-only dashed lines and forwards every Recharts CartesianGrid prop.

PropTypeDefaultDescription
…gridProps

Every Recharts CartesianGrid prop is forwarded as-is. See the Recharts CartesianGrid documentation.

Tooltip

The hover tooltip. It reads the chart's selection state so its content dims unselected series.

PropTypeDefaultDescription
variantdefault|frosted-glass"default"

The visual style of the tooltip surface.

roundnesssm|md|lg|xl"lg"

Controls the border-radius of the tooltip.

defaultIndexnumber

When set, the tooltip is visible by default at the specified data point index.

cursorbooleantrue

Whether the vertical cursor line follows the pointer on hover.

Legend

The series legend. When isClickable is set, each entry toggles selection of its series.

PropTypeDefaultDescription
variantsquare|circle|circle-outline|rounded-square|rounded-square-outline|vertical-bar|horizontal-bar

The visual style of the legend indicators.

alignleft|center|right"right"

Horizontal placement of the legend.

verticalAligntop|middle|bottom"top"

Vertical placement of the legend.

isClickablebooleanfalse

Lets each legend entry toggle selection of its series.

Brush

An optional zoom brush below the chart. Include <EvilAreaChart.Brush /> to render it; dragging the range filters the main chart.

PropTypeDefaultDescription
heightnumber

Height of the brush preview strip in pixels.

formatLabel(value: unknown, index: number) => string

Formats the range-handle labels below the brush.

onChange(range: { startIndex: number; endIndex: number }) => void

Fires when the brush selection range changes.