004 / RECHARTS / LINE
Range Line
Visualizes a central trend alongside a lower-to-upper interval envelope for forecasts, confidence intervals, and operational tolerance bands.
- SPEC
- #004
- ENGINE
- Recharts
- FAMILY
- Line
- RENDERER
- svg
- STATUS
- preview
Installation
Checking public registry…
View local registry JSONCopied as source into your project (requires recharts).
Overview
Range Line visualizes a central trend alongside a continuous lower-to-upper interval envelope. It models three values per horizontal observation — a central observation, a lower boundary, and an upper boundary — over a shared, honest Cartesian scale.
Unlike generic multi-line charts that represent three disconnected lines, Range Line establishes an integrated visual hierarchy:
- Central Signal Line: Rendered as a prominent solid stroke (
2px) in the primary theme color (var(--chart-1)). - Interval Envelope Band: Rendered behind the central line as a filled area band between the lower and upper limits with configurable opacity (
0.18default). - Optional Boundary Strokes: Subtle dashed boundary lines (
3 3) along the upper and lower limits of the envelope to clarify envelope edges. - Single Shared Y Scale: Evaluates the combined extent of all central values, lower limits, and upper limits to guarantee the interval envelope is never clipped.
- Truthful Outlier Policy: If an actual observation falls outside the interval envelope, it is never clamped. Outliers remain visible outside the band.
import { RangeLine } from "@/components/charts/recharts/line-range"export function DemandForecastCard() { return ( <RangeLine data={forecastData} xKey="month" valueKey="forecast" lowerKey="lower" upperKey="upper" label="Expected Demand" rangeLabel="95% Confidence" curve="monotone" showRangeBoundary /> )}Best Suited For
Range Line is specifically engineered for:
- Demand & Capacity Forecasting: Projected demand surrounded by widening confidence intervals over future planning horizons.
- Operational SLA Envelopes: System latency, request duration, or throughput tracked against contracted minimum and maximum tolerance bands.
- Process & Quality Control: Sensor telemetry and manufacturing metrics evaluated against upper and lower control limits (UCL / LCL).
- Financial & Market Volatility: Asset price trends bounded by Bollinger Bands, implied volatility ranges, or price targets.
When to Avoid
- Two Independent Competing Series: Use
TwinlineComparewhen comparing two distinct time periods (e.g. 2024 Actual vs 2023 Prior Year). - Unbounded Multiple Series: Use
LineMultiplewhen plotting three or more independent metrics that do not represent an upper/lower interval. - Single Series Only: Use
LineBasicorPulseLinewhen there is no uncertainty or tolerance range to display.
Installation
Install Range Line directly into your project via the shadcn CLI. The component source and its required dependencies (recharts and shared Plotcn primitives) will be copied directly into your repository under complete source ownership.
Checking public registry…
View local registry JSONCopied as source into your project (requires recharts).
Data Contract
Range Line accepts a readonly array of observations. Each record must contain a shared horizontal domain key and three numeric properties: central trend, lower boundary, and upper boundary.
export interface RangeLineDatum { month: string // Horizontal domain coordinate (e.g. "Jan", "2026-Q1") forecast: number // Central observation value (e.g. expected demand) lower: number // Lower interval limit (e.g. 5th percentile) upper: number // Upper interval limit (e.g. 95th percentile)}Interval Integrity & Outlier Policy
Range Line enforces deterministic data safety across all observations:
- Mandatory Interval Validation (
lower <= upper): For every observation, Range Line verifies thatlower <= upper. If an inverted interval is encountered (e.g.lower = 200, upper = 100), the interval is treated as missing for that point to prevent rendering an inverted polygon. In development mode, a console warning is emitted. - Unclamped Outlier Preservation: Range Line never assumes
lower <= value <= upper. Real-world observations legitimately exceed tolerances or forecast bounds. Central points outside the band remain visible in their true position. - Partial Missing Bounds: If only one boundary is present (e.g.
lower = 100, upper = null), no valid interval exists. Range Line preserves the central line while leaving a clean gap in the envelope. - Missing Central Value: If the central point is
nullbut both lower and upper bounds are valid, the range band remains visible while the central line shows a gap.
Component Props
Core Configuration
| Prop | Type | Default | Description |
|---|---|---|---|
data | readonly TData[] | [] | Readonly array of observation records. The caller's array is never mutated. |
xKey | keyof TData & string | required | Property name representing the horizontal X-axis coordinate. |
valueKey | keyof TData & string | "value" | Property name representing the central observation value. |
lowerKey | keyof TData & string | "lower" | Property name representing the lower limit of the interval band. |
upperKey | keyof TData & string | "upper" | Property name representing the upper limit of the interval band. |
series | RangeLineSeriesConfig | undefined | Optional series descriptor combining keys, labels, and color overrides. |
label | string | "Central" | Human-readable label for the central line displayed in tooltip and legend. |
rangeLabel | string | "Range" | Human-readable label for the interval envelope (e.g. "95% Confidence"). |
height | number | string | 340 | Container height in pixels or standard CSS dimension strings. |
curve | "monotone" | "linear" | "step" | "monotone" | Geometric curve interpolation applied synchronously to both the line and band. |
domain | [number, number] | ["auto", "auto"] | "auto" | Explicit Y-axis bounds. Automatic mode calculates a unified scale spanning central and range limits. |
missingValuePolicy | "gap" | "connect" | "gap" | Handling of null observations in the central line. |
Visual & Appearance
| Prop | Type | Default | Description |
|---|---|---|---|
color | string | "var(--chart-1)" | Stroke color for the central line. |
rangeColor | string | color | Fill color for the interval band. Defaults to the central line color. |
rangeOpacity | number | 0.18 | Fill opacity of the interval band (0 to 1). |
showRangeBoundary | boolean | false | Whether to render subtle dashed boundary strokes along the upper and lower limits. |
rangeBoundaryDash | string | "3 3" | Dash array for the boundary strokes if showRangeBoundary is enabled. |
showGrid | boolean | true | Renders subtle horizontal dashed reference dividers (var(--chart-grid)). |
showLegend | boolean | false | Renders legend distinguishing central line from range band. |
showXAxis | boolean | true | Renders horizontal domain tick labels. |
showYAxis | boolean | true | Renders vertical value tick labels on the shared scale. |
showRangeWidthInTooltip | boolean | false | Calculates and displays the derived interval span (upper - lower) in the tooltip. |
motion | boolean | { duration: number } | true | Coordinated reveal animation (350ms). Automatically disabled under prefers-reduced-motion. |
Accessibility & States
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | "Range Line Chart" | Accessible name announced by screen readers for the <figure> region. |
description | string | undefined | Extended contextual description for assistive technologies. |
loading | boolean | false | Displays neutral loading state without fake data while preserving layout footprint. |
error | Error | string | null | null | Actionable error banner with optional retry trigger. |
unavailable | boolean | string | null | false | Unavailability notice (e.g. missing prediction interval model). |
onRetry | () => void | undefined | Callback invoked when user clicks the retry button in the error state. |
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.
<RangeLine
data={data}
xKey="date"
valueKey="value"
lowerKey="lower"
upperKey="upper"
/>Primary theme stroke color for the central line. Accepts CSS variables or color values.
color="var(--chart-1, #10b981)"Default: "var(--chart-1, #10b981)"Fill opacity applied to the range envelope band (0 to 1).
rangeOpacity={0.18}Default: 0.18Whether to render subtle dashed boundary strokes along the upper and lower limits of the band.
showRangeBoundary={false}Default: falseGeometric curve interpolation applied synchronously to both the central line and the range band.
curve="monotone"Default: "monotone"Container height in pixels or standard CSS dimension strings.
height={340}Default: 340Whether to display the chart legend distinguishing central line from range band.
showLegend={false}Default: falseWhether to render subtle horizontal background reference gridlines.
showGrid={true}Default: true| Property | Type | Default | Required | Description |
|---|---|---|---|---|
dataReq | readonly TData[] | [] | Yes | Readonly array of structured observation records. Caller data is never mutated. Best for: Primary dataset |
xKeyReq | keyof TData & string | — | Yes | Property name for the horizontal X-axis domain (e.g. date, month, or sprint). Best for: Domain coordinates |
valueKeyOpt | keyof TData & string | "value" | No | Field name for the central observation value plotted with dominant solid stroke. Best for: Central signal series |
lowerKeyOpt | keyof TData & string | "lower" | No | Field name for the lower limit of the range band. Best for: Lower interval limit |
upperKeyOpt | keyof TData & string | "upper" | No | Field name for the upper limit of the range band. Best for: Upper interval limit |
seriesOpt | RangeLineSeriesConfig<TData> | undefined | No | Optional range-aware series descriptor combining valueKey, lowerKey, upperKey, and semantic labels. Best for: Encapsulated series config |
labelOpt | string | "Central" | No | Human-readable label for the central series displayed in tooltips and legends. Best for: Series identification |
rangeLabelOpt | string | "Range" | No | Human-readable label for the interval envelope (e.g. 'Confidence Interval', 'Operating Range'). Best for: Interval identification |
colorOpt | string | "var(--chart-1, #10b981)" | No | Primary theme stroke color for the central line. Accepts CSS variables or color values. Best for: Primary brand theme |
rangeOpacityOpt | number | 0.18 | No | Fill opacity applied to the range envelope band (0 to 1). Best for: Interval emphasis |
boolean | false | No | Whether to render subtle dashed boundary strokes along the upper and lower limits of the band. Best for: Boundary clarity | |
curveOpt | "monotone" | "linear" | "step" | "monotone" | No | Geometric curve interpolation applied synchronously to both the central line and the range band. Best for: Interpolation style |
heightOpt | number | string | 340 | No | Container height in pixels or standard CSS dimension strings. Best for: Dashboard slot sizing |
showLegendOpt | boolean | false | No | Whether to display the chart legend distinguishing central line from range band. Best for: Multi-series clarity |
showGridOpt | boolean | true | No | Whether to render subtle horizontal background reference gridlines. Best for: Grid density control |
boolean | false | No | Whether to calculate and display the derived range span (upper - lower) in the tooltip. Best for: Quantitative interval inspection | |
"gap" | "connect" | "gap" | No | Handling of null observations in the central line. 'gap' preserves visual breaks; 'connect' bridges adjacent points. Best for: Data safety & truthful representation | |
domainOpt | [number, number] | ["auto", "auto"] | "auto" | No | Explicit Y-axis numeric domain spanning both central and range values, or 'auto' unified scale calculation. |
showXAxisOpt | boolean | true | No | Whether to display the horizontal X-axis tick labels. |
showYAxisOpt | boolean | true | No | Whether to display the unified vertical Y-axis scale. |
motionOpt | boolean | { duration?: number } | true | No | Synchronized reveal animation (350ms). Automatically disabled under prefers-reduced-motion. |
titleOpt | string | "Range Line Chart" | No | Accessible name announced to screen-readers for the chart figure region. |
descriptionOpt | string | undefined | No | Long-form context describing what the trend and interval envelope communicate. |
loadingOpt | boolean | false | No | Renders a neutral loading skeleton preserving container footprint without fake bands. |
errorOpt | Error | string | null | null | No | Renders an actionable error state banner with optional retry trigger. |
unavailableOpt | boolean | string | null | false | No | Renders a metric unavailability notice (e.g. permission restriction or missing interval model). |
Component Variants & Edge States
Production cookbooks showcasing configuration variants alongside verified handling of loading, empty data, and network error states.
Demand Forecast with Confidence Band
Expected monthly product demand with a widening 95% statistical confidence envelope.
API Latency with Operating Envelope
Observed p95 latency curve plotted inside contractually acceptable SLA bounds with boundary strokes.
Tiered Capacity Allocation Band
Scheduled infrastructure provision tiers with discrete step interpolation on both signal and limits.
Compact Metric Overview Widget
Condensed 200px dashboard tile with hidden axes, maintaining interval visibility in tight slots.
Skeletons indicate runtime fetch or pending data queries.
Handles empty collections ([]) gracefully without crashing.
Graceful failure banner when data source or script fails.
Responsive Behavior
Range Line automatically adapts to its parent container without clipping or layout shifts:
- Desktop (1024px+): Spacious presentation, complete interval tooltip with exact lower and upper values, and optional range span calculation.
- Tablet (640px – 1023px): Adaptive X-axis tick thinning to prevent collision, preserved band continuity, consolidated tooltip padding.
- Mobile (< 640px): Compact padding, preserved start/end axis labels, full-width touch scrub interaction, and stacked tooltip items.
Container-Driven Breakpoints
Range Line scales the central line and interval band synchronously across container widths. The unified Y-domain recalculates to comfortably enclose extreme bounds without clipping.
Full interval tooltip with exact lower and upper values, optional range span, and clear line-versus-band distinction.
Thinned X-axis labels, preserved band continuity, compact margins, tooltip pinned within viewport boundaries.
Edge-to-edge scrub inspection, preserved interval visibility without opacity blowout, touch-first scrub interaction.
Accessibility & Keyboard Navigation
Range Line conforms to WCAG 2.1 AAA accessibility standards:
- Keyboard Operable: Pressing Tab focuses the chart region with a prominent
var(--chart-focus)ring. - Observation Navigation:
- → Navigates to the next time observation.
- ← Navigates to the previous time observation.
- Home Jumps to the first observation.
- End Jumps to the final observation.
- Esc Clears active point selection.
- Screen Reader Announcement: Announces central values and lower–upper interval limits without requiring manual SVG node traversal.
- Factual Figure Summary: An invisible
<figcaption>provides an automated quantitative overview summarizing total observations, central range, and interval availability without marketing spin.
Accessibility & Navigation Standards
Screen-reader figure region with quantitative interval summary (observation count, central range, and interval availability).
Container mounts as region with explicit assistive label.
Central observation is a prominent solid line (2px) while the interval is an area band (fill with optional dashed boundary strokes), providing clear geometric differentiation independent of color.
Embeds visually hidden summary (.sr-only) declaring: “VoiceOver and NVDA announce central values and lower–upper limits without SVG node traversal.”
Automatically suppresses stroke draw and area reveal animations when user requests reduced motion.
| Key | Action |
|---|---|
| Tab | Focus range chart region with prominent focus ring |
| ArrowLeft | Step to previous observation and announce central + range values |
| ArrowRight | Step to next observation and announce central + range values |
| Home | Jump to first observation point |
| End | Jump to latest observation point |
| Escape | Clear active inspection state |
Data Safety Guarantee
- Zero Fabricated Fallback Data: Range Line will never synthesize fake interval bands or fill missing data points with fabricated curves.
- Interval Boundary Check: Enforces
lower <= upperbefore rendering any band polygon to prevent visual distortion. - Shared Scale Integrity: The vertical scale is calculated across all central, lower, and upper values, guaranteeing that interval envelopes are never cut off by the container viewport.
- Unclamped Outliers: Preserves true observations when they exceed normal or expected limits rather than hiding anomalous behavior.
Internal Architecture & File Dependencies
Source-first ownership model. Inspect the exact component call tree, dependencies, and full implementation below.
Scoped CSS variables for axes, grid, and crosshairs without global pollution.