# TowerChart

> The component that draws a single tower, for building your own layout.

`<TowerChart />` draws one tower and nothing else: no heading, no key, no state. Use it when `<Towers />` does not fit your page, for instance to put each tower in its own card or tab.

```tsx
import { TowerChart, assignFills } from '@vinsa/towers';
import '@vinsa/towers/styles.css';

function RiskTowers({ risk }) {
  // One map for the whole risk, so a contract keeps its colour in every tower.
  const fills = useMemo(() => assignFills(risk.towers), [risk]);
  const [selected, setSelected] = useState<string | null>(null);

  return risk.towers.map((tower) => (
    <section key={tower.towerNo}>
      <h3>{tower.towerName}</h3>
      <TowerChart tower={tower} fills={fills} selectedKey={selected} onSelect={setSelected} />
    </section>
  ));
}
```

## Props

| Prop | Type | Default | |
| --- | --- | --- | --- |
| `tower` | `Tower` | required | One entry from a risk's `towers`. |
| `fills` | `Map<string, string>` | worked out per tower | Colour for each `colorKey`. Share one map between charts. |
| `selectedKey` | `string \| null` | `null` | The highlighted layer. |
| `onSelect` | `(key) => void` | | Makes layers clickable. Called with `null` when the selection is cleared. |
| `loss` | `number \| null` | `null` | Draws a loss of this amount. |
| `scale` | `'amount' \| 'even'` | `'amount'` | |
| `height` | `number` | `420` | Plot height in pixels. |

## How it differs from Towers

- **It keeps no state.** Selection is whatever you pass in `selectedKey`. Without `onSelect`, layers are not clickable at all.
- **Colours are yours to share.** Each chart on its own assigns fills from the first colour, so two towers of one risk would not match. Build one map with `assignFills(risk.towers)` and pass it to each.
- **There is no key.** Use the `rt-swatch` classes from the stylesheet to build one:

```tsx
<span className="rt-swatch is-retention" /> kept by the cedant
<span className="rt-swatch rt-status-quoted" /> quoted
```

The status classes are `rt-status-signed`, `rt-status-firm-order`, `rt-status-quoted` and `rt-status-indication`.

The optional `blockKind` from the [reinsurer viewpoint](https://towers.vinsa.dev/docs/api/viewpoints.md) identifies named Lines, Other reinsurers and cedant retention. Quoted and indication Lines show their status in the tooltip and use the dashed `rt-quote` modifier alongside their status class. Add the same modifier to the corresponding swatches in a custom key.
