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

Installation

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

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.

<script lang="ts">
	import {
		EChartsAreaChart,
		type ChartConfig
	} from '$lib/components/evilcharts/charts/echarts-area-chart/index.js';
</script>
<EChartsAreaChart {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 difference is under the hood: these compound children are declarative configuration slots rather than visual DOM nodes. The root reads their props and compiles an ECharts option, which ECharts paints with Canvas by default or SVG when renderer="svg".

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

Examples

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

SVG Renderer

Pass renderer="svg" to the chart root to opt into ECharts’ SVG renderer. Omit it to use the default Canvas renderer.

Hover Highlight

Buffer Line

Hover Reveal

Gradient Colors

Curve Types

Stack Types

Stroke Variants

Area Variants

Ordered dither

Set renderStyle="dither" to use the independent ordered-dither treatment inspired by Dither Kit. Axes, tooltips, selection, and the ECharts renderer stay intact.

API Reference

Props are grouped by the part they belong to. Regardless of renderer, each part is declarative config the root compiles, but the API mirrors the LayerChart sibling 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*Snippet

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

classstring

Additional CSS classes for the chart container.

renderer canvas| svg"canvas"

Rendering engine used by ECharts. Use "svg" for an SVG-backed chart surface; omit the prop to keep the Canvas default.

renderStyle native| dither"native"

Selects native ECharts paint or EvilCharts’ ordered-dither rendering.

ditherVariant gradient| dotted| hatched| solid"gradient"

Default ordered-dither pattern used by the chart’s series.

ditherCellSizenumber2

Dither cell size in CSS pixels.

bloom off| low| high| aura"off"

Optional glow applied to dithered marks. It has no effect in native rendering mode.

xDataKeykeyof TData & string

Data key for the x-axis categories.

curveType linear| 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.

animationType none| 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 LayerChart sibling). "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.

stackType default| stacked| expanded"default"

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

defaultSelectedDataKeystring | nullnull

The series selected on first render.

selectedDataKeystring | null

Controls the selected series. Leave it undefined to let the chart manage selection; pass null to clear a controlled selection.

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 .

accessibilityChartAccessibility

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

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.

variant gradient| 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 LayerChart sibling.

strokeVariant solid| dashed| animated-dashed"dashed"

The stroke style for this area.

strokeWidthnumber0.8

Stroke thickness for this area, in pixels.

curveType linear| smooth| bump| monotone| monotoneX| monotoneY| natural| 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 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.

ditherVariant gradient| dotted| hatched| solid

Overrides the root ordered-dither pattern for this area only.

childrenSnippet

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

cursorbooleantrue

Whether the vertical cursor line follows the pointer on hover.

Legend

The series legend, rendered as HTML above the chart surface. Include it to show the legend; omit it and none shows. 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 — 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.