Skip to content

LineChart

Plot one x/y series from row mappings with an accessible fallback.

Import from hedron import LineChart
Distribution hedron[charts]
Backend activity No
Normal render mode RenderMode.FRAGMENT

Live demo

Monthly revenueRevenue rose from January through June.

The preview is a local docs simulation (not a running Hedron server). Interactive demos show a “Simulated HTMX” trace when applicable.

Install the optional provider before importing this component:

pip install "hedron[charts]>=0.1.0,<0.2"

Basic use

from hedron import LineChart

component = LineChart(rows, x='month', y='revenue', title='Monthly revenue', description='Revenue rose from January through June.')

Compose under Page for full documents, or return from a fragment route for HTMX swaps.

How it works

LineChart prefers the Matplotlib adapter when installed and otherwise produces a reviewed accessible SVG plus a redacted table fallback. Numeric and categorical x values are supported.

This component's core behavior is server-rendered HTML and does not require a browser runtime. The preview is ordinary semantic HTML, so keyboard, form, link, and disclosure behavior comes from the platform.

Constructor and parameters

LineChart(data, *, x, y, title, description=None, alt=None, waiver=None, limits=None)
Parameter Type Meaning
data Sequence[Mapping] Bounded rows.
x / y str Source field names.
title str Required chart title.
description / alt str | None Text equivalents.
waiver str | None Reviewed accessibility exception.
limits VisualizationLimits | None Complexity bounds.

Composition and backend behavior

Keep LineChart at the smallest semantic boundary. Fragment routes should return only the replaced region and preserve stable target IDs across success, validation, empty, loading, and error responses.

This component is primarily presentational; keep any mutation on an explicit action or component route.

Accessibility

Supply a conclusion-oriented description and keep the tabular fallback available to users who cannot perceive the plot.

Security

Escaping and SafeUrl / TrustedHtml are framework concerns; authorization and data exposure remain application code. Redact secrets before rendering.

Common mistakes

  • Bound data and never insert raw labels into active SVG or bypass the accessibility contract.
  • Do not copy docs-preview JavaScript into an application server.

Testing

from hedron import RenderMode, render

result = render(component, mode=RenderMode.FRAGMENT)
assert result.html
assert not result.diagnostics

All component demos · Built-in API · Testing