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 powered by Apache ECharts

Basic Chart

Installation

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

Usage

The ECharts area chart is composable. <EChartsAreaChart> is the container, and every part hangs off it as a compound member — <EChartsAreaChart.Grid>, <EChartsAreaChart.XAxis>, <EChartsAreaChart.YAxis>, <EChartsAreaChart.Legend>, <EChartsAreaChart.Tooltip>, <EChartsAreaChart.Brush>, and one or more <EChartsAreaChart.Area> — so a single import gives you the whole chart. Each <Area> sets its own variant, strokeVariant, and isClickable, so one chart can mix fills, strokes, and selective interactivity.

import { EChartsAreaChart, type ChartConfig } from "@/components/evilcharts/charts/echarts-area-chart";
<EChartsAreaChart data={data} config={chartConfig} stackType="stacked">
  <EChartsAreaChart.Grid />
  <EChartsAreaChart.XAxis dataKey="month" />
  <EChartsAreaChart.Brush />
  <EChartsAreaChart.Legend isClickable />
  <EChartsAreaChart.Tooltip />
  <EChartsAreaChart.Area dataKey="desktop" variant="gradient" strokeVariant="dashed" isClickable />
  <EChartsAreaChart.Area dataKey="mobile" variant="hatched" strokeVariant="solid" isClickable />
</EChartsAreaChart>

The one real difference is under the hood: ECharts renders to a <canvas>, so these children never mount as DOM. The root reads their props and compiles them into the ECharts option — same JSX, same presence semantics (omit a part and it won't render), same behavior, just declarative config instead of live DOM nodes.

The config is the same contract as every EvilCharts chart — each key maps a data key to a label and a per-theme colors array. See Chart Config for the full shape. Colors resolve from CSS variables at runtime, so dark mode just works.

Loading State

isLoading='true'

Examples

Change variant and strokeVariant on an <Area>, or curveType and stackType on the chart, to restyle it.

Hover Highlight

enableHoverHighlight='true'

Buffer Line

enableBufferLine='true'

Hover Reveal

enableHoverReveal='true'

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

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

API Reference

Props are grouped by the part they belong to. On canvas each part is declarative config the root compiles, but the API mirrors the Recharts twin one-to-one.

EChartsAreaChart

The root container. It owns the data, shared selection state, loading skeleton, and optional native dataZoom brush. Everything visual is composed as its children and compiled into the ECharts option.

PropTypeDefaultDescription
data*TData[]

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

config*ChartConfig

Defines the chart's series. Each key matches a data key, with a label and a per-theme colors array. Same contract as every EvilCharts chart — see Chart Config.

children*ReactNode

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

classNamestring

Additional CSS classes for the chart container.

xDataKeykeyof TData & string

Data key for the x-axis categories.

curveTypelinear|smooth|bump|monotone|monotoneX|monotoneY|natural|step"linear"

Default curve interpolation inherited by every <Area />.

animationbooleantrue

Master switch for the intro draw-in. Pass false to render instantly, regardless of animationType.

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

The intro animation inherited by every <Area />. Any value but "none" plays ECharts' native progressive draw-in — the line traces in and dots pop as its front passes (direction values exist for parity with the Recharts twin). "none" disables it; OS reduce-motion falls back to "none" automatically.

enableHoverHighlightbooleanfalse

Highlights the hovered series by dimming the others — the hover twin of click selection, using the same dim levels.

enableHoverRevealbooleanfalse

On hover, colors each area up to the pointer's x-position and mutes the rest to a neutral gray, with the active dot at the cursor. A standalone hover mode that takes visual precedence over enableHoverHighlight; idle, the chart renders normally.

stackTypedefault|stacked|expanded"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.

chartOptionsRecord<string, unknown>

Escape hatch deep-merged into the underlying ECharts option object. See the ECharts option documentation.

Area

A single area series. Each <Area /> carries its own fill and stroke config, 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"

Visual style of the area fill, for this area only. Multi-color configs render the full horizontal gradient faded vertically, matching the Recharts twin.

strokeVariantsolid|dashed|animated-dashed"dashed"

The stroke style for this area.

strokeWidthnumber0.8

Stroke thickness for this area, in pixels.

curveTypelinear|smooth|bump|monotone|monotoneX|monotoneY|natural|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 draw-in for this area (the first <Area />'s value drives the chart). Falls back to the chart's animationType when omitted.

connectNullsbooleanfalse

Whether to connect line segments across null or missing values.

isClickablebooleanfalse

Makes this area selectable on click. When any area is selected, the rest turn semi-transparent.

enableBufferLinebooleanfalse

Renders this area's last segment as a dashed buffer tail while the rest stays solid — useful for projected or incomplete data at the end of a series.

childrenReactNode

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

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"default"

The visual style of the point marker.

XAxis and YAxis

The category and value axes. Include <XAxis /> or <YAxis /> to show each; omit either to hide it. Both hide automatically while loading, and <YAxis /> formats ticks as percentages when stackType="expanded".

PropTypeDefaultDescription
dataKeystring

The data key for the axis values.

tickFormatter(value: string | number, index: number) => string

Formats the axis tick labels.

hideDotsbooleanfalse

Hides the small tick dots that sit beside this axis's labels.

Grid

The background grid lines. Include it to draw the dashed horizontal split lines; omit it and they don't. Takes no props.

Tooltip

The hover tooltip. Include it to enable the tooltip; omit it and none shows. It reads selection state, dimming unselected series in its content.

PropTypeDefaultDescription
variantdefault|frosted-glass"default"

The visual style of the tooltip surface.

roundnesssm|md|lg|xl"lg"

Controls the border-radius of the tooltip.

cursorbooleantrue

Whether the vertical cursor line follows the pointer on hover.

Legend

The series legend, rendered as HTML above the canvas. Include it to show the legend; omit it and none shows. 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 — a themed mini chart driven by ECharts' native dataZoom. Include <EChartsAreaChart.Brush /> to render it; dragging the range filters the main chart.

PropTypeDefaultDescription
heightnumber56

Height of the brush preview strip in pixels.

formatLabel(value: string | number, 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.