BarChart#

Labelled horizontal bars, all measured against one scale.

Import#

TSX
import { BarChart, commonScale } from '@sigx/terminal';

Usage#

TSX
const items = [
    { label: 'p50', value: p50 },
    { label: 'p90', value: p90 },
    { label: 'p99', value: p99 },
];

<BarChart items={items} scale={commonScale(items.map((i) => i.value))} width={40} />

scale is required, and that is the point#

Sizing each bar to its own value is not a chart — it is a list of full bars. A 12µs queue wait and a 47ms turn would draw identically, and the comparison you opened the panel for is exactly what you would lose.

Derive it once with commonScale(values). For data with a long tail, commonScale(values, { clip: 0.99 }) ignores the top percentile so a single pathological outlier cannot flatten every other bar to nothing.

Percentile rows are three items; so is anything else you want compared side by side.

Props#

PropTypeNotes
itemsBarChartItem[]required{ label, value, tone?, text? }; value: null is "no reading", drawn as such rather than as zero
scalenumberrequired — the shared maximum
widthnumberbar area in cells
labelWidthnumberlabel column width
format(value: number) => stringtrailing text per bar
colorstringtheme token
thresholdsThreshold[]colour by magnitude
emptyTextstringshown when items is empty

See also#

  • Meter — one ratio rather than a comparison.