Detent web components
By Shane Logsdon

Charts & metrics

Area Chart

Implemented

Interactive area chart with range selection

detent-area-chart

Port status
Catalog status
implemented
Origin
upstream
Phase
3
Wave
phase-3-data
Group
Charts & metrics

9.2 KB gzip for the class module · inlines the shared spring

Variants

7D week view
no data (empty state)

Local sample data only: pick a range with the tabs, or focus a chart and press ArrowLeft.

Recorded states

  • hover recorded state; no setter
  • closed recorded state; no setter
  • selected recorded state; no setter
  • reduced motion recorded state; no setter
  • active recorded state; no setter

Usage

Import

import '/components/area-chart/define.js';

// or register it yourself
import { DetentAreaChart } from '/components/area-chart/area-chart.js';

Attributes

  • default-range
  • height
  • title

Properties

  • data

Slots

No slots are recorded for this component.

Events

No events are recorded for this component.

Example

Runnable example: site/examples/area-chart.ts. The snippet below is generated from the catalogued attributes.

<detent-area-chart
  default-range="30D"
  height="280"
  title="Revenue"
></detent-area-chart>

Property-only values

const element = document.querySelector('detent-area-chart');
if (element !== null) {
  // data: AreaChartData
  element.data = undefined;
}

Source

The pinned upstream source for this row:

  • src/components/ui/InteractiveAreaChart.tsx sha256 ecaa0b1977b2…

Native files

The native module and its artifacts:

  • src/components/area-chart/area-chart.ts
  • src/components/area-chart/styles.css
  • src/components/area-chart/define.ts
  • docs/components/area-chart.md
  • site/examples/area-chart.ts
  • tests/browser/area-chart.spec.ts
  • evidence/components/area-chart.md

API

Boolean attributes follow HTML presence semantics: present means true, absent means false, and disabled="false" still means disabled.

Attributes

Attributes
AttributePropertyTypeDefaultNotes
default-rangedefaultRangestring"30D"Kebab-case attribute; camelCase property.
heightheightnumber280Kebab-case attribute; camelCase property.
titletitlestring"Revenue"Kebab-case attribute; camelCase property.

Properties

Properties
PropertyTypeDefaultNotes
dataAreaChartDataDEFAULT_AREA_CHART_DATAProperty-only: assign from script; not accepted as an attribute.

Events

No custom events are recorded for this component.

Slots

No slots are recorded for this component.

CSS customisation

  • `className` prop is replaced by documented CSS parts/custom properties; no Tailwind in consumers.
  • React state/hooks replaced by element-owned state with pre-upgrade property preservation.
  • The two extra exports (makeSeries, DEFAULT_AREA_CHART_DATA) ship from the class module instead of a second tag, keeping PC-2.1's one-to-one rule (recorded decision for the row's exports).
  • className is replaced by the documented CSS parts and custom properties; consumers need no Tailwind.
  • React state/hooks and Framer Motion's springs become element-owned state plus the shared createSpring helper (pinned 520/42/0.6 for the crosshair).
  • default-range reflects the active range; a range the data does not contain selects the first key rather than rendering nothing.
  • The line uses --detent-chart-series-1, whose light value is darkened so the mark keeps ≥ 3:1 against the surface (PC-12.6).
  • role="tab" buttons have no aria-controls tabpanel: the chart they control is a single role="img", exactly as upstream, which is recorded rather than invented.
  • Under reduced motion the morph is applied in one step and the crosshair jumps; no animation frame is scheduled for either.

What it does

A hand-written SVG area chart with a range switcher (7D / 30D / 1Y by default), an interruptible dataset morph, Catmull-Rom smoothing, a spring-tracked crosshair and full keyboard scrubbing. Zero charting dependencies and no network code of its own.

Upstream behaviour
  • Hand-crafted SVG path generation with zero charting library dependencies
  • Interruptible dataset morphing transition between date ranges (7D, 30D, 1Y)
  • Catmull-Rom spline interpolation for smooth curve rendering
  • Fluid scrubbing with spring-tracked crosshair, dot, and floating tooltip
  • Full keyboard scrubbing support using Left and Right arrow keys
Differences from upstream
  • `className` prop is replaced by documented CSS parts/custom properties; no Tailwind in consumers.
  • React state/hooks replaced by element-owned state with pre-upgrade property preservation.
  • The two extra exports (makeSeries, DEFAULT_AREA_CHART_DATA) ship from the class module instead of a second tag, keeping PC-2.1's one-to-one rule (recorded decision for the row's exports).
  • className is replaced by the documented CSS parts and custom properties; consumers need no Tailwind.
  • React state/hooks and Framer Motion's springs become element-owned state plus the shared createSpring helper (pinned 520/42/0.6 for the crosshair).
  • default-range reflects the active range; a range the data does not contain selects the first key rather than rendering nothing.
  • The line uses --detent-chart-series-1, whose light value is darkened so the mark keeps ≥ 3:1 against the surface (PC-12.6).
  • role="tab" buttons have no aria-controls tabpanel: the chart they control is a single role="img", exactly as upstream, which is recorded rather than invented.
  • Under reduced motion the morph is applied in one step and the crosshair jumps; no animation frame is scheduled for either.
Previous: Hamburger Menu Next: Timeline

Docs

Components

Project