Skip to content

OrigamChartSparkline ​

A tiny inline chart for table cells, KPI cards, and dashboards. Renders a single numeric series as a compact visualization with no axes, no legend, and no grid.

Quick start ​

vue
<OrigamChartSparkline
  :series="[{ name: 'Sales', data: [18, 22, 19, 25, 32, 28, 33, 30, 36, 39, 42, 45] }]"
  type="line"
  color="primary"
  :width="120"
  :height="30"
/>

Props ​

Visual ​

PropTypeDefaultDescription
typeTChartSparklineKind'line'Rendering mode: 'line', 'area', 'column', 'bar'
colorTIntent | string'primary'Stroke / fill colour — intent token or raw CSS
lineWidthnumber1.5Stroke width (SVG pixels) — line and area only
widthnumber | string120Container width in px or CSS string
heightnumber | string30Container height in px or CSS string

Markers ​

PropTypeDefaultDescription
showMarkersbooleanfalseShow a filled circle at every data point
showMinbooleanfalseHighlight the minimum value in red
showMaxbooleanfalseHighlight the maximum value in green
showLastbooleantrueHighlight the last data point in the series colour
markerSizenumber2.5Radius of highlighted marker circles (SVG pixels)

Behaviour ​

PropTypeDefaultDescription
seriesArray<IChartSeries>requiredSingle data series. Data must be Array<number>
showTooltipbooleanfalseEnable a minimal value tooltip on hover
animatedbooleanfalse⛔ Sans effet sur ce composant — no animation is ever emitted — neither a CSS class nor an inline animation declaration. La prop reste declaree (elle est heritee d'IChartBaseProps) et emet un avertissement de developpement si elle est passee. Voir #426.
animationDurationnumber600⛔ Sans effet sur ce composant — nothing is animated, so there is no duration to apply. La prop reste declaree (elle est heritee d'IChartBaseProps) et emet un avertissement de developpement si elle est passee. Voir #426.

Layout (inherited from IChartBaseProps) ​

PropTypeDefaultDescription
marginTMargin—Outer spacing
paddingTPadding—Inner spacing
roundedTRounded—Border radius token
elevationTElevation—Shadow token
bgColorTIntent | string—Background colour
minWidth / maxWidth / minHeight / maxHeightnumber | string—Dimension bounds. The root consumes the full IDimensionProps surface through useDimension(props).dimensionStyles, so all seven dimension props take effect — not just width / height.
titlestring—Accessible title. Rendered as no visible header at all: it feeds the root aria-label, the SVG aria-label, and the SVG <title>. When absent, falls back to the translated name of the active type (origam.chart.sparkline.aria_label_{type} — e.g. "Line sparkline"), so the accessible name follows the active locale.
aspectRatiostring—⛔ Sans effet sur ce composant — the root sizes itself from width / height; no aspect-ratio declaration is emitted. La prop reste declaree (elle est heritee d'IChartBaseProps) et emet un avertissement de developpement si elle est passee. Voir #426.
subtitlestring—⛔ Sans effet sur ce composant — a sparkline renders no header, neither title nor subtitle. La prop reste declaree (elle est heritee d'IChartBaseProps) et emet un avertissement de developpement si elle est passee. Voir #426.
categoriesArray<string>—⛔ Sans effet sur ce composant — a sparkline is a bare trend line: it draws no axis and no labels. La prop reste declaree (elle est heritee d'IChartBaseProps) et emet un avertissement de developpement si elle est passee. Voir #426.
fontSizeTFontSize—⛔ Sans effet sur ce composant — a sparkline renders no text at all. La prop reste declaree (elle est heritee d'IChartBaseProps) et emet un avertissement de developpement si elle est passee. Voir #426.
fontWeightTFontWeight—⛔ Sans effet sur ce composant — a sparkline renders no text at all. La prop reste declaree (elle est heritee d'IChartBaseProps) et emet un avertissement de developpement si elle est passee. Voir #426.

Emits ​

EventPayloadDescription
point-click(point: IChartPoint, event: MouseEvent | KeyboardEvent)Fired when a data point is activated — click anywhere on the SVG (nearest point), or click / Enter / Space on a rendered marker, special (min/max/last) marker, or bar

Slots ​

SlotBindingsDescription
tooltip{ point: IChartPoint, series: IChartSeries, index: number }Replace the default hover tooltip body
empty—Render when series is empty or contains no numeric data

Behaviour notes ​

Responsive drawing surface (#1324). The SVG viewBox follows the measured box (useChartSize, a ResizeObserver), 1 unit = 1 px, and preserveAspectRatio="none" is gone: stroke widths stay constant and markers stay round whatever the width / height. Until measured (SSR, first paint) the 120 × 30 fallback is used, so hydration is unchanged.

  • Point interaction — every rendered marker (showMarkers), special marker (showMin / showMax / showLast), and bar (type="column" / type="bar") is a point of the chart's single tab stop (roving tabindex, #1333: arrows move between marks, Home / End jump to the ends, see the OrigamChart page; role="button", a value-carrying aria-label) and activates on click, Enter, or Space. Clicking anywhere else on the SVG — e.g. a plain line/area sparkline with no markers shown — falls back to the nearest data point by horizontal position, so point-click stays reachable by mouse even with no visible marks.

Types ​

ts
type TChartSparklineKind = 'line' | 'area' | 'column' | 'bar'

Defined in src/types/Chart/chart-sparkline-kind.type.ts.

Rendering modes ​

ModeShapeUse case
linePolyline connecting data pointsTrend over time
areaLine with translucent fill belowEmphasise volume
columnVertical bars proportional to valueDiscrete periods
barHorizontal bars proportional to valueRanked comparison

Colour behaviour ​

Unlike full chart families, sparklines use a single color prop — no palette cycling. Passing a TIntent ('primary', 'success', 'danger', …) resolves to the matching design token. Raw CSS strings pass through untouched.

Special markers (showMin, showMax) override the colour locally:

  • Min → feedback.danger.bg token (red)
  • Max → feedback.success.bg token (green)
  • Last → same as the series color

Accessibility ​

The component uses a <figure> root (semantic landmark for a self-contained chart), an SVG with role="group", aria-label, <title>, and <desc> for screen reader support.

Accessibility — the <desc> summary is localised AND agrees in number. The <desc> text is not an English literal: it resolves through the DS t() mechanism against origam.chart.sparkline.desc*, and the grammatical form is chosen by Intl.PluralRules for the ACTIVE locale — never by a count === 1 test in the component. A translator supplies only the forms their language needs (_one / _other cover en and fr; a Russian translation adds _few with no component change), and a category a locale does not define falls back to _other rather than leaking the raw key.

Usage examples ​

Embedding in a table ​

vue
<table>
  <tbody>
    <tr v-for="row in data" :key="row.id">
      <td>{{ row.name }}</td>
      <td>{{ row.latestValue }}</td>
      <td>
        <OrigamChartSparkline
          type="line"
          :series="[{ name: row.name, data: row.history }]"
          :color="row.trend >= 0 ? 'success' : 'danger'"
          :width="100"
          :height="28"
          :show-last="true"
        />
      </td>
    </tr>
  </tbody>
</table>

KPI card with area sparkline ​

vue
<div class="kpi-card">
  <span class="kpi-value">$42,500</span>
  <OrigamChartSparkline
    type="area"
    :series="[{ name: 'Revenue', data: monthlyRevenue }]"
    color="success"
    :show-max="true"
    :show-last="true"
    :width="160"
    :height="40"
  />
</div>

With custom tooltip slot ​

vue
<OrigamChartSparkline
  type="line"
  :series="[{ name: 'Price', data: prices }]"
  :show-tooltip="true"
  :width="200"
  :height="48"
>
  <template #tooltip="{ point, index }">
    <div>
      <strong>Day {{ index + 1 }}</strong>
      <span>${{ point.y.toLocaleString() }}</span>
    </div>
  </template>
</OrigamChartSparkline>

Caveats ​

  • Only the first entry of the series array is rendered. Multi-series is not supported — use <OrigamChartCartesian> for that.
  • Data must be Array<number>. Object-form entries ({ x, y }) are accepted and the y value is extracted, but the x is ignored (no X axis).
  • animated is inert, not merely defaulted to false. There is no animation path in this component at all — no CSS class, no inline animation declaration — so setting animated="true" does nothing beyond raising a dev-build warning. animationDuration is inert for the same reason. See the Props table above and #426.
  • The tooltip (showTooltip) tracks the nearest column index by horizontal proximity; it does not snap to the exact SVG circle — this is intentional for the tiny surface area.