Skip to main content
196

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Web docs
Data displayGlass surface

LineChart

Shows ordered trends, multiple series, missing-value gaps, areas, markers, and reference values.

FrameworksAstro · React · Elements

Registry commandlumen add LineChart

InteractionEnhanced runtime

← All chart guides · Framework setup · Native counterparts

01

See it and copy it

Framework example

Explore the live chart, then open its code for Astro, React, or Elements.

AstroCode target · live preview uses Astro

Website traffic

2 series, 10 points. Values range from 82 to 238.

  • Page views
  • Visits
View chart data
CategoryPage viewsVisits
Mon12082
Tue168104
Wed15497
Thu201128
Fri238146
Traffic increased through the end of the week.
View LineChart code

Framework usage

Switch targets to compare the adapter code. This live preview runs the Astro example. React and Elements use their own behavior APIs; complete the matching framework setup before copying an example.
astro
---
import { LineChart } from '@santi020k/lumen-astro'

const series = [
  {
    data: [
      { x: 'Mon', y: 120 },
      { x: 'Tue', y: 168 },
      { x: 'Wed', y: 154 },
      { x: 'Thu', y: 201 },
      { x: 'Fri', y: 238 }
    ],
    id: 'views',
    label: 'Page views'
  },
  {
    data: [
      { x: 'Mon', y: 82 },
      { x: 'Tue', y: 104 },
      { x: 'Wed', y: 97 },
      { x: 'Thu', y: 128 },
      { x: 'Fri', y: 146 }
    ],
    id: 'visits',
    label: 'Visits'
  }
]
---

<LineChart
  aria-label="Page views and visits from Monday through Friday"
  area
  caption="Traffic increased through the end of the week."
  heading="Website traffic"
  {series}
/>
Edit LineChart in browser

Framework differences

Elements: Pass series as a JSON attribute or through the public element property. The Elements example serializes the sample data with JSON.stringify; Astro expression bindings are not HTML attributes.

When to use LineChart

Use a line when the order and movement between observations matter: traffic, temperature, balances, or recurring measurements.

  • A break in the line marks a missing observation. Area fill follows the same gaps.
  • Use annotations or referenceValue to explain an event or threshold. Include the reporting period and units in the heading, description, or caption.
  • Enable interactive inspection for pointer, touch, and keyboard exploration. Matching syncGroup values synchronize charts at the same X identity; Astro also needs UIPrimitives.

Prepare the data

ts
import type { LumenChartSeries } from '@santi020k/lumen-core'

const series = [{
  id: 'visits',
  label: 'Visits',
  data: [
    { x: '2026-08-01T00:00:00Z', y: 120 },
    { x: '2026-08-02T00:00:00Z', y: null },
    { x: '2026-08-04T00:00:00Z', y: 180 }
  ]
}] satisfies readonly LumenChartSeries[]
  • Give each series a unique id and a readable label. Keep y numeric; use null for an observation that is unavailable.
  • The default xScale is categorical and spaces categories evenly. Use xScale="time" for elapsed-time spacing or "linear" for numeric spacing.
  • For time data, use timestamps or ISO dates with an explicit time zone, sort ascending, and use formatCategory to display the intended locale and time zone.

Shared data and formatting guidance →

Avoid misleading comparisons

  • Do not format dates into ambiguous category strings before plotting a time scale.
  • A shortened Y domain emphasizes small changes. Keep domains consistent when readers compare separate plots, and disclose the units.

Chart accessibility and keyboard guidance →

02

Choose your target

Add this component

Choose the package for your runtime. All adapters share the Lumen stylesheet. Use the matching registry command when you want a local wrapper for that framework.

bash@santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
bashAstro wrapper
lumen add LineChart
lumen add LineChart

Glass

Add the glass prop to apply the shared blur, saturation, border, and highlight tokens. Glass reads best over vivid content, so place the surface above imagery or color.

AstroCode target · live preview uses Astro

Coverage

1 series, 4 points. Values range from 94 to 98.

View chart data
CategoryCoverage
Mon94
Tue96
Wed95
Thu98
View LineChart code

Framework usage

Switch targets to compare the adapter code. This live preview runs the Astro example. React and Elements use their own behavior APIs; complete the matching framework setup before copying an example.
astro
---
import { LineChart } from '@santi020k/lumen-astro'

const series = [
  {
    data: [
      { x: 'Mon', y: 94 },
      { x: 'Tue', y: 96 },
      { x: 'Wed', y: 95 },
      { x: 'Thu', y: 98 }
    ],
    id: 'coverage',
    label: 'Coverage'
  }
]
---

<div class="docs-glass-demo">
  <LineChart
    aria-label="Test coverage"
    area
    glass
    heading="Coverage"
    referenceValue={95}
    {series}
  />
</div>
Edit LineChart in browser

API reference

Lumen-specific props and runtime attributes for the Astro primitive. Use the framework differences above and the copyable examples for React composition and Elements attributes; the public adapter types define their supported contracts.

AttributeValuesDefaultDescription
glassboolean | "subtle" | "strong"falseApplies the tokenized liquid-glass surface treatment with backdrop-filter fallbacks; "subtle" and "strong" adjust the fill intensity.
xScale"categorical" | "linear" | "time""categorical"Uses numeric or elapsed-time spacing, sorted against one shared X domain. Format dates explicitly for the application locale and time zone.
domain, xDomainPartial<LumenChartDomain>automaticSets finite axis bounds shared by all series.
interactive, syncGroupboolean, stringfalse, unsetEnables keyboard/pointer/touch inspection, toggled legends, and exact-X cursor synchronization. Astro requires UIPrimitives.
annotationsLumenChartAnnotation[][]Places labeled X events or Y reference lines in data coordinates.
cursor, onCursorChangeReact cursor identity and callbackuncontrolledReact can supply the active X identity and receive cursor changes. Astro and Elements emit ui:chart-cursor-change.
width, heightnumber640, 320Sets the SVG coordinate dimensions; narrow plots retain internal scrolling.
drilldownboolean (Astro / Elements attribute)falseEnables plotted datum actions and an equivalent native button disclosure, including with hidden tables. Astro requires UIPrimitives; Elements owns its lifecycle.
onDatumActivate(detail: LumenChartDatumActivationDetail) => void (React)-Enables React datum actions and receives validated values with raw identities. Navigation and filtering remain application owned.
explore-data-label, datum-action-prefix, datumActionFormatterstring attributes, (context: string) => string property (Elements)English labelsLocalizes the Elements disclosure and datum actions.
labels.exploreData, labels.formatDatumActionstring, (context: string) => stringEnglish labelsLocalizes the actions disclosure and each contextual datum button.
seriesLumenChartSeries[]requiredProvides ordered, already-aggregated points; null y values create visible gaps.
areabooleanfalseAdds a tokenized fill between each line segment and the zero or domain baseline.
markers"auto" | "all" | "none" | boolean | number"auto"Controls marker density; a number displays every nth point while retaining all line and table data.
formatCategory, formatValueformatter functionsStringFormats axes, SVG titles, and the accessible data table without changing data identity.
emptyLabelstring"No chart data available."Provides actionable, source-specific empty-state guidance.
referenceValuenumber-Draws a dashed threshold or comparison line across the plot.
showLegendbooleantrue for multiple seriesShows the color-independent series key.
showTablebooleantrueProvides a revealable semantic table containing every plotted value.
class, classNamestring""Merges custom classes with the generated ui-* root classes.
...native attributesHTML attributes-Forwards standard attributes to the root element unless the component consumes them.

Keyboard interactions

Keyboard behavior provided by the Astro UIPrimitives runtime for this component.

KeyAction
TabFocus the actions disclosure and its native buttons in document order.
Enter, SpaceToggle the disclosure or activate the focused datum button. Actions remain available when the data table is hidden.

Runtime events

CustomEvents dispatched by the Astro UIPrimitives runtime for this component.

EventTargetDetailWhen
ui:chart-cursor-changeLineChart{ x: number | string | null }An interactive chart cursor changes through keyboard, pointer, or touch.
ui:chart-datum-activateAstro chart figure or Elements data chart hostLumenChartDatumActivationDetail: series { seriesId, x, y, datumId? }, heatmap { x, y, value, datumId? }, range { x, low, high, datumId? }Fires once after a plotted datum or its native action button is activated. Requires drilldown. Astro uses UIPrimitives, Elements owns its lifecycle, and React uses onDatumActivate instead.

Web docsFull catalog