Area Chart

Documentation Index

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

Area charts with stacked, gradient, pattern, and reveal variants

Installation

npx shadcn-svelte@latest add https://evilcharts-sv.vercel.app/r/layerchart-area-chart.json

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.

<script lang="ts">
	import { EvilAreaChart } from '$lib/components/evilcharts/charts/layerchart-area-chart';
	import { type ChartConfig } from '$lib/components/evilcharts/ui/layerchart-chart';
</script>
<EvilAreaChart {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}
	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

Examples

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

Gradient Colors

Curve Types

Stack Types

Stroke Variants

Area Variants

Dither rendering

Set renderStyle="dither" on the existing chart root to paint its series with a responsive ordered-dither canvas while the SVG marks continue to own tooltips, selection, dots, and brush interaction. Use ditherVariant on an individual <Area /> to override the root texture.

The renderer is independently implemented for EvilCharts SV and inspired by Dither Kit by Boring Software.

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*Snippet

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

accessibilityChartAccessibility

Names and optionally describes the chart wrapper. It remains a group, so interactive legends and marks stay available to assistive technology.

classNamestring

Additional CSS classes for the chart container.

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

Default curve interpolation inherited by every <Area />.

animationType none| 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.

stackType default| 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.

renderStyle svg| dither"svg"Selects the SVG or ordered-dither renderer.
ditherVariant gradient| dotted| hatched| solid"gradient"Default texture for dithered series.
ditherCellSizenumber2Dither cell size in CSS pixels.
bloom off| low| high| aura"off"Optional bounded glow around dither pixels.
chartPropsComponentProps<typeof AreaChart>

Escape hatch forwarded to the underlying LayerChart Chart. See the LayerChart Chart 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.

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

The fill style for this area.

strokeVariant solid| 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.

animationType none| 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.

childrenSnippet

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

areaPropsComponentProps<typeof Area>

Escape hatch for raw props forwarded to the underlying LayerChart 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
variant default| 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 LayerChart 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 LayerChart axis prop is forwarded as-is. See the LayerChart Axis documentation .

Grid

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

PropTypeDefaultDescription
…gridProps

Every LayerChart grid prop is forwarded as-is. See the LayerChart Grid documentation .

Tooltip

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

PropTypeDefaultDescription
variant default| frosted-glass"default"

The visual style of the tooltip surface.

roundness sm| 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
variant square| circle| circle-outline| rounded-square| rounded-square-outline| vertical-bar| horizontal-bar

The visual style of the legend indicators.

align left| center| right"right"

Horizontal placement of the legend.

verticalAlign top| 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.