Data Visualisation

Sparkline

<DomSparkline>

Compact trends for metric cards, table cells, and resource lists.

Trends inside a revenue table

Revenue and seven-week trends by plan
PlanRevenueSeven-week trend
Starter£7,000
Starter revenue trend
Growth£17,200
Growth revenue trend
Scale£21,600
Scale revenue trend
Install
npm install @getdom/studio
vue
<script setup>
import '@getdom/studio/style.css';
import { DomSparkline } from '@getdom/studio';
const products = [
	{ name: 'Starter', revenue: '£7,000', values: [4, 8, 6, 9, 7, 12, 14] },
	{ name: 'Growth', revenue: '£17,200', values: [12, 10, 15, 12, 16, 18, 22] },
	{ name: 'Scale', revenue: '£21,600', values: [8, 12, 9, 14, 20, 19, 25] },
];
/** Projects weekly measurements into the same record format used by full-size charts. */
function trendRows(values) { return values.map((value, index) => ({ week: `Week ${index + 1}`, value })); }
</script>
<template>
	<div class="w-full overflow-auto">
		<table class="w-full text-left text-sm"><caption class="sr-only">Revenue and seven-week trends by plan</caption>
			<thead class="text-xs text-muted-fg"><tr><th scope="col" class="py-3">Plan</th><th scope="col" class="py-3 text-right">Revenue</th><th scope="col" class="py-3 pl-6">Seven-week trend</th></tr></thead>
			<tbody><tr v-for="product in products" :key="product.name" class="border-t border-border"><th scope="row" class="py-4 font-medium">{{ product.name }}</th><td class="py-4 text-right tabular-nums">{{ product.revenue }}</td><td class="w-40 py-4 pl-6"><DomSparkline :title="`${product.name} revenue trend`" :rows="trendRows(product.values)" x-key="week" :series="[{ key: 'value', color: 'chart-2' }]" /></td></tr></tbody>
		</table>
	</div>
</template>

Working with your data

The compact chart hides its heading visually, but retains an accessible name and keyboard inspection. Provide a meaningful title when embedding it in a card or table. Enable showTable when a standalone data alternative is needed.

Explore Data Visualisation

Reference

Props

Control props

NameTypeTSDefaultDescription
rowsarrayArray<unknown>[]Application-owned records. Missing measurements remain gaps; zero is valid.
seriesarrayArray<unknown>[]Field keys or { key, label, color, dashed } definitions. Keep keys stable when filtering.
xKeystringstring'date'Record field used for category or horizontal axis values.
xType'category' | 'time' | 'number'string'category'Category preserves row order; time and number use proportional, sorted coordinates.
titlestringstring'Trend'
descriptionstringstring''Supporting context, units, or reporting period.
heightnumbernumber48
format'number' | 'compact' | 'currency' | 'percent'string'number'Value format. Percent expects fractions, such as 0.25 for 25%.
currencystringstring'GBP'ISO currency code for currency formatting.
localestringstring'en-GB'Locale used for number and date labels.
valueFormatterfunctionFunctionOptional (value) => string override shared by axes, tooltips, and tables.
xFormatterfunctionFunctionOptional (value) => string override for category/date labels.
yFormatterfunctionFunctionOptional (value) => string for value-axis ticks only. Tooltips and tables keep the full valueFormatter output.
loadingbooleanbooleanfalseShow a loading state in the reserved plot space.
errorstringstring''Show an application-owned error with a retry action.
emptyLabelstringstring'No data for this period'Message when no finite measurements are available.
legendbooleanbooleanfalse
showTablebooleanbooleanfalse
gridbooleanbooleantrueShow subtle value-axis grid lines.
curve'linear' | 'monotoneX' | 'step'string'linear'Line interpolation. Linear avoids implying unobserved smooth changes.

Auto-generated from Sparkline.props and inline _edit hints.

Events

NamePayloadDescription
@select{ row, index }Original application record selected by click or Enter.
@retryRequests another attempt to load application data.

Names auto-detected from defineEmits and source emit() calls; payload and description from __doc.events when present.

Keyboard

  • Arrow keys / Home / EndInspect data points.
  • EnterSelect the inspected record.