Skip to content
Charts

Live Line Chart

Streaming line. Default and Motion variants.

Examples

Installation

Default is a ready-made wrapper from the registry. Motion is the composable engine at @cronus-ui/ui/charts (peer visx + motion).

bash
npx cronus-ui add live-line-chart
tsx
import { LiveLineChart } from "@cronus-ui/ui";

Usage

Motion timestamps are unix seconds (`Date.now() / 1000`). The visible window is `window` seconds ending at now. `paused` freezes the scroll.

tsx
import { LiveLineChart, LiveLine, LiveXAxis, LiveYAxis, Grid, ChartTooltip } from "@cronus-ui/ui/charts";
<LiveLineChart data={points} value={points.at(-1)?.value ?? 0} window={30}>
<Grid horizontal />
<LiveLine dataKey="value" formatValue={formatUsd} />
<LiveXAxis />
<LiveYAxis formatValue={formatUsd} position="right" />
<ChartTooltip />
</LiveLineChart>

Components

Motion API — compose these under the chart root. Default wrapper props are in Default API below.

LiveLineChart

Streaming time window. Interpolates `value` toward the latest sample.

Skip LiveLineChartProps props table
PropTypeDefaultDescription
data*
LiveLinePoint[]{ time: unixSeconds, value } samples.
value*
numberLatest value (lerped).
dataKey
string"value"Value field in context data.
window
number30Visible window in seconds.
nowOffsetUnits
number0Leading offset in X-tick units. 0 = now at the right edge.
lerpSpeed
number0.08Interpolation 0–1.
paused
booleanfalseFreeze scrolling.
margin
`Partial<{ top, right, bottom, left }>`{ top: 16, right: 80, bottom: 40, left: 56 }Plot margins.

LiveLine

The streaming path, gradient fill, live dot, and value badge.

Skip LiveLineProps props table
PropTypeDefaultDescription
dataKey*
stringY-value key.
stroke
stringvar(--chart-line-primary)Line color.
fill
booleantrueGradient under the curve.
pulse
booleantruePulsing live dot.
badge
booleantrueValue pill at the live tip.
formatValue
(v: number) => stringBadge formatter.
momentumColors
{ up, down, flat }Override stroke from recent slope.

LiveXAxis

HH:MM:SS labels (local time, en-US) that fade under the crosshair.

Skip LiveXAxisProps props table
PropTypeDefaultDescription
numTicks
number5Time labels.

LiveYAxis

Value ticks with a nice-step picker.

Skip LiveYAxisProps props table
PropTypeDefaultDescription
position
"left" | "right""left"Side.
formatValue
(v: number) => stringTick formatter.
minGap
number36Minimum pixel gap between labels.

Grid

Plot-area grid lines. Horizontal by default; optional shimmer while loading.

Skip GridProps props table
PropTypeDefaultDescription
horizontal
booleantrueShow horizontal lines.
vertical
booleanfalseShow vertical lines.
numTicksRows
number5Horizontal line count.
numTicksColumns
number10Vertical line count.
stroke
stringvar(--chart-grid)Line color while ready.
strokeDasharray
string"4,4"Dash pattern.
shimmer
booleanfalseAnimate a band across horizontal lines.
highlightRowValues
number[]Rows drawn with alternate styling (e.g. zero).

ChartTooltip

Motion tooltip: crosshair, series dots, floating panel, optional date pill. This is not the recharts ChartTooltip from `@cronus-ui/ui`.

Skip ChartTooltipProps props table
PropTypeDefaultDescription
showDatePill
booleantrueAnimated date ticker on the x-axis.
showCrosshair
booleantrueVertical crosshair.
showDots
booleantrueDots on series at the hovered x.
dotVariant
"dot" | "ring""dot"Filled circle or ring.
indicatorColor
string | (point) => stringCrosshair and dot color.
indicatorDasharray
stringDash pattern for the crosshair.
indicatorFadeEdges
"both" | "top" | "bottom" | "none""both"Vertical crosshair fade.
matchCrosshair
booleanfalsePanel uses the crosshair spring when true.
damping
number20Panel follow when matchCrosshair is false. 0 = instant.
content
(props) => ReactNodeCustom tooltip renderer.
rows
(point) => TooltipRow[]Custom row generator.

Time window

`window` is seconds of history. `nowOffsetUnits` pulls “now” left so the live tip is not clipped by the right margin.

tsx
<LiveLineChart data={points} value={last} window={30} nowOffsetUnits={0.4}>
<LiveLine dataKey="value" />
<LiveXAxis />
</LiveLineChart>

Momentum colors

Pass momentumColors so the stroke, fill, and live dot follow recent slope.

tsx
<LiveLine
dataKey="value"
momentumColors={{
up: "var(--cronus-success)",
down: "var(--cronus-danger)",
flat: "var(--chart-line-primary)",
}}
/>

Data format

`time` is unix seconds, not milliseconds and not Date objects.

ts
type LiveLinePoint = { time: number; value: number };
const points: LiveLinePoint[] = [
{ time: Date.now() / 1000 - 8, value: 184.2 },
{ time: Date.now() / 1000 - 4, value: 184.9 },
{ time: Date.now() / 1000, value: 185.1 },
];

Theming

Motion charts read `--chart-*` aliases that map onto Cronus semantic tokens (`--cronus-chart-1`…`--cronus-chart-5`, `--cronus-border`, `--cronus-fg`, surfaces). Override the aliases or the tokens — never palette scales (`bg-zinc-900`). Default wrappers use `ChartConfig` with `var(--cronus-chart-*)` / `var(--cronus-primary)`. The live badge uses `--chart-tooltip-background` / `--chart-tooltip-foreground`.

Full token reference: Theming.

Dependencies

Default needs the recharts peer. Motion needs visx (and sometimes d3) as optional peers — install only what this chart uses.

bash
bun add recharts
bash
bun add @visx/curve @visx/responsive @visx/scale @visx/shape motion react-use-measure d3-array

Default API

Generated from the Default wrapper's exported types. Motion subcomponents are documented above.

LiveLineChartProps

Extends HTMLAttributes<HTMLDivElement>

Skip LiveLineChartProps props table
PropTypeDefaultDescription
data*
LiveLinePoint[]
interval
number1000
maxPoints
number24