On this page

Charts

BridgeChart

A bridge in vertical columns: the start, then a column for the running total after each change. Each column carries a cap for the change that led to it, the new total above and a short note below.

When to use it #

Use BridgeChart when the totals matter as much as the changes: a quote that shrinks to the profit you kept, a budget that is spent down in stages. Each column is a running total, so a reader can see what was left after every step. The cap on a column marks the change (loss or gain), note names it (“−$260 discount”), and a gradient area joins the totals (area={false} removes it). The last column is solid and emphasized; highlightLast={false} keeps it as hatched as the rest. A callout pins a pill above the last column for the headline numbers, such as “$400 kept | 12.3% margin”.

If you want one row per change that ends in a calculated total, use WaterfallChart. A bridge shows the totals, a waterfall shows the changes between them.

Import #

Terminal
npm i tally-charts
app/profit.tsx
import { BridgeChart } from 'tally-charts'
import 'tally-charts/theme.css'

Examples #

Every step has a note, the short word that follows the change. highlightLast={false} keeps the last column hatched like the others, for a result that is not the point of the chart.

From quote to cash collected
View of From quote to cash collected
From quote to cash collected
ColumnChangeTotal
Quotedno value$48,000
After change orders+$3,600 change orders$51,600
After discounts−$2,400 discounts$49,200
After retainage−$3,000 retainage$46,200
After write-offs−$1,700 write-offs$44,500

callout is an array of segments, so it stays serializable: the pill sits above the last column, which is solid by default (highlightLast).

Estimated profit to profit kept, one job
View of Estimated profit to profit kept, one job

What a step leaks (or gains) is drawn as a hatched cap on its column. The callout pill is lifted clear of any column labels it reaches over.

Props #

NameTypeDefaultRequiredDescription
activeIdId | null—No—
animateboolean—No—
areabooleantrueNo

Gradient area joining the column totals. Default true.

aria-labelledbystring—No

Id of an element that names the chart; it wins over title for the name.

calloutreadonly TooltipSegment[]—No

A pill pinned above the last column, e.g. $400 kept | 12.3% margin.

chartIdstring—No

Prefix for pattern and mask ids. React's useId is only unique within one root, so set this when charts render in several React roots on one page.

childrenReactNode—No—
classNamestring—No—
dataTableboolean | DataTableOptionstrueNo

Hidden data table for screen readers: true, false, or { caption, columns } to set its caption and rename column headers. Default true.

descriptionstring—No

Accessible description, usually the takeaway sentence.

dimInactiveboolean—No—
domainreadonly [number, number]zero to the largest total, rounded to nice ticksNo

Value domain. Default: zero to the largest total, rounded to nice ticks.

emptyReactNode"No data"No

Rendered instead of the plot when data is an empty array. Default "No data".

formatFormatSpec'number'No

Default 'number'.

heightnumber240 unless `aspectRatio` is setNo

Height in px. Default 240 unless aspectRatio is set.

highlightLastbooleantrueNo

Solid, highlighted last column with an emphasized label. Default true.

initialWidthnumber640No

Width used for server rendering and the first client render. Default 640.

keyboardHintstring"Use arrow keys to move between points, Home and End for first and last, Escape to clear.", plus " Press Enter to select." while the active point (or the first, before one is active) can be selected with `onSelect`No

Instructions read with the chart when it takes keyboard focus. Default: "Use arrow keys to move between points, Home and End for first and last, Escape to clear.", plus " Press Enter to select." while the active point (or the first, before one is active) can be selected with onSelect. A custom text is used as is. Set it to translate the text; "" turns it off.

marginPartial<Margin>—No—
onActiveChange(id: Id | null, point: ChartPoint<D> | null) => void—No

Called with the new active id, and its point; point.datum is the row from data.

onSelect(id: Id, point: ChartPoint<D>) => void—No

Called on click, Enter or Space; point.datum is the row from data.

paddingnumber0.45No

Inner band padding, 0–1. Default 0.45.

startBridgeStart—Yes—
stepLabel(step: S) => stringthe signed change plus the noteNo

Text under each column total. Default: the signed change plus the note.

stepsreadonly S[]—Yes—
styleCSSProperties—No—
titlestring—No

Accessible name of the chart; also the default caption of the data table.

tooltipChartTooltip<S | BridgeStart>trueNo

Tooltip on hover and focus: true for the default pill, or a function that renders the content for a point (point.datum is your row). Default true.

widthnumber—No

Fixed width in px; turns off container measuring.

Keyboard and screen readers #

BridgeChart is built on Chart, so it follows the same keyboard model as the other charts: it is a single tab stop, and tabbing in shows the first column with its tooltip and announces it. Arrow keys move to the previous or next column, Home and End jump to the first and last, Enter or Space selects the active column when the chart has onSelect, and Esc clears the active column. Esc is only consumed when a column is active, so an enclosing dialog still closes. The widget’s description ends with a keyboard hint (“Use arrow keys to move between points, Home and End for first and last, Escape to clear.”, plus “Press Enter to select.” with onSelect); keyboardHint replaces it, for example to translate it, and keyboardHint="" turns it off.

Screen readers get the chart title and description, then an announcement for each column the keyboard moves to, in the form “2 of 5, After discount, $1,000, −$260 discount”: its position, label, running total and the change with its note. A visually hidden data table with the columns Column, Change and Total follows the chart; dataTable renames the caption and headers, or turns it off.

The SVG and the HTML overlay are aria-hidden, so a callout says nothing to a screen reader. Put the same facts in the title, the description or the notes, as the job-profit example does with the profit kept. In a very narrow chart BridgeChart shows only some column totals and no notes, and a pinned pill can take three lines; the tooltip and the data table still have everything.

The full model is in the accessibility guide.