TowerChart
<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.
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> ));}| 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
Section titled “How it differs from Towers”- It keeps no state. Selection is whatever you pass in
selectedKey. WithoutonSelect, 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-swatchclasses from the stylesheet to build one:
<span className="rt-swatch is-retention" /> kept by the cedant<span className="rt-swatch rt-status-quoted" /> quotedThe status classes are rt-status-signed, rt-status-firm-order, rt-status-quoted and rt-status-indication.
The optional blockKind from the reinsurer viewpoint 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.