Towers
<Towers /> takes the API response and draws every tower in it: one section per risk, the risk’s towers side by side, and a key underneath.
import { Towers } from '@vinsa/towers';import '@vinsa/towers/styles.css';
<Towers data={response} />;Property portfolio
Casualty portfolio
When the response has more than one risk, each gets a heading: the insured’s name, or failing that the policy reference or risk id.
| Prop | Type | Default | |
|---|---|---|---|
data |
TowersResponse |
required | The API response, unchanged. |
riskId |
string |
every risk | Draw only this risk. |
selectedKey |
string | null |
own state | The highlighted layer. Pass it to control selection yourself. |
onSelect |
(key, risk) => void |
Called when a layer is clicked. key is null when the selection is cleared. |
|
loss |
number | null |
null |
Draws a loss of this amount up every tower. |
scale |
'amount' | 'even' |
'amount' |
Heights to scale, or every band the same height. |
height |
number |
420 |
Plot height of each tower, in pixels. |
legend |
boolean |
true |
Show the key under each risk, including an Other reinsurers entry when that block is present. |
className |
string |
Added to the outer element. |
One risk at a time
Section titled “One risk at a time”Pass riskId to draw a single risk, for a page with a risk picker of its own.
<Towers data={response} riskId="R-1001" />Selection
Section titled “Selection”Clicking a layer highlights it and dims the rest. Clicking it again, or the empty plot, clears the selection.
Left alone, the component remembers the selection itself. To react to it, pass onSelect. The key is the layer’s layerRef, or its layerName when it has no reference.
<Towers data={response} onSelect={(key, risk) => { if (key) openLayerPanel(risk.riskId, key); }}/>To own the selection, for example to keep it in the URL, pass selectedKey as well:
const [selected, setSelected] = useState<string | null>(null);
<Towers data={response} riskId={riskId} selectedKey={selected} onSelect={setSelected} />;A controlled selectedKey applies to every risk on show, so pair it with riskId.
scale="amount" draws heights in proportion to amounts, which is truthful but can squash a small layer under a large one. scale="even" gives every band the same height so each layer is readable.
loss washes the tower up to that amount and flags the level. See Test a loss.