components/Breakdown
import { … } from 'zidane-ui'ui/src/components/Breakdown.tsx
Components#
BreakdownComponent#
Renders parts of a whole as sorted bars, or as one split bar and a list.
function Breakdown(props: BreakdownProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | BreakdownProps |
Returns
ElementProps
| Name | Type | Default | Description |
|---|---|---|---|
| className? | string | Extra classes on the root element. | |
| format? | (value: number) => string | Formats a value. Default: the number in full, up to two decimals. | |
| highlight? | string | The label of the part to emphasize: the others dim. | |
| mode? | 'bars' | 'stacked' | 'bars' |
|
| parts | readonly BreakdownPart[] | The parts, in any order. Negative values count as 0. | |
| style? | CSSProperties | Inline styles on the root element. | |
| title? | ReactNode | A title above the bar. | |
| top? | number | Bars: how many of the largest parts take the accent. Default: those that make half the whole, at most 3. | |
| total? | number | The whole. Default: the sum of the parts. Shares are of this. | |
| unit? | string | The values' unit, for example |
Functions#
breakdownSlicesFunction#
The parts as drawn: largest first, the parts under 3% merged into one
(past BREAKDOWN_SHOW_ALL parts, when there are two or more of them), each with its share of total
(default: the sum).
function breakdownSlices(
parts: readonly BreakdownPart[],
total: number | undefined,
otherLabel: string,
): { slices: BreakdownSlice[]; total: number }Parameters
| Name | Type | Description |
|---|---|---|
| parts | readonly BreakdownPart[] | The parts. |
| total | number | undefined | The whole. |
| otherLabel | string | The merged part's label. |
Returns
{ slices: BreakdownSlice[]; total: number }Interfaces#
BreakdownPropsInterface#
Props for Breakdown.
interface BreakdownPropsProperties
| Name | Type | Default | Description |
|---|---|---|---|
| className? | string | Extra classes on the root element. | |
| format? | (value: number) => string | Formats a value. Default: the number in full, up to two decimals. | |
| highlight? | string | The label of the part to emphasize: the others dim. | |
| mode? | 'bars' | 'stacked' | 'bars' |
|
| parts | readonly BreakdownPart[] | The parts, in any order. Negative values count as 0. | |
| style? | CSSProperties | Inline styles on the root element. | |
| title? | ReactNode | A title above the bar. | |
| top? | number | Bars: how many of the largest parts take the accent. Default: those that make half the whole, at most 3. | |
| total? | number | The whole. Default: the sum of the parts. Shares are of this. | |
| unit? | string | The values' unit, for example |
Types#
BreakdownPartType#
One part: its label and its value.
type BreakdownPart = readonly [label: string, value: number]