PathLogs UI
Русский

Components

Sparkline

An inline SVG trend without a chart library — in a row or a badge.

An inline sparkline: a trend on one line — in a table, in a badge, in the status bar. A single <path> in SVG plus, optionally, dots. No chart library.

Example

Коммиты за 2 недели
+18%
Задержка ответа, мс
выброс
Остаток работ
−92%

Inside a table row

A sparkline's real home is not a chart of its own but a cell next to a number: a «how it moved» column without unfolding into a full diagram.

auth89
billing80
search45
notifications52

Props

values*number[]

The series, left to right.

width / heightnumber

defaults to: 120 / 32

Dimensions in pixels.

colorstring

defaults to: var(--accent)

The line colour.

fillboolean

defaults to: false

Fill the area under the line with a gradient of the line colour.

smoothboolean

defaults to: false

Smooth with curves instead of a polyline.

dotsboolean

defaults to: false

Mark the first and last points.

extremesboolean

defaults to: false

Mark the minimum and maximum of the series.

zeroBasedboolean

defaults to: false

Include zero in the scale — then heights are comparable between charts.

maxPointsnumber

Thin a long series down to this many points, preserving the outliers.

labelstring

The accessible caption. «Trend +N%» by default.

The geometry, separately

The line maths is pure and reusable without React:

tsx
import {
  sparklineGeometry, // points, the line path and the fill path
  extentOf,          // scale bounds (a flat series never divides by zero)
  decimate,          // thinning that preserves extremes
  trend,             // change from first to last, as a fraction
} from "@toimetdev/pathlogs-core";