Skip to content

Sparkline ^0.1.15 ​

Tiny inline charts for cards, tables, and KPIs. Line, area, or bar variants with auto positive/negative coloring and optional reference line.

Line ​

vue
<VxSparkline :data="[4,8,6,10,7,12,9,15,11,17,14,20]" :width="160" :height="40" />

Area ​

vue
<VxSparkline :data="data" type="area" color="#22c55e" />

Bar ​

vue
<VxSparkline :data="data" type="bar" color="#f59e0b" />

Auto color ^0.1.15 ​

Color switches automatically based on trend direction (first vs last value).

Rising — green
Falling — red
vue
<VxSparkline :data="trend" autoColor />
<VxSparkline :data="trend" type="bar" autoColor />

With pulsing end dot ​

vue
<VxSparkline :data="data" showDot autoColor />

Reference line ^0.1.15 ​

Show a baseline (target, zero, opening price).

Stock price
$125.00
+25% from open
vue
<VxSparkline :data="prices" :reference="openPrice" type="area" autoColor showDot />

Inside stat cards ​

Revenue
$12,480
Churn
3.2%
Signups
482

Inside a table ​

CompanyTrend (30d)Change
Acme Corp+12.4%
Globex Ltd-4.1%
Soylent Inc+2.3%
Initech-8.7%

Bar with auto colors relative to reference ​

vue
<VxSparkline :data="data" type="bar" autoColor :reference="50" />

Live updating ​

vue
<script setup>
import { ref, onMounted, onBeforeUnmount } from 'vue'
import { VxSparkline } from 'veloxui'

const live = ref([5, 8, 6, 10, 7, 12, 9, 15, 11, 17])
let t
onMounted(() => {
  t = setInterval(() => {
    const next = Math.max(2, Math.min(30, live.value.at(-1) + (Math.random() - 0.5) * 8))
    live.value = [...live.value.slice(1), Math.round(next)]
  }, 1200)
})
onBeforeUnmount(() => clearInterval(t))
</script>

<template>
  <VxSparkline :data="live" type="area" showDot />
</template>

API ​

PropTypeDefaultDescription
datanumber[][]Data series
type'line' | 'area' | 'bar''line'Visual variant
widthnumber120SVG width
heightnumber36SVG height
colorstringvar(--primary)Stroke / fill color
autoColorbooleanfalseColor by trend direction (up/down)
upColorstring#22c55eColor when rising
downColorstring#ef4444Color when falling
referencenumber—Horizontal baseline value
strokeWidthnumber2Line stroke thickness
smoothbooleantrueSmooth curve
showDotbooleanfalsePulsing dot on last value
showAreabooleantrueArea fill under line (type='area')
gapnumber2Gap between bars
animatebooleantrueAnimate on data change
animationDurationnumber700Tween duration in ms
min / maxnumberautoForce value bounds