dssoca docs
GitHub repository

Sparkline

Tiny inline trend chart.

A compact sparkline for trends, rendered as bars, a line, or a filled area. Fix the scale with `min`/`max` to compare rows, colour by `trend` (auto derives up/down/flat → success/danger/muted), and flex it to the cell with `fluid`/`width`. Decorative by default; the auto-generated summary (or `label`) names it for assistive tech.

Demo

live · storybook Open in Storybook

Demo loads from https://dssoca-storybook.vercel.app/. Run pnpm storybook for it to render locally.

Usage

svelte
<script>
  import { Sparkline } from 'dssoca';
</script>

<Sparkline data={[3, 7, 4, 9, 6, 11]} label="req/min, last 6h" />
<Sparkline data={[12, 9, 11, 6, 4]} trend="auto" variant="area" fluid />

Props

PropTypeDefaultDescription
datanumber[]Required. Series values.
variant'bars' | 'line' | 'area''bars'Rendering style.
colorstringvar(--ss-primary)Bar/line fill. Ignored when `trend` resolves to a direction.
trend'auto' | 'up' | 'down' | 'flat' | 'none''none'Colour by direction; `auto` derives first-vs-last → success/danger/muted.
minnumberLower scale bound. Defaults to the data min — set to fix the scale across rows.
maxnumberUpper scale bound. Defaults to the data max — set to fix the scale across rows.
fluidbooleanfalseFlex the chart to fill its container width (table-cell friendly).
widthstringExplicit CSS width (e.g. '120px', '100%'); overrides the intrinsic width.
labelstringAccessible name; overrides the auto-generated summary (sets role="img").
summarystringReplace the auto-generated screen-reader summary entirely.
valueFormat(v: number) => stringFormat a value for the screen-reader summary (e.g. v => v + "%").
size'sm' | 'md' | 'lg'Per-instance size override; inherits the ancestor `data-size-variant` when unset.