Skip to content

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.

TypeScript
function Breakdown(props: BreakdownProps): Element
Parameters
NameTypeDescription
propsBreakdownProps

BreakdownProps.

Element
Breakdown props
NameTypeDefaultDescription
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'

bars: one bar per part. stacked: one split bar and a list.

partsreadonly 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 tokens (see withUnit).

ui/src/components/Breakdown.tsx:143

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).

TypeScript
function breakdownSlices(
  parts: readonly BreakdownPart[],
  total: number | undefined,
  otherLabel: string,
): { slices: BreakdownSlice[]; total: number }
Parameters
NameTypeDescription
partsreadonly BreakdownPart[]

The parts.

totalnumber | undefined

The whole.

otherLabelstring

The merged part's label.

{ slices: BreakdownSlice[]; total: number }

ui/src/components/Breakdown.tsx:75

Interfaces#

BreakdownPropsInterface#

Props for Breakdown.

TypeScript
interface BreakdownProps
BreakdownProps properties
NameTypeDefaultDescription
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'

bars: one bar per part. stacked: one split bar and a list.

partsreadonly 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 tokens (see withUnit).

ui/src/components/Breakdown.tsx:22

Types#

BreakdownPartType#

One part: its label and its value.

TypeScript
type BreakdownPart = readonly [label: string, value: number]

ui/src/components/Breakdown.tsx:19