017 / RECHARTS / AREA
Baseline Area
Single-series area visualization showing values above and below an explicit quantitative reference baseline with truthful deviation semantics.
- SPEC
- #017
- ENGINE
- Recharts
- FAMILY
- Area
- RENDERER
- svg
- STATUS
- preview
Installation
Checking public registry…
View local registry JSONCopied as source into your project (requires recharts).
Overview
Baseline Area is the deviation-specialized chart of the Plotcn Area family. It partitions a single quantitative series across an ordered domain relative to an explicit reference baseline, visually highlighting positive and negative deviations with truthful occupied area fills.
The primary analytical question answered by Baseline Area is:
"How far is this value above or below the configured reference, and where does the signal cross?"
The defining mathematical relationship is:
Unlike generic area charts that silently default to zero or fabricate split datasets, Baseline Area requires an explicit baseline reference, preserves original observation values as canonical data, and derives deviations factually without imposing judgmental "good" or "bad" business labels.
import { BaselineArea } from "@/components/charts/recharts/area-baseline"const utilizationData = [ { day: "Day 01", utilization: 68 }, { day: "Day 03", utilization: 72 }, { day: "Day 05", utilization: 84 }, { day: "Day 07", utilization: 89 }, { day: "Day 09", utilization: 79 }, { day: "Day 11", utilization: 75 }, { day: "Day 13", utilization: 66 }, { day: "Day 15", utilization: 61 }, { day: "Day 17", utilization: 74 }, { day: "Day 19", utilization: 82 }, { day: "Day 21", utilization: 88 }, { day: "Day 23", utilization: 77 }, { day: "Day 25", utilization: 71 }, { day: "Day 27", utilization: 67 }, { day: "Day 29", utilization: 75 }, { day: "Day 30", utilization: 83 },]export function ResourceUtilizationTracker() { return ( <BaselineArea data={utilizationData} xKey="day" series={{ key: "utilization", label: "Resource Utilization", valueFormatter: (v) => `${v}%`, }} baseline={75} baselineLabel="Target SLA" aboveLabel="Above SLA" belowLabel="Below SLA" aboveColor="var(--chart-1)" belowColor="var(--chart-2)" showGrid showDeviation /> )}Area-Family Positioning
The Plotcn Area family provides specialized analytical instruments:
| Consideration | Prism Area (011) | Threshold Line (008) | Comparison Area (015) | Gradient Depth Area (016) | Baseline Area (017) |
|---|---|---|---|---|---|
| Primary Question | "How much magnitude relative to baseline?" | "Where does signal cross boundary limits?" | "How does primary compare to reference series?" | "How does magnitude change with surface depth?" | "How far above or below the explicit baseline is the value?" |
| Fill Geometry | Uniform fill down to baseline | No filled volume (line stroke only) | Dual overlapping series fills | Semantic opacity fade (32% → 2%) | Dual-region continuous fill partitioned at baseline |
| Series Roles | Single series | Single signal + boundary lines | Exactly two: Primary & Reference | Single quantitative series | Single signal + required reference baseline |
| Baseline Requirement | Optional ( or domain min) | Contextual threshold lines | Shared area baseline | Baseline anchor ( or min) | Strictly required constant baseline () |
| Color Semantics | One series color | Signal color + threshold color | Distinct primary vs reference colors | Single color driving stroke & gradient | Signal stroke + aboveColor + belowColor + baselineColor |
Baseline Area vs Threshold Line (008)
- Threshold Line: Best when the signal curve is the primary focus and horizontal thresholds serve as secondary context or warning limits.
- Baseline Area: Best when the occupied space above and below the reference is the primary analytical message. The filled volume makes the cumulative duration and severity of deviations immediately visible.
Baseline Area vs Prism Area (011)
- Prism Area: Treats the baseline as a passive structural floor (conventionally zero). All observations are displayed as a continuous positive volume.
- Baseline Area: Treats the baseline as an active evaluation reference. Observations above the reference fill downward toward it, while observations below the reference fill upward toward it.
Baseline Model
The Baseline Area evaluation model classifies each observation into one of three factual mathematical states:
Factual Classification Around an Explicit Reference Baseline
- Above Reference (): The observation exceeds the reference baseline. The area polygon fills downward to the baseline using
aboveColor. Deviation is strictly positive. - Exact Baseline (): The observation lands precisely on the reference baseline. Area thickness at this coordinate is zero; deviation is $0$.
- Below Reference (): The observation falls below the reference baseline. The area polygon fills upward to the baseline using
belowColor. Deviation is strictly negative.
Visual Invariant: Classification is strictly relative to the explicit baseline, never mathematical zero. An observation of against a baseline of $100$ is below reference (deviation ), while an observation of against a baseline of is above reference (deviation ).
Above & Below Semantics
Plotcn separates spatial position from moral or business judgment:
- Above Does Not Mean "Good": In metrics such as server latency, error rate, memory consumption, or defect count, exceeding a baseline represents degraded performance.
- Below Does Not Mean "Bad": In costs, wait times, or churn rates, falling below a reference baseline represents favorable outcomes.
- Semantic Neutrality:
aboveColordefaults tovar(--chart-1)andbelowColordefaults tovar(--chart-2). Developers can explicitly configure custom colors when their business domain warrants green/red polarity.
Crossing Behavior
In real continuous signals, the trajectory crosses the reference baseline between discrete sample intervals. Plotcn implements continuous vertical Y-axis segmentation:
Color Transitions Precisely at the Interpolated Baseline Intersection
- Continuous Y Segmentation: A single continuous SVG Area geometry is filled with an SVG
<linearGradient>with a sharp stop transition aligned to the exact baseline coordinate. - True Interpolated Crossing: The color boundary between
aboveColorandbelowColoroccurs at the exact mathematical crossing point along the horizontal baseline line. - Zero Artifacts: Crossings do not toggle abruptly by discrete X columns or create jagged polygon seams.
Rendering Architecture
Baseline Area is built purely on top of Recharts and native SVG primitives, guaranteeing zero dependencies on D3, Canvas, or WebGL:
Source-First Recharts SVG Rendering Pipeline
- Consumer Inputs & Validation: Validates that
baselineis an explicit finite number. Non-finite data (NaN,Infinity) is normalized tonull. - Safe Domain & Baseline Offset: Automatic Y-domain expands to enclose both the dataset range and the baseline. The normalized gradient stop offset is calculated as .
- Hard-Stop Linear Gradient: Constructs an SSR-safe
<linearGradient>with a deterministic collision-free ID. - Recharts Area & ReferenceLine: Renders
<Area baseValue={baseline} fill="url(#id)" stroke={color} />alongside a subtle dashed<ReferenceLine y={baseline} stroke={baselineColor} />. - Nearest-X Inspection: Provides synchronized tooltips displaying original observed values, reference baseline, and signed deviation ().
Data Contract
Baseline Area consumes sequential records with an ordered domain key and a single quantitative metric:
| Field | Type | Required | Meaning |
|---|---|---|---|
[xKey] | string | Date | Required | Ordered horizontal domain coordinate (day, month, timestamp). |
[series.key] | number | null | Required | Observed quantitative metric value. |
baseline | number | Required | Explicit constant reference baseline (prop, not data field). |
interface BaselineAreaDatum { day: string utilization: number | null}Series Contract
interface BaselineAreaSeries<TData> { /** Property key on data records for quantitative values */ key: NumericKeyOf<TData> /** Human-readable label for tooltip and screen readers */ label: string /** Optional custom numeric formatter */ valueFormatter?: (value: number) => string}Color Semantics
The component enforces a clean, multi-token color hierarchy:
- Signal Stroke (
color): Preserves the continuous identity of the quantitative signal across the domain. Defaults tovar(--chart-1). - Above Region (
aboveColor): Applied to occupied area above the baseline. Defaults tovar(--chart-1). - Below Region (
belowColor): Applied to occupied area below the baseline. Defaults tovar(--chart-2). - Reference Line (
baselineColor): Applied to the constant horizontal reference line and label. Defaults tovar(--chart-axis). - Active Selection (
selectionColor): Applied to persistent locked crosshair indicator. Defaults tovar(--chart-selection).
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.
<BaselineArea
data={data}
xKey="date"
seriesKey="value"
/>Explicit constant reference baseline. Strictly required and validated as finite (never defaults to zero).
baseline={75}Default: —Interpolation curve applied to the signal boundary stroke and filled area geometry.
curve="monotone"Default: "monotone"Fill opacity applied to both above and below occupied area regions.
fillOpacity={0.24}Default: 0.24Whether to render subtle horizontal Cartesian grid reference lines.
showGrid={true}Default: trueWhether to render above/below/baseline status indicator legend.
showLegend={false}Default: falseWhether to derive and display signed arithmetic deviation in inspection tooltips.
showDeviation={true}Default: trueEnables persistent inspection pinning on click or keyboard Enter/Space.
lockableTooltip={true}Default: truePolicy for missing data: "gap" preserves truthful breaks; "connect" bridges across gaps.
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 reordered. |
xKeyReq | keyof TData & string | — | Yes | Property name on data records representing the horizontal domain coordinate. |
seriesReq | BaselineAreaSeries<TData> | — | Yes | Single quantitative series configuration defining metric key, label, and valueFormatter. |
baselineReq | number | — | Yes | Explicit constant reference baseline. Strictly required and validated as finite (never defaults to zero). |
string | "Reference" | No | Human-readable label for the reference line (e.g. Target, SLA, Budget, Baseline). | |
aboveLabelOpt | string | "Above reference" | No | Label for observations exceeding the baseline (communicates position, not business outcome). |
belowLabelOpt | string | "Below reference" | No | Label for observations falling below the baseline (communicates position, not business outcome). |
heightOpt | number | string | 320 | No | Container height in pixels or standard CSS dimension string. |
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" to safely enclose both data and baseline. |
colorOpt | string | var(--chart-1) | No | Primary signal stroke and active observation marker color. |
aboveColorOpt | string | var(--chart-1) | No | Area fill color for observations exceeding the reference baseline. |
belowColorOpt | string | var(--chart-2) | No | Area fill color for observations falling below the reference baseline. |
string | var(--chart-axis) | No | Stroke color for the constant horizontal reference baseline line. | |
string | var(--chart-selection) | No | Color for locked inspection crosshair reference line. | |
fillOpacityOpt | number | 0.24 | No | Fill opacity applied to both above and below occupied area regions. |
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 above/below/baseline status indicator legend. |
boolean | true | No | Whether to derive and display signed arithmetic deviation in inspection tooltips. | |
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 gaps. | |
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.
Utilization vs 75% Target Baseline
Standard single-series resource utilization tracking positive and negative deviations from an explicit 75% reference target.
Frequent Reference Crossings
Validates continuous vertical Y segmentation when data oscillates frequently above and below the reference baseline.
Zero Baseline (Positive/Negative)
Explicit baseline={0} anchor demonstrating truthful handling of mathematical zero without collapsing negative values.
Linear Interpolation with Exact Crossings
Piecewise linear segments demonstrating deterministic vertex alignment and exact baseline intersection geometry.
Status Legend Enabled
Displays structural sample swatches for Above Reference, Below Reference, and the Reference Baseline.
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
Baseline Area preserves the constant horizontal reference baseline, continuous above/below segmentation, and nearest-X inspection across all viewport dimensions down to 320px.
Spacious Cartesian grid, full domain tick density, inline baseline label annotations, and detailed inspection card.
Adaptive domain tick thinning, preserved reference line geometry, and compact inspection gutters.
Compact gutters, touch-forgiving nearest-X scrubbing, truthful missing breaks, and uncompromised continuous Y color segmentation.
Accessibility & Data Safety
- One Tab Stop: Root figure is keyboard-focusable with comprehensive shortcuts:
ArrowLeft/ArrowRight: Navigate chronological observations.Home/End: Jump to first / last observation.Enter/Space: Pin or unpin persistent tooltip inspection.Escape: Dismiss locked inspection.
- Off-Screen Structured Table: Accessible
<table className="sr-only">presents raw values, baseline reference, deviation arithmetic, and relative position classification to screen readers. - Factual Narration: Screen reader captions state deviations factually without editorializing (e.g. "7 units above reference", not "Performance good").
- Reduced Motion: Entrance reveal animations immediately bypass when
prefers-reduced-motionis active.
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.
Reference line geometry, active dot marker, signed +/- deviation readout, and structured offscreen HTML table ensure complete non-color accessibility.
Embeds visually hidden summary (.sr-only) declaring: “Announces domain coordinate, observed value, reference baseline, and signed deviation. Classifications are narrated factually without business value judgments.”
All entrance 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
- ✓ Baseline is explicit and never silently assumed to be zero
- ✓ Baseline is constant and finite in V1
- ✓ Automatic domain always encloses the reference baseline
- ✓ Explicit domain is respected without clamping the baseline
- ✓ Values are classified relative to baseline, not zero
- ✓ Positive raw values can be below baseline; negative raw values can be above baseline
- ✓ Exact-baseline values remain exact with zero deviation
- ✓ Missing values never collapse into baseline values
- ✓ Zero remains a valid observation
- ✓ Non-finite values (
NaN,Infinity) never reach SVG geometry - ✓ Caller data is 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 SVG viewBox sizing
Coordinates scales, Cartesian grid, defs linearGradient, Area geometry, and ReferenceLine
Displays above, below, and baseline reference swatches