016 / RECHARTS / AREA
Gradient Depth Area
Single-series area visualization with a semantic fade-to-surface fill that adds restrained depth without encoding an additional variable.
- SPEC
- #016
- ENGINE
- Recharts
- FAMILY
- Area
- RENDERER
- svg
- STATUS
- preview
Installation
Checking public registry…
View local registry JSONCopied as source into your project (requires recharts).
Overview
Gradient Depth Area is the depth-specialized single-magnitude chart of the Plotcn Area family. It visualizes a single quantitative magnitude series across an ordered domain, featuring a controlled semantic opacity fade from the signal boundary toward the chart surface.
The primary analytical question answered by Gradient Depth Area is:
"How does this magnitude change across the ordered domain?"
Its visual specialization is:
"Can the area retain useful magnitude while visually dissolving into the surrounding surface instead of behaving like a flat translucent block?"
Unlike decorative gradients that use arbitrary rainbow spectrums or glow filters, Gradient Depth Area employs a semantic fade-to-surface. The stroke and gradient share one single semantic series identity; opacity gradually tapers downward so the chart surface underneath emerges naturally.
import { GradientDepthArea } from "@/components/charts/recharts/area-gradient-depth"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 ApiRequestVolume() { return ( <GradientDepthArea data={requestData} xKey="date" series={{ key: "requests", label: "API Requests", valueFormatter: (v) => `${v.toLocaleString()} reqs`, }} color="var(--chart-1)" gradientMode="surface" fillOpacity={0.32} baseline="zero" showGrid /> )}Area-Family Positioning
The Plotcn Area family provides six distinct analytical instruments:
| Consideration | Prism Area (011) | Stack Flow Area (012) | Percent Stream Area (013) | Range Area (014) | Comparison Area (015) | Gradient Depth Area (016) |
|---|---|---|---|---|---|---|
| Primary Question | "How much magnitude relative to baseline?" | "How do parts and total combine?" | "How does the composition of the whole evolve?" | "What envelope contains the observations?" | "How does primary compare with reference?" | "How does magnitude change with visual surface depth?" |
| Fill Geometry | Uniform translucent fill to baseline | Additive stacked layers to total | 100% normalized proportional shares | Fills between lower and upper bounds | Overlapping dual fills to shared baseline | Semantic fade-to-surface fill to baseline |
| Series Roles | Single series | additive series | proportional series | Bounded envelope + optional center | Exactly two: Primary & Reference | Single quantitative series |
| Baseline Role | Configurable ( or min) | Fixed baseline () | Fixed baseline () | No baseline; lower bound is floor | Shared baseline for both roles | Shared baseline ( or domain min) |
| Visual Depth | Flat fill | Flat stacked layers | Flat normalized streams | Bounded interval fill | Restrained overlap | Controlled opacity fade (32% → 2%) |
Gradient Depth Area vs Prism Area (011)
- Prism Area: Uses a uniform, flat semantic fill. Preferred when styling must remain completely neutral or when presenting dense dashboards with multiple adjacent visual elements.
- Gradient Depth Area: Uses a controlled opacity taper from the signal boundary toward the surface. The stroke defines the exact quantitative trend while the fill adds visual depth without introducing additional cognitive weight.
Depth Model
Stroke Defines Trend; Controlled Opacity Fade Dissolves into Surface
1. Signal-to-Surface Opacity Attenuation
At every domain coordinate :
- Signal Boundary (0% Stop): Renders at the maximum configured
fillOpacity(default:0.32). The crisp 2px solid stroke provides the authoritative quantitative boundary. - Transition Region (55% Stop): Opacity gently attenuates to of the leading value (default:
0.14). - Surface Threshold (100% Stop): Opacity dissolves to , allowing the chart card surface or page background to emerge seamlessly without a hard boundary.
Gradient Semantics
Gradient opacity does not signify:
- Higher or lower statistical confidence.
- Probability distribution or uncertainty bounds.
- Kernel density or observation concentration.
- Projected future values versus observed history.
The visual fade is an aesthetic technique for surface integration and depth perception. The data contains strictly one quantitative number per observation coordinate.
Baseline Semantics
Gradient Depth Area fills toward an explicit, truthful baseline:
"zero"(Default): Fills toward . The automatic domain calculation ensures $0$ is enclosed within the vertical axis scale."domain-min": Fills toward the minimum value observed across the visible domain. Ideal for elevated series where zero is far removed from the operating range.- Explicit Numeric Baseline: Fills toward a specific user-configured threshold (e.g.
baseline={100}).
[!CAUTION] Data Integrity: Plotcn never fades toward an artificial canvas bottom when the mathematical baseline is elsewhere. The linear gradient aligns strictly with the data coordinate space.
Data Contract
Gradient Depth Area accepts a readonly array of observation records. Caller data is never mutated or sorted in place.
export interface RequestVolumePoint { date: string // Chronological or ordinal domain key requests: number | null // Single quantitative magnitude}Truthful Missing Values
| Observation at Coordinate | Boundary Stroke | Depth Area Fill | Tooltip Status | Accessibility Announcement |
|---|---|---|---|---|
| Valid Number ($18,200$) | Continuous stroke | Fading depth area | Formatted value | Factual observation read |
| Zero ($0$) | Rendered at | Collapsed to baseline | $0 | Zero read as real value |
| Missing ( or ) | Visual gap | Area gaps | "Unavailable" | Announced as unavailable |
| Non-finite (, ) | Sanitized to null | Area gaps | "Unavailable" | Sanitized safely |
Series Contract
Gradient Depth Area is strictly specialized for a single series. Configuration is passed via the series prop:
| Property | Type | Required | Description |
|---|---|---|---|
key | NumericKeyOf<TData> | Yes | Property key on observation records containing metric values |
label | string | Yes | Descriptive label for tooltips, legend, and screen readers |
valueFormatter | (value: number) => string | Optional | Optional custom numeric formatter for values and tooltips |
Color Customization
Gradient Depth Area accepts semantic CSS theme tokens or custom color overrides:
<GradientDepthArea data={data} xKey="date" series={series} color="var(--chart-1)" // Primary stroke and all gradient stops selectionColor="var(--chart-selection)" // Active locked crosshair line gradientMode="surface" // "surface" | "none" fillOpacity={0.32} // Leading boundary opacity (0.1 to 1.0)/>- Single Color System: Changing
colorsynchronizes the boundary stroke, all three gradient stops, active inspection dots, and tooltips simultaneously without remounting or replaying animations. - Fade-to-Surface via Opacity: Plotcn fades stops by varying
stopOpacityagainst the singlecolor. No background hex codes are hardcoded, ensuring instant portability across Light, Dark, and custom card backgrounds.
Props Reference
| Property | Type | Default | Description |
|---|---|---|---|
data | readonly TData[] | [] | Readonly array of observation records. Caller data is never mutated. |
xKey | keyof TData & string | required | Property key representing horizontal domain coordinates. |
series | GradientDepthAreaSeries<TData> | required | Single series configuration declaring key, label, and optional formatter. |
height | number | string | 320 | Container height in pixels or CSS units. |
curve | "monotone" | "linear" | "step" | "monotone" | Interpolation curve applied to boundary stroke and area geometry. |
domain | [number, number] | "auto" | "auto" | Explicit vertical domain override. Defaults to auto-padded scale enclosing baseline. |
baseline | "zero" | "domain-min" | number | "zero" | Baseline reference toward which the area fills. |
color | string | var(--chart-1) | Primary series color applied to stroke, active marker, and gradient stops. |
selectionColor | string | var(--chart-selection) | Accent color for active crosshair and pinned inspection state. |
gradientMode | "surface" | "none" | "surface" | Depth fill style: "surface" (semantic fade) or "none" (flat fill). |
fillOpacity | number | 0.32 | Leading fill opacity at the signal boundary (0.05 to 1.0). |
showGrid | boolean | true | Whether to render subtle horizontal Cartesian grid reference lines. |
showXAxis | boolean | true | Whether to render horizontal domain tick labels. |
showYAxis | boolean | true | Whether to render vertical metric scale ticks. |
showLegend | boolean | false | Whether to render series identity indicator. |
lockableTooltip | boolean | true | Enables persistent tooltip pinning on click, tap, or Enter/Space. |
missingValuePolicy | "gap" | "connect" | "gap" | Policy for missing data: "gap" preserves truthful breaks; "connect" bridges gaps visually. |
motion | boolean | { duration?: number } | true | Enables entry draw animation. Automatically bypassed under reduced motion. |
valueFormatter | (value: number) => string | n.toLocaleString() | Formatter for metric values and tooltips. |
xFormatter | (value: string | number) => string | — | Formatter for horizontal tick labels. |
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.
<GradientDepthArea
data={data}
xKey="date"
seriesKey="value"
/>Controls depth fill style. "surface" applies a semantic fade toward chart surface; "none" renders a flat fill.
gradientMode="surface"Default: "surface"Leading fill opacity at the signal boundary (0.05 to 1.0). Subordinate gradient stops derive proportionally.
fillOpacity={0.32}Default: 0.32Baseline reference toward which the area fills. "zero" includes 0 in automatic domain; "domain-min" fills to domain minimum.
baseline="zero"Default: "zero"Interpolation curve applied to the signal boundary stroke and filled area geometry.
curve="monotone"Default: "monotone"Whether to render subtle horizontal Cartesian grid reference lines.
showGrid={true}Default: trueWhether to render series identity legend.
showLegend={false}Default: falseEnables persistent inspection pinning on click or keyboard Enter/Space.
lockableTooltip={true}Default: truePolicy for missing data: "gap" preserves truthful breaks; "connect" bridges across missing observations.
missingValuePolicy="gap"Default: "gap"Enables entrance path animation. Automatically bypassed when prefers-reduced-motion is active.
motion={true}Default: true| 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 | GradientDepthAreaSeries<TData> | — | Yes | Single semantic series configuration mapping metric key, label, and valueFormatter. |
gradientModeOpt | "surface" | "none" | "surface" | No | Controls depth fill style. "surface" applies a semantic fade toward chart surface; "none" renders a flat fill. |
fillOpacityOpt | number | 0.32 | No | Leading fill opacity at the signal boundary (0.05 to 1.0). Subordinate gradient stops derive proportionally. |
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 CSS units. |
curveOpt | "monotone" | "linear" | "step" | "monotone" | No | Interpolation curve applied to the signal boundary stroke and filled area geometry. |
domainOpt | [number, number] | "auto" | "auto" | No | Explicit Y-axis numeric domain bounds, or "auto" for auto-padded safe scale enclosing baseline. |
colorOpt | string | var(--chart-1) | No | Primary semantic series color applied to stroke, active marker, and all gradient stops. |
string | var(--chart-selection) | No | Color for active locked observation crosshair reference line. | |
showGridOpt | boolean | true | No | Whether to render subtle horizontal Cartesian grid reference lines. |
showXAxisOpt | boolean | true | No | Whether to render horizontal domain tick labels. |
showYAxisOpt | boolean | true | No | Whether to render vertical metric scale ticks. |
showLegendOpt | boolean | false | No | Whether to render series identity legend. |
boolean | true | No | Enables persistent inspection pinning on click or keyboard Enter/Space. | |
"gap" | "connect" | "gap" | No | Policy for missing data: "gap" preserves truthful breaks; "connect" bridges across missing observations. | |
motionOpt | boolean | { duration?: number } | true | No | Enables entrance path animation. Automatically bypassed when prefers-reduced-motion is active. |
Component Variants & Edge States
Production cookbooks showcasing configuration variants alongside verified handling of loading, empty data, and network error states.
Basic Semantic Depth
Default single-series request volume with controlled fade-to-surface depth.
Deep Fade
Prominent leading boundary opacity tapering cleanly into the background.
Flat Fill (No Fade)
Disables gradient fade to compare against uniform semantic area fill.
Domain Min Baseline
Fills toward the domain floor rather than zero for elevated ranges.
Linear Interpolation
Piecewise linear segments demonstrating deterministic vertex alignment.
With Legend
Displays series identity indicator and fill description.
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
Gradient Depth Area preserves single-series magnitude, semantic fade geometry, and nearest-X inspection across all device widths down to 320px.
Spacious vertical gradient fade, full domain ticks, horizontal legend option, and detailed inspection card.
Adaptive domain tick thinning, preserved gradient depth ratio, and compact tooltip gutters.
Compact gutters, truthful missing gaps, touch-forgiving nearest-X inspection, and uncompromised semantic gradient fill.
Accessibility & Navigation Standards
Single keyboard tab stop on root figure with ArrowLeft, ArrowRight, Home, End, Enter/Space, and Escape shortcuts. Structured data table provided for assistive technologies.
Container mounts as region with explicit assistive label.
High-contrast stroke (2px), active circle marker, persistent crosshair, and offscreen structured HTML data table ensure complete non-color accessibility.
Embeds visually hidden summary (.sr-only) declaring: “Announces domain coordinate and quantitative series value. Gradient depth is treated purely as styling and is never announced as an additional variable.”
All entrance reveal animations immediately bypass when prefers-reduced-motion is detected in user system preferences.
| Key | Action |
|---|---|
| ArrowRight | Inspect next chronological observation across the domain. |
| ArrowLeft | Inspect previous chronological observation across the domain. |
| Home | Jump inspection directly to the first observation. |
| End | Jump inspection directly to the final observation. |
| Enter / Space | Lock or unlock persistent inspection at the active coordinate. |
| Escape | Release locked selection and dismiss active inspection tooltip. |
Data Safety Guarantees
- Styling Is Not Data: Gradient opacity never encodes confidence, density, probability, or a second variable.
- Deterministic Single Series: Specialized strictly for one series; multi-series stacking is prohibited.
- Truthful Missing Values: Missing observations () break geometry cleanly; zero is never substituted.
- Finite Coordinates Only: Non-finite coordinates (
NaN,Infinity) are sanitized before reaching SVG paths. - No Baked Backgrounds: Gradients fade via opacity; no hardcoded background colors are baked into the component.
- SSR-Safe Gradient IDs: Dynamic IDs generated via
React.useId()prevent cross-instance gradient collisions. - Caller Immutability: Original caller records are never mutated or sorted in place.
- Accessibility Disclosure: Off-screen structured HTML data table disclosure provides full non-visual access to all values.
Internal Architecture & File Dependencies
Source-first ownership model. Inspect the exact component call tree, dependencies, and full implementation below.
Handles container dimension measurement and SVG viewBox sizing
Coordinates scales, Cartesian grid, defs linearGradient, area geometry, and inspection tooltip
Displays series label and semantic color swatch indicator