Base JS behaviour

Sparkline

The tiny line chart with an area and an end dot; trend coloring and a draw-in on reveal.

Real scenarios

The component as it is used in a product — not a specimen grid.

Marketplace, Monday report

Each store gets one line in its row: green or red says which way the week went, the end dot marks yesterday, and the actual numbers sit beside it visually hidden for screen readers.

Daily sales of the last seven days per store
Store Daily sales — last 7 days Week total Change
Woodart Gallery Home decor Daily sales: 12، 18، 14، 22، 19، 26، 31 142 orders +12.4٪
Nilgoon Books Books & stationery Daily sales: 22، 21، 23، 20، 19، 17، 15 137 orders −8.1٪
Cafe Dami Coffee & beans Daily sales: 9، 11، 10، 13، 12، 15، 14 84 orders +3.2٪

The status page of one cluster

Row height wants a shorter line: --nx-sparkline-height squeezes it, and area="false" drops the fill for the rows that would get noisy. The worker stays unjudged — no trend, the quiet neutral — while the same rising line means worry on the database and good news on the cache hit rate; the words decide, not the slope.

  • App worker CPU, 7 days CPU, 7 days: 41، 38، 44، 40، 37، 42، 39 39٪
  • Database CPU, 7 days CPU, 7 days: 55، 62، 58، 71، 64، 76، 69 69٪
  • Cache Hit rate, 7 days Hit rate, 7 days: 72، 74، 73، 76، 78، 77، 80 80٪

Falling can be good news

Customer churn, down six weeks straight. trend="down" paints the line red because that is what a falling line looks like here — the badge and the sentence carry the verdict, so color is never the only cue.

2.1٪ improving Weekly churn percent: 4، 4، 3، 3، 3، 2، 2 Weekly churn — from 4% six weeks ago to 2.1% this week, after the onboarding rework.

Important props

Important props
Prop Type Default What it does
data array [] The number series; paths are built in PHP.
trend string null up or down to color the trend.
area bool true Fill under the line.

Snippet

<x-nx::sparkline :data="[12, 18, 14, 22, 19, 26]" trend="up" />