Line Chart | kamod chartsSkip to content

Charts

Line Chart

Show change over time with an accessible, SVG-first line chart.

Charts / Line Chart

Preact nativeResponsiveStackableTyped props

Overview

Revenue vs costsFirst-half revenue and operating costs for 2024.JanFebMarAprMayJun15k20k25k30k35k40k45k

Line charts share Kamod’s cartesian model with area and scatter charts. Style lines per series, stack cumulative totals, and annotate thresholds with reference lines, areas, and points — all through typed props.

import { LineChart } from "@kamod-ch/charts/line";
Static bundle
Import from @kamod-ch/charts/line for charts without the motion runtime.
Series styling
Per-series props on LineSeriesConfig override chart-level defaults for stroke width, dash patterns, and markers.

API notes

Typed LineChart props — no dashed boolean and no option:any.

LineSeriesConfig
Each entry in series extends the cartesian config with strokeWidth, strokeDasharray, showPoints, and pointRadius. Series values win over chart-level defaults.
Dash patterns
Use strokeDasharray (e.g. "6 4") on the chart or on a series — not a dashed boolean. Combine solid actuals with a dashed forecast line via per-series patterns.
Curve values
Exported curve names: linear, monotoneX, basis, step, stepBefore, stepAfter. Default is linear.
Stacked lines
Set stacked to draw each series on cumulative y1. Axis tooltips still report each series’ raw value; markers and crosshair anchor on the stacked position.
Reference areas
referenceAreas accept vertical x1/x2 or horizontal y1/y2 pairs. Band scales include full category bandwidth.
Reference points
referencePoints mark explicit x/y events with circle, square, or diamond shapes. Kamod does not infer peaks — pass coordinates from your domain model.
Reference lines
referenceLines accept optional strokeWidth and strokeDasharray. When omitted, the legacy "4 4" dash pattern is preserved.
Theme tokens
Reference fills and markers use var(--chart-reference-area) and var(--chart-reference-point) so annotations stay readable in light and dark themes.

Thirteen functional patterns covering curves, forecasts, stacking, and cartesian annotations. Each preview uses Kamod’s real LineChart API — no copied option objects.

Basic line

A single responsive series with grid, tooltip, and accessible title. This is the starting point for most dashboards.

ResponsiveTooltip
Monthly revenueFirst-half revenue trend with keyboard-accessible tooltips.JanFebMarAprMayJun30k35k40k45k

Multiple series with legend

Compare related metrics and let readers toggle series from the HTML legend without losing keyboard focus on the chart surface.

showLegendmonotoneX
Revenue vs costsTwo series with legend toggles and a smooth monotone curve.JanFebMarAprMayJun15k20k25k30k35k40k45k

Smooth line without points

Use curve="monotoneX" for a smooth trend and showPoints={false} when markers would clutter dense data.

monotoneXshowPoints={false}
Smooth revenue curveMonotone interpolation with markers disabled.JanFebMarAprMayJun30k35k40k45k

Actual solid, forecast dashed

Style each series through LineSeriesConfig. Per-series strokeDasharray overrides the chart default so actuals stay solid while projections read as provisional.

LineSeriesConfigstrokeDasharray
Actual vs forecast pipelineSolid actuals hand off to a dashed forecast line.JanFebMarAprMayJunJulAugSep40k45k50k

Step line

Use curve="step" for centered step transitions between discrete periods.

step
Stepped customer countCustomer totals with centered step interpolation.JanFebMarAprMayJun1.2k1.3k1.4k1.5k1.6k1.7k

Peak marker and horizontal target

Combine referencePoints for explicit events with referenceLines for thresholds. Kamod does not auto-detect peaks — pass coordinates from your analytics layer.

referencePointsreferenceLines
Revenue peak with targetMay peak marker and a dashed revenue target line.JanFebMarAprMayJun30k35k40k45k

Linear segments

linear is the Kamod default — straight segments between points without smoothing or steps.

linear
Linear segment comparisonTwo series rendered with the default linear curve.JanFebMarAprMayJun15k20k25k30k35k40k45k

Step before

curve="stepBefore" holds the previous value until the next category boundary — useful for inventory or quota resets.

stepBefore
Step-before customer growthCustomer totals with stepBefore interpolation.JanFebMarAprMayJun1.2k1.3k1.4k1.5k1.6k1.7k

Stacked lines

Set stacked to draw each series on cumulative y1. Tooltips still report raw channel values while markers follow the stacked geometry.

stackedRaw tooltip values
Stacked channel volumeThree stacked line series; tooltips show each channel's original value.JanFebMarAprMayJun01020304050

Dashed forecast series

Apply strokeDasharray on a single forecast series or at chart level. Prefer explicit dash strings over boolean flags.

strokeDasharrayForecast
Forecast-only outlookProjected months rendered as a dashed monotone line.JulAugSep50k51k52k53k54k

Actual vs forecast with peak window

Highlight a peak interval with referenceAreas while keeping actual and forecast lines on the same chart.

referenceAreasActual + forecast
Pipeline peak windowShaded peak period with solid actuals and dashed forecast.JanFebMarAprMayJunJulAugSep40k45k50k

Calendar event window

Use xScale="time" with Date x values and a vertical reference area to mark launch or maintenance windows on a daily axis.

time scalereferenceAreasResponsive
Adoption around launchDaily adoption with a time-scaled launch highlight band.Jun 03Jun 05Jun 07Jun 09200300400500600700

Capacity changes as diamonds

Mark infrastructure step changes with referencePoints using shape="diamond". Pass explicit x/y coordinates when capacity shifts.

referencePointsdiamond
Throughput vs capacity stepsDiamond markers annotate discrete capacity increases.Mar 09Mar 16Mar 23Mar 30Apr 06Apr 13Apr 20800850900950

Props

LineChart props
PropTypeDefaultDescription
datareadonly TDatum[]—Array of row objects rendered by the chart.
xKeyDataAccessor<TDatum, string | number | Date | null | undefined>—Field or accessor for the x axis.
xScale"linear" | "time" | "band" | "point"—Scale kind for the x axis.
heightnumber—Chart height in pixels.
widthnumber—Fixed width. Prefer responsive + initialWidth for fluid layouts.
initialWidthnumber—SSR / first-paint width before ResizeObserver measures the container.
responsivebooleanfalseStretch to the parent container width.
titlestring—Accessible chart title rendered into SVG title.
descriptionstring—Accessible description rendered into SVG desc.
showGridboolean—Show cartesian grid lines.
showLegendboolean—Show an HTML legend with series toggles. Supported on Line, Scatter, Area, and Bar charts.
tooltipboolean | CartesianTooltipOptions<TDatum>—Enable pointer and keyboard tooltips. `true` uses chart defaults: axis mode for Line and Area, nearest mode for Scatter and Bar. Options may set mode, placement, offset, render, formatValue, and formatLabel. PieChart does not support this prop.
seriesreadonly LineSeriesConfig<TDatum>[]—One or more line series. LineSeriesConfig extends the cartesian config with strokeWidth, strokeDasharray, showPoints, and pointRadius.
animateboolean | ChartAnimateOptions—Optional data animation. No-op on static entries unless a MotionConfig from @kamod-ch/charts/motion is present. Defaults to on for charts imported from that subpath. Options: enabled, duration (seconds), easing, preset, reducedMotion.
stackedbooleanfalseStack series on cumulative y1 geometry. Tooltips still report raw series values.
curve"linear" | "monotoneX" | "basis" | "step" | "stepBefore" | "stepAfter" | CurveFactory"linear"Path interpolation for every visible series.
connectNullsbooleanfalseDraw across null / undefined values.
strokeWidthnumber—Default line stroke width. Overridden by per-series strokeWidth.
strokeDasharraystring—Default SVG dash pattern, e.g. "6 4". Overridden by per-series strokeDasharray. Use explicit patterns instead of a dashed boolean.
showPointsboolean | "auto""auto"Render markers on each defined datum (auto hides markers above 500 points).
pointRadiusnumber2.5Default marker radius when showPoints is enabled.
referenceLinesreadonly CartesianReferenceLine<TDatum>[]—Optional x/y reference markers with label, color, strokeWidth, and strokeDasharray.
referenceAreasreadonly CartesianReferenceArea<TDatum>[]—Vertical x1/x2 or horizontal y1/y2 highlight bands clipped to the plot area.
referencePointsreadonly CartesianReferencePoint<TDatum>[]—Explicit x/y event markers with shape, label, and labelPosition. Kamod does not infer peaks.