# Bar chart

> Horizontal bars from zero for a few named amounts: shoot days per location, pages per act, cost by account. Names on the left, values at the bar ends, a table behind.

Source: https://kwark.space/designSystem/components/bar-chart

## Usage

### What it is
Bars compare named amounts by length. Kwark draws them horizontally, so long names (*Lumen Studios, Stage 2*) read without rotation, and always from zero.

The specimen answers a producer's question during scheduling: **how many shoot days does each location need?** The half days are split days, where the unit makes a company move at lunch (see the [Gantt chart](https://kwark.space/designSystem/components/gantt-chart.md)).

### When to use
- Up to about eight named amounts: shoot days by location, pages per act, cost by budget account, scenes per character.
- When the reader wants to rank or compare at a glance.

### When not to
- Change over time. Use a [Line chart](https://kwark.space/designSystem/components/line-chart.md).
- Parts of one whole with three or fewer parts. A sentence or a [Donut chart](https://kwark.space/designSystem/components/donut-chart.md).
- **Never to rank people**: not crew by hours, not writers by pages.

### Anatomy in use
- One colour for one measure (`--k-chart-aqua`). The row the reader came from (the location open in the list) takes coral and a raised row.
- Sorted by value, unless the order means something: acts stay in story order, days stay in date order.
- The value is printed at the end of each bar, in the unit (*5 days*, *2½ days*).
- A scale under the bars at round values; no gridlines through them.

### Writing
The title is the measure and its grouping (*Shoot days by location*). The reading names the total and the largest: *12 shoot days at 5 locations. Lumen Studios carries 5 of them.*

**Do:** Five aqua bars sorted by days, values at the ends, names with their sets.

**Don't:** A 3D bar chart, a gradient fill, or bars that start at 1 day to make the difference look bigger.

## Style

### Anatomy

1. **Frame**: `.kw-viz` card.
2. **Row**: grid `168px 1fr`, 36px tall, 8px gap between rows.
3. **Name**: 14px 500, truncated; the set under it 12px `--k-text-2`.
4. **Bar**: 14px tall, square at zero, 3px corners at the end; width is the value over the scale maximum.
5. **Value**: 12px 600 tabular, 8px after the bar end.
6. **Current row**: `--k-raise` ground, bar in `--k-chart-coral`.
7. **Scale**: ticks at round values, 12px `--k-text-2`.
8. **Phone** (under 480px): name above the bar, both full width.

### Tokens

| Token | Light | Dark |
|---|---|---|
| `--k-chart-aqua` | #509ca0 | var(--k-brand-aqua) |
| `--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-surface` | #ffffff | #1a1a1a |
| `--k-raise` | #f1f5f9 | #252525 |
| `--k-radius-card` | 10px |  |
| `--k-fs-meta` | 12px |  |

### States
| State | Look |
|---|---|
| Rest | Aqua bars |
| Current | Raised row, coral bar |
| Zero | No bar; the value *0 days* sits at the start |
| Table | Location, set and days, right-aligned |

## 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
<figure class="kw-viz">
  <figcaption class="kw-viz__head"><div><p class="kw-viz__title">Shoot days by location</p><p class="kw-viz__reading">12 shoot days at 5 locations. Lumen Studios carries 5 of them.</p></div><label class="kw-viz__switch"><input class="kw-visually-hidden" type="checkbox" role="switch" aria-label="Show shoot days by location as a table"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 10h18M3 15h18M9 10v10"/></svg><span>Table</span></label></figcaption>
  <div class="kw-viz__plot">
    <div class="kw-bars2" style="--kw-max:6" aria-hidden="true">
      <div class="kw-bars2__row" data-current><span class="kw-bars2__name"><b>Lumen Studios, Stage 2</b><small>INT. EDIT SUITE</small></span><span class="kw-bars2__track"><i style="--v:5"></i><em>5 days</em></span></div>
      <div class="kw-bars2__row"><span class="kw-bars2__name"><b>Mira's flat, Versova</b><small>INT. FLAT</small></span><span class="kw-bars2__track"><i style="--v:2.5"></i><em>2½ days</em></span></div>
      <div class="kw-bars2__row"><span class="kw-bars2__name"><b>Old Film Lab rooftop</b><small>EXT. ROOF · night</small></span><span class="kw-bars2__track"><i style="--v:2"></i><em>2 days</em></span></div>
      <div class="kw-bars2__row"><span class="kw-bars2__name"><b>Andheri East, Lane 4</b><small>EXT. STREET</small></span><span class="kw-bars2__track"><i style="--v:1.5"></i><em>1½ days</em></span></div>
      <div class="kw-bars2__row"><span class="kw-bars2__name"><b>Highway, Goregaon</b><small>EXT. HIGHWAY · dawn</small></span><span class="kw-bars2__track"><i style="--v:1"></i><em>1 day</em></span></div>
      <div class="kw-bars2__scale"><span></span><span class="kw-bars2__ticks"><i style="left:0%">0</i><i style="left:33.33333333333333%">2</i><i style="left:66.66666666666666%">4</i><i style="left:100%">6</i></span></div>
    </div>
    <p class="kw-viz__foot" aria-hidden="true"><span>Bars start at zero · half days are split days with a company move</span></p>
  </div>
  <div class="kw-viz__table"><table><caption>Shoot days by location</caption><thead><tr><th scope="col">Location</th><th scope="col">Set</th><th scope="col" class="num">Shoot days</th></tr></thead><tbody><tr><th scope="row">Lumen Studios, Stage 2</th><td>INT. EDIT SUITE</td><td class="num">5 days</td></tr><tr><th scope="row">Mira's flat, Versova</th><td>INT. FLAT</td><td class="num">2½ days</td></tr><tr><th scope="row">Old Film Lab rooftop</th><td>EXT. ROOF · night</td><td class="num">2 days</td></tr><tr><th scope="row">Andheri East, Lane 4</th><td>EXT. STREET</td><td class="num">1½ days</td></tr><tr><th scope="row">Highway, Goregaon</th><td>EXT. HIGHWAY · dawn</td><td class="num">1 day</td></tr></tbody></table></div>
</figure>
```

### Building it
Set `--kw-max` on the chart (the top of the scale) and `--v` on each bar; CSS sets the width as `calc(var(--v) / var(--kw-max) * 100%)`. The table is generated from the same rows.

## Accessibility

### Screen readers
The drawn bars are `aria-hidden`; the table carries every name, set and value, and the reading line says the finding.

### Colour
Values print beside every bar, so nothing depends on telling colours apart. The current row is marked by its raised ground as well as colour.

## For agents

### Rules

- **Must** start bars at zero.
- **Must** print the value with its unit at the end of every bar.
- **Never** rank people by a bar chart.
- **Always** keep story or date order when the order means something.
- **Always** carry a table with the same rows.

### AI readiness test

**Task:** Show pages per act for Blank Pages.

**Give the agent:** Bar chart, Story spine, Data visualisation.

**Constraint:** Acts keep story order; Act 2 has two parts.

**A reliable answer:**
- Bars in act order, not sorted
- Pages in eighths at the bar ends
- One colour
- Table switch
- No judgement of act length
