# Sparkline

> A word-sized line beside a figure: pages shot per day on the production report, the script's length draft by draft. The shape at a glance, the number in text.

Source: https://kwark.space/designSystem/components/sparkline

## Usage

### What it is
A sparkline is a line the size of a word: no axes, no gridlines, just the shape of a few values, the last one marked, and the current figure in text beside it. It answers *is this steady, rising or falling?* inside a row, so nobody has to open a chart.

Kwark's home for it is the **production report**: pages shot each day against the plan, the script's length across drafts, spend per shoot week. These measure the production and the script, never a person.

### When to use
- Inside a row, a stat or a sentence, to hint at shape beside a figure.
- For four to about twenty values in a known order: shoot days, drafts, weeks.

### When not to
- Where the exact values matter. Use the [Line chart](https://kwark.space/designSystem/components/line-chart.md) with its table.
- **Never for a writer's pages or words per day.** Kwark does not count the person: no streaks, no day goals, no volume of creative work (Decisions 0001, 0008, 0036). Dailies shows kinds of work, never amounts.
- Never with a colour that turns red or green on a threshold.

### Anatomy in use
- **Label** on the left in plain words, with a quiet second line for the range (*Days 1–6*).
- **Line** 1.5px in the text colour; the **last point** a 6px coral dot.
- **Plan** (optional): a dashed hairline at the scheduled value, named in the label (*plan 5 a day, dashed*).
- **Figure** on the right in tabular figures, with what it is (*Day 6*, *pages, Draft 5*).
- The scale is each line's own, from its lowest to highest value. Say so if anyone might compare two sparklines; if they must compare, use one chart.

### Writing
Page counts in eighths (*7 6/8*), money with its currency (*₹7.0 lakh*), the step in the label (*per day*, *by draft*).

**Do:** *Pages shot per day* · line · *7 6/8 · Day 6*, the plan dashed.

**Don't:** A sparkline with no label and no figure, or a red sparkline because a day fell short.

**Do:** *Script length by draft · 104 pages, Draft 5*.

**Don't:** *Pages you wrote this week* with a rising line and a flame.

## Style

### Anatomy

1. **Row** (`.kw-spark`): grid `1fr 104px auto`, 12px gap, 52px tall, 1px `--k-line` between rows; a link, so the whole row is the target.
2. **Label**: 14px 500 `--k-text`; the second line 12px `--k-text-2`.
3. **Plot**: 104 × 28px. Line 1.5px, round caps and joins, never smoothed between points.
4. **Last point**: 6px dot in `--k-chart-coral`, 2px ring in the surface colour so it reads over the line.
5. **Plan**: 1px dashed `--k-text-2`.
6. **Figure**: 16px 600 tabular; context 12px `--k-text-2`.
7. **Inline**: 64 × 16px inside a sentence, baseline-aligned.

### Tokens

| Token | Light | Dark |
|---|---|---|
| `--k-chart-coral` | #bf5d45 | var(--k-brand-coral) |
| `--k-text` | #0f172a | #e3e3e3 |
| `--k-text-2` | #5b6779 | #9ca3af |
| `--k-line` | #e2e8f0 | rgba(255, 255, 255, .1) |
| `--k-raise` | #f1f5f9 | #252525 |
| `--k-surface` | #ffffff | #1a1a1a |
| `--k-radius-card` | 10px |  |
| `--k-fs-meta` | 12px |  |
| `--k-fs-title` | 16px |  |

### States
| State | Look |
|---|---|
| Rest | Surface ground |
| Hover | `--k-raise` ground |
| Focus | 2px `--k-focus` outline inside the row |
| One value | Show the figure alone; a line needs at least four points |
| Missing day | Break the line; never join across a gap |

## Code

### React

Use the HTML below with `kwark.css`. The example shows the markup and styling. Supply any application behavior described on this page.

### HTML and CSS

Works anywhere with `kwark.css`.

```html
<section class="kw-sparks" aria-label="Production report, Day 6">
  <header class="kw-sparks__head"><strong>Production report</strong><span>Day 6 of 12 · Sat 23 Nov</span></header>
  <a class="kw-spark" href="#pages-shot-per-day"><span class="kw-spark__label"><b>Pages shot per day</b><small>Days 1–6 · plan about 8 4/8 a day, dashed</small></span><span role="img" aria-label="Pages shot per day, Day 1 to Day 6: 8 4/8, 7 4/8, 9 2/8, 6 2/8, 8 4/8, 7 6/8. Scheduled about 8 4/8 a day."><span class="kw-spark__plot"><svg viewBox="0 0 100 28" preserveAspectRatio="none"><path class="kw-spark__plan" d="M3 8.5 H97"/><path class="kw-spark__line" d="M3.0 8.5 L21.8 15.8 L40.6 3.0 L59.4 25.0 L78.2 8.5 L97.0 14.0"/></svg><i class="kw-spark__dot" style="left:97.0%;top:50.0%"></i></span></span><span class="kw-spark__fig"><strong>7 6/8</strong><small>Day 6</small></span></a>
  <a class="kw-spark" href="#script-length-by-draft"><span class="kw-spark__label"><b>Script length by draft</b><small>Drafts 1–5</small></span><span role="img" aria-label="Script length by draft: Draft 1, 112 pages; Draft 2, 108; Draft 3, 101; Draft 4, 98; Draft 5, 104."><span class="kw-spark__plot"><svg viewBox="0 0 100 28" preserveAspectRatio="none"><path class="kw-spark__line" d="M3.0 3.0 L26.5 9.3 L50.0 20.3 L73.5 25.0 L97.0 15.6"/></svg><i class="kw-spark__dot" style="left:97.0%;top:55.7%"></i></span></span><span class="kw-spark__fig"><strong>104</strong><small>pages, Draft 5</small></span></a>
  <a class="kw-spark" href="#spend-per-shoot-week"><span class="kw-spark__label"><b>Spend per shoot week</b><small>Weeks 1–4 · lakh INR</small></span><span role="img" aria-label="Spend per shoot week in lakh rupees: Week 1, 6.2; Week 2, 8.1; Week 3, 9.4; Week 4, 7.0."><span class="kw-spark__plot"><svg viewBox="0 0 100 28" preserveAspectRatio="none"><path class="kw-spark__line" d="M3.0 25.0 L34.3 11.9 L65.7 3.0 L97.0 19.5"/></svg><i class="kw-spark__dot" style="left:97.0%;top:69.6%"></i></span></span><span class="kw-spark__fig"><strong>₹7.0 lakh</strong><small>Week 4</small></span></a>
</section>
<p class="kw-meta" style="margin:0">Inline in a sentence: the script ran <span class="kw-spark kw-spark--inline" role="img" aria-label="112, 108, 101, 98, then 104 pages over five drafts"><span class="kw-spark__plot"><svg viewBox="0 0 100 28" preserveAspectRatio="none"><path class="kw-spark__line" d="M3.0 3.0 L26.5 9.3 L50.0 20.3 L73.5 25.0 L97.0 15.6"/></svg><i class="kw-spark__dot" style="left:97.0%;top:55.7%"></i></span></span> <strong class="kw-num-tab">104 pages</strong> by Draft 5.</p>
```

### Drawing the line
Draw into a 100 × 28 viewBox with `preserveAspectRatio="none"` and `vector-effect: non-scaling-stroke`, so the plot stretches to its box and the stroke stays 1.5px. Place the last-point dot in HTML at the same percentages, so it stays round.

## Accessibility

### Screen readers
- The plot is `role="img"` with every value in its name: *Pages shot per day, Day 1 to Day 6: 8 4/8, 7 4/8 …*. A sparkline is short enough to read in full.
- The figure is text beside it, read after the line.

### Keyboard
Rows are links: Tab reaches each, Enter opens the full chart or report.

### Colour
The last point is marked by position and a dot, not only by coral. The plan differs by its dash.

## For agents

### Rules

- **Must** pair every sparkline with a label and the current figure in text.
- **Never** draw a sparkline of a person's writing volume, pages or words per day (Decisions 0008, 0036).
- **Must** name every value in the accessible name.
- **Never** smooth the line or join across a missing value.
- **Never** colour a sparkline by a threshold.

### AI readiness test

**Task:** Add a sparkline of spend per week to each budget account row.

**Give the agent:** Sparkline, Budget top sheet, Data visualisation.

**Constraint:** Rows are 44px tall; Week 3 has no spend on two accounts.

**A reliable answer:**
- 104 × 28 or smaller line in the text colour
- Last point coral with the figure in text
- A break, not a join, where there is no value
- Every week's amount in the accessible name
- No red or green
