# CitySkyline (/docs/charts/city-skyline)

CitySkyline compares a handful of groups on two variables at once: how big each one is, and how activated it is.
**Height** is the primary, precise channel: zero-anchored bars, like a MiniBar. The **lit-window fraction** is a
secondary, low-precision channel you read as "mostly lit, half lit, or dark", not as a number. Omit `lit` everywhere and
you get a plain bar row.

```tsx
import { CitySkyline } from "@microcharts/react/city-skyline";

<CitySkyline data={teams} unit="teams" title="Team sizes" />
```

## Install

```tsx
import { CitySkyline } from "@microcharts/react/city-skyline";

<CitySkyline data={teams} unit="teams" title="Team sizes" />
```

Setup (package + stylesheet): [Quickstart](/docs/quickstart#set-up-with-an-ai-agent) or paste [`/agent-setup.md`](/agent-setup.md) into your agent.

## Try it

```tsx
import { CitySkyline } from "@microcharts/react/city-skyline/interactive";

<CitySkyline
  data={teams}
/>
```

## When to use it

Use it for team or region size plus an activation read, an org KPI where two variables are the story, or a per-BU
comparison with utilization. For a single variable reach for `MiniBar`; skip it when you need a precise activation read,
or when you have more than about eight groups.

## Sizing

**omit lit for a plain bar row**

```tsx
<CitySkyline data={teams.map(({ label, value }) => ({ label, value }))} />
```

**labelled, the two-variable read**

```tsx
<CitySkyline data={teams} labels />
```

## Variants

Windows appear whenever `lit` is present. Heights stay zero-anchored bars either way, and nothing is encoded in building
width: width, roof, and ground are constants.

```tsx
<CitySkyline data={teams.map(({ label, value }) => ({ label, value }))} />
<CitySkyline data={teams} label="value" />
```

## Edge cases

```tsx
// all-equal values read as a flat roofline — no artificial variation is added
<CitySkyline
  data={[
    { label: "A", value: 30, lit: 0.8 },
    { label: "B", value: 30, lit: 0.4 },
    { label: "C", value: 30, lit: 0 },
  ]}
/>
```

```tsx
// a building under one window row renders as a solid tower — its lit
// fraction still reads on hover and keyboard focus
<CitySkyline
  data={[
    { label: "big", value: 40, lit: 0.8 },
    { label: "tiny", value: 2, lit: 0.9 },
  ]}
/>
```

All-equal values render as a flat roofline; no variation is added to make the row look busier. Lit windows are quantized
to the window count and filled bottom-up, so activation reads as a fill level. The secondary channel drops out before
the primary: a building too short for one window row renders as a solid tower, and its `lit` still shows in the
per-building readout on hover or keyboard focus.

## Four homes

**In a sentence**

```tsx
<p>
  Team sizes across eng{" "}
  <span className="mc-inline">
    <CitySkyline data={teams} summary={false} />
  </span>{" "}
  — Platform is largest at 46, 70% activated.
</p>
```

**In a table cell**

```tsx
<td>
  <CitySkyline data={teams} />
</td>
```

**In a KPI card**

```tsx
<div className="kpi">
  <span className="figure">46</span>
  <span className="unit">heads · 70% lit</span>
  <CitySkyline data={teams} />
</div>
```

**In a tab header**

```tsx
<button className="tab">
  Platform <CitySkyline data={teams} />
</button>
```

## Accessibility

The accessible name gives the count and the tallest: **"3 groups; tallest A at 46."** The interactive entry roves the
buildings with ←/→ or hover and announces each one. On the team demo at the top of this page, Platform reads "Platform:
46; 70% lit."

The interactive entry follows the shared [interaction contract](/docs/accessibility#one-interaction-contract):
arrow keys rove between units on both axes, `Home` and `End` jump to the ends, and a click, tap, `Enter` or
`Space` selects a unit — pinning its readout so it survives blur, until you select it again, press `Escape`, or
press outside the chart. On touch, a tap pins and a drag scrubs.

## Props

| Prop | Type | Description |
| --- | --- | --- |
| `data` (required) | `{ label, value, lit? }[]` | value = height; lit = 0–1 window fraction. |
| `labels` | `boolean` | Category labels under the buildings. |
| `ground` | `boolean` | The baseline hairline (default true). |
| `label` | `"none" \| "value"` | Numeral above each building. |
| `unit` | `string` | Category noun for the summary (default 'groups'). |
| `bw` | `number` | Building width in viewBox units (default 9). |
| `gap` | `number` | Gap between buildings in viewBox units (default 3). |
| `fontSize` | `number` | Type size of the value numerals, in viewBox units. Defaults from `height`. |
| `animate` | `boolean` | (interactive) Opt-in entrance motion when the chart mounts client-side — add `import "@microcharts/react/motion"` once. Inert on the server, on hydrated server HTML, and under `prefers-reduced-motion`. |

Plus the shared grammar — `data`, `domain`, `color`, `title`, `summary`, `format` — and the layout props (`width`, `height`, `className`, `style`) that every chart accepts. Interactive entries also share `animate` and `live`, and — wherever a chart has more than one navigable unit — `onActive`, `onSelect`, `selectedIndex` and `defaultSelectedIndex`; and — wherever the chart shows a hover value — `readout`. See [the shared grammar](/docs/quickstart#the-shared-grammar).
