011 / RECHARTS / AREA
Prism Area
Single-series magnitude area chart with restrained semantic fill, explicit baseline semantics, and Plotcn shared inspection.
- SPEC
- #011
- ENGINE
- Recharts
- FAMILY
- Area
- RENDERER
- svg
- STATUS
- preview
Installation
Checking public registry…
View local registry JSONCopied as source into your project (requires recharts).
Overview
Prism Area is the foundational single-series component of the Plotcn Area family. It is engineered to communicate quantitative magnitude and volume trends across an ordered domain by combining an authoritative trend stroke with a restrained, semantic area fill anchored to an explicit baseline.
The primary analytical question answered by Prism Area is:
"How does this quantitative magnitude change across the ordered domain relative to its baseline?"
While line charts communicate directional movement, area charts communicate magnitude through occupied visual space. The filled polygon beneath the curve carries analytical weight: it represents the total accumulated quantity between the observation curve and the reference baseline.
Stroke Communicates Direction; Filled Area Communicates Magnitude
import { PrismArea } from "@/components/charts/recharts/area-prism"const requestData = [ { date: "May 01", requests: 12400 }, { date: "May 05", requests: 14800 }, { date: "May 10", requests: 13900 }, { date: "May 15", requests: 18200 }, { date: "May 20", requests: 21500 }, { date: "May 25", requests: 19800 }, { date: "May 30", requests: 24600 },]export function RequestVolumeTrend() { return ( <PrismArea data={requestData} xKey="date" series={{ key: "requests", label: "API Requests", valueFormatter: (v) => `${v.toLocaleString()} req/s`, }} baseline="zero" showGrid lockableTooltip /> )}Line vs. Area: Why Prism Area Exists Separately
In data visualization architecture, an area chart is not merely a line chart with background coloring.
| Consideration | Signal Line (Component 001) | Prism Area (Component 011) |
|---|---|---|
| Primary Question | "What direction is the trend moving?" | "How much magnitude exists relative to a baseline?" |
| Visual Encoding | 1D stroke path (slope and position) | 2D filled polygon (accumulated height and area) |
| Baseline Dependency | Baseline is optional; domain can crop tightly | Baseline is fundamental to the area's quantitative meaning |
| Ideal Metrics | Stock prices, temperature, exchange rates, index points | Volume, storage usage, throughput, session counts, bandwidth |
| Perceived Weight | Minimal visual mass; easy to overlay multiple lines | Substantial visual mass; establishes authoritative hierarchy |
Visualization Principle: Avoid area charts when the baseline has no physical or financial meaning, or when values represent purely relative percentages or index changes where filling to zero distorts perception.
Baseline Semantics & Domain Safeguards
The area polygon fills toward an explicit reference level. Plotcn provides three deliberate baseline modes:
How Configured Baselines Shape Visual Magnitude & Domain Bounds
Fills toward zero. Domain includes 0 even if observations are far above zero (e.g. 90–110).
Fills toward domain minimum. Does not force 0 in the scale; maximizes visual height of variation.
Fills toward an explicit numerical benchmark or threshold. Domain safely encompasses the benchmark.
1. Zero Baseline (baseline="zero", Default)
Conventional magnitude metrics (counts, volume, throughput, bytes) naturally anchor at zero. When baseline="zero" is configured:
- The filled polygon extends from the observation value down to .
- Critical Domain Rule: The automatic Y-scale calculation always includes zero, even if all data points are substantially above zero (e.g. data spanning $92$ to $104$ will scale from $0$ to $110$).
- Anti-Distortion Invariant: Plotcn prevents the common visualization flaw where an area chart truncates its Y-axis at $90$, visually exaggerating variation as though the bottom of the card were zero.
2. Domain-Min Baseline (baseline="domain-min")
When exploring high-baseline trends where variation rather than absolute zero-based magnitude is the primary subject:
- The filled polygon terminates at the lowest visible observation (
baseValue="dataMin"). - The automatic Y-scale frames data tightly around its minimum and maximum values without forcing zero into the scale.
- Analytical Trade-off: Emphasizes local fluctuations at the expense of absolute magnitude comparison.
3. Custom Numeric Baseline (baseline={100})
Useful for evaluating performance relative to a defined quota, capacity ceiling, or SLA target:
- The polygon fills toward the specified numeric value (e.g., ).
- The automatic domain safely encloses both data extrema and the target baseline to prevent polygon clipping.
Positive, Negative & Baseline Crossing
Prism Area preserves positive and negative values without artificial clamping:
Positive Fills Down to Zero; Negative Fills Up to Zero
| Orientation | Direction | Fill Anchor |
|---|---|---|
| Positive Magnitude () | Fills downward | Anchors to baseline |
| Negative Magnitude () | Fills upward | Anchors to baseline |
- Truthful Crossings: Values above zero fill downward to the baseline; values below zero fill upward to the baseline.
- Neutral Color Coding: Prism Area does not automatically switch colors to red below zero. The chart remains semantically neutral, leaving evaluative color encoding to specialized threshold or diverging components.
Color & Fill System
Prism Area implements synchronized stroke, fill, and inspection identities with deterministic override precedence:
| Identity Surface | Resolved Value | Precedence |
|---|---|---|
| Stroke Path & Points | color prop | Explicit color Theme var(--chart-1) |
| Area Polygon Fill | fillColor or color | Explicit fillColor Inherited stroke color fillOpacity |
| Locked Indicator & Pin | selectionColor | Explicit selectionColor var(--chart-selection) |
1. Stroke (color)
Defaults to var(--chart-1). Governs the primary continuous trend stroke, observation markers, and inspection readouts.
2. Area Fill (fillColor & fillOpacity)
By default, the fill automatically inherits the resolved stroke color at fillOpacity={0.2}. If a designer specifies an explicit fillColor (e.g. color="#2563eb" fillColor="#93c5fd"), the explicit fill takes precedence while stroke retains its independent identity.
3. Gradient Mode (gradientMode="fade")
When enabled, Prism Area applies a vertical linear gradient fading from stroke color at the peak down to opacity at the baseline. All gradient <defs> utilize collision-safe, SSR-compliant IDs generated via React.useId(), ensuring multiple area charts can render on the same page without style leakage.
Data & Series Contracts
Prism Area accepts an ordered array of data records:
type PrismAreaDatum = { date: string | Date requests: number | null}Series Configuration Object
interface PrismAreaSeries<TData> { key: NumericKeyOf<TData> label: string valueFormatter?: (value: number) => string}Installation
Install Prism Area directly into your project using the shadcn CLI:
Checking public registry…
View local registry JSONCopied as source into your project (requires recharts).
Component Props
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
data | readonly TData[] | [] | Required | Readonly array of observation records. Caller data is never mutated. |
xKey | keyof TData & string | — | Required | Property name for horizontal domain coordinates (e.g. date, month). |
series | PrismAreaSeries<TData> | — | Required | Single semantic series descriptor declaring metric key, label, and formatter. |
baseline | "zero" | "domain-min" | number | "zero" | Optional | Baseline reference toward which the area fills. |
height | number | string | 320 | Optional | Container height in pixels or standard CSS dimension strings. |
curve | "monotone" | "linear" | "step" | "monotone" | Optional | Curve interpolation algorithm for stroke and area polygon paths. |
domain | [number, number] | ["auto", "auto"] | ["auto", "auto"] | Optional | Vertical Y scale domain. Automatically encloses the active baseline. |
color | string | "var(--chart-1)" | Optional | Stroke color, active marker color, and default auto-fill color. |
fillColor | string | undefined | Optional | Explicit fill color override. Takes precedence over auto-fill. |
fillOpacity | number | 0.2 | Optional | Fill opacity between 0 and 1. |
gradientMode | "none" | "fade" | "none" | Optional | Gradient styling. "fade" renders a collision-safe top-to-bottom opacity gradient. |
selectionColor | string | "var(--chart-selection)" | Optional | Accent color for the locked crosshair and locked inspection indicator. |
showGrid | boolean | true | Optional | Whether to render subtle horizontal Cartesian grid reference lines. |
showLegend | boolean | false | Optional | Whether to render the series identity legend with area swatch sample. |
lockableTooltip | boolean | true | Optional | Enables persistent tooltip locking via click, tap, or Enter/Space. |
missingValuePolicy | "gap" | "carry" | "gap" | Optional | Policy for missing values: honest visual break (gap) or forward fill (carry). |
animation | "draw" | "fade" | "none" | "draw" | Optional | Entry reveal animation. Bypassed automatically under prefers-reduced-motion. |
valueFormatter | (value: number) => string | n.toLocaleString() | Optional | Formatter for Y-axis scale ticks and default tooltip metric readouts. |
xFormatter | (value: string | number) => string | String | Optional | Formatter for horizontal domain tick labels. |
title | string | "Prism Area Chart" | Optional | Accessible title for assistive technologies and screen readers. |
description | string | undefined | Optional | Accessible description detailing metric volume and baseline reference. |
Keyboard Navigation Reference
Prism Area provides a single focused entry point for Cartesian exploration:
| Key | Control Target | Action |
|---|---|---|
| → / ArrowRight | Plot Inspection | Inspect next chronological observation across the domain |
| ← / ArrowLeft | Plot Inspection | Inspect previous chronological observation |
| Home | Plot Inspection | Jump inspection to the first observation |
| End | Plot Inspection | Jump inspection to the latest observation |
| Enter or Space | Plot Inspection | Lock or unlock persistent inspection at the active coordinate |
| Escape | Plot Inspection | Dismiss locked inspection and release pinned tooltip |
Props Reference & Interactive Prop Explorer
Inspect every component property, customize semantic color roles live with instant visual feedback, and copy production-ready code with active prop configurations.
Colors & Appearance Configuration
Customize primary, reference, or annotation series colors. Defaults derive from Plotcn theme tokens.
<PrismArea
data={data}
xKey="date"
series={{
key: "requests",
label: "API Requests",
}}
/>Baseline reference toward which the area fills. "zero" includes 0 in automatic domain; "domain-min" fills to domain minimum.
baseline="zero"Default: "zero"Curve interpolation algorithm for the stroke path and area polygon boundaries.
curve="monotone"Default: "monotone"Stroke line color, active marker color, and default auto-fill color identity.
color="var(--chart-1, #3b82f6)"Default: "var(--chart-1)"Opacity of the translucent area fill (clamped between 0 and 1).
fillOpacity={0.15}Default: 0.2Gradient styling for the area fill. "fade" creates a subtle top-to-bottom opacity fade using collision-safe IDs.
gradientMode="none"Default: "none"Whether to render subtle horizontal Cartesian grid reference lines.
showGrid={true}Default: trueWhether to render the series identity legend with area swatch sample.
showLegend={false}Default: falsePolicy for missing values: honest visual break (gap) or forward fill (carry).
missingValuePolicy="gap"Default: "gap"| Property | Type | Default | Required | Description |
|---|---|---|---|---|
dataReq | readonly TData[] | [] | Yes | Readonly array of observation records. Caller data is never mutated or sorted in place. |
xKeyReq | keyof TData & string | — | Yes | Property name on data records for horizontal domain coordinates. |
seriesReq | PrismAreaSeries<TData> | — | Yes | Single semantic series configuration mapping metric key, label, and valueFormatter. |
baselineOpt | "zero" | "domain-min" | number | "zero" | No | Baseline reference toward which the area fills. "zero" includes 0 in automatic domain; "domain-min" fills to domain minimum. |
heightOpt | number | string | 320 | No | Container height in pixels or standard CSS dimension strings. |
curveOpt | "monotone" | "linear" | "step" | "monotone" | No | Curve interpolation algorithm for the stroke path and area polygon boundaries. |
domainOpt | [number, number] | ["auto", "auto"] | "auto" | "auto" | No | Explicit Cartesian Y scale domain. Automatically encloses the active baseline to prevent false exaggeration. |
colorOpt | string | "var(--chart-1)" | No | Stroke line color, active marker color, and default auto-fill color identity. |
fillColorOpt | string | — | No | Explicit area fill color override. Takes precedence over auto-fill from stroke color. |
fillOpacityOpt | number | 0.2 | No | Opacity of the translucent area fill (clamped between 0 and 1). |
gradientModeOpt | "none" | "fade" | "none" | No | Gradient styling for the area fill. "fade" creates a subtle top-to-bottom opacity fade using collision-safe IDs. |
string | "var(--chart-selection)" | No | Accent color for the locked crosshair and locked inspection status indicator. | |
showGridOpt | boolean | true | No | Whether to render subtle horizontal Cartesian grid reference lines. |
showLegendOpt | boolean | false | No | Whether to render the series identity legend with area swatch sample. |
boolean | true | No | Enables persistent tooltip pinning on click, tap, or Enter/Space. | |
"gap" | "carry" | "gap" | No | Policy for missing values: honest visual break (gap) or forward fill (carry). | |
animationOpt | "draw" | "fade" | "none" | "draw" | No | Initial reveal animation style. Bypassed automatically when reduced motion is preferred. |
(value: number) => string | — | No | Custom formatter for Y-axis numbers and default tooltip metric values. | |
xFormatterOpt | (value: string | number) => string | — | No | Custom formatter for horizontal domain tick labels. |
Component Variants & Edge States
Production cookbooks showcasing configuration variants alongside verified handling of loading, empty data, and network error states.
API Request Volume
Standard single-series magnitude visualization showing daily API request volume relative to a zero baseline.
Explicit Fill Color & Opacity
Independent stroke and fill colors with higher fill opacity to emphasize quantitative volume.
Subtle Vertical Fade Gradient
Area fill with a gentle linear opacity fade from the stroke line toward the zero baseline using collision-safe SVG defs.
Truthful Missing Value Gaps
Missing observations create honest gaps in the area and stroke without collapsing to the baseline or coercing null to zero.
Skeletons indicate runtime fetch or pending data queries.
Handles empty collections ([]) gracefully without crashing.
Graceful failure banner when data source or script fails.
Container-Driven Breakpoints
Prism Area adapts horizontal tick density and axis gutters based on container width while preserving the exact magnitude fill and baseline relationship across all viewports.
Full X-axis ticks, comfortable axis margins, spacious tooltip card, and full area geometry.
Thinned categorical ticks, adaptive padding, and synchronized nearest-X inspection.
Compact gutters, essential ticks, touch scrubbing with pan-y scroll safety, and preserved baseline geometry.
Accessibility & Navigation Standards
Single keyboard tab stop on root figure with ArrowLeft, ArrowRight, Home, End, Enter, and Escape shortcuts. Screen readers announce factual observation metrics and baseline relationships.
Container mounts as region with explicit assistive label.
Stroke line remains visually dominant over the translucent fill; active markers and tooltips provide non-color cues readable in monochrome.
Embeds visually hidden summary (.sr-only) declaring: “Announces domain time, series label, quantitative magnitude, and baseline semantics factually without speculative claims.”
All entrance animations immediately bypass when prefers-reduced-motion is detected in system preferences.
| Key | Action |
|---|---|
| ArrowRight | Inspect next chronological observation. |
| ArrowLeft | Inspect previous chronological observation. |
| Home | Jump inspection to the first observation. |
| End | Jump inspection to the final observation. |
| Enter / Space | Lock or unlock the currently active inspection coordinate. |
| Escape | Release locked selection and dismiss active tooltip. |
Data Safety Checklist
- ✓ Missing Observations Never Collapse to Baseline:
null,undefined, andNaNvalues produce an honest visual break (null ≠ 0). - ✓ Zero Remains a Valid Observation: True zero is rendered at the baseline without being treated as missing or falsy.
- ✓ Automatic Domain Encloses Baseline: When
baseline="zero"is used, $0$ is guaranteed to be within the scale domain to prevent magnitude exaggeration. - ✓ Negative Values Render Truthfully: Negative values fill upward toward the baseline without clamping or taking absolute values.
- ✓ Gradient Never Encodes Data: The fade gradient is purely decorative depth; it never represents probability, uncertainty, or a secondary metric.
- ✓ Collision-Safe SVG Defs: Gradient IDs are generated dynamically via
React.useId()to prevent cross-chart style corruption. - ✓ Immutability: Caller data arrays and series configuration objects are never mutated.
Internal Architecture & File Dependencies
Source-first ownership model. Inspect the exact component call tree, dependencies, and full implementation below.
Handles container dimension measurement and CSS token scoping
Coordinates coordinate scales, Cartesian grid, and Area polygon rendering