Skip to content
Calm motion: animations on this site only fade, with no movement

Pyramid ​

Back-to-back bars for two groups on each row

Compares two groups row by row, with one group to the left and one to the right. For example, it shows listeners by age, with men on one side and women on the other. For two values on one line, use the dumbbell.

Basic
Listeners by age and gender
AgeMenWomen
65+2.1%2.8%
55–644.3%4.9%
45–547.8%7.1%
35–4411.6%10.2%
25–3415.9%13.4%
18–249.7%10.2%
  • data is a list of rows. Each row has a label, a left value, and a right value. The rows show in the order of the list, so put the top row first.
  • The two sides use one scale, so equal values have bars of equal length. Each bar has its value at its outer end.
  • colors sets the two colors, as token names or any CSS colors (default chart-1 and chart-2). format sets the text of a value.
  • Set the width of the middle column with the --bless-pyramid-label CSS variable (default 4.5rem).
  • For screen readers, the chart is a table. label names the table. Name the two sides and the rows with labels or a label pack: left, right, and row.

Usage ​

ts
import { BlessPyramid } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
data*BlessPyramidRow[]—
colors[string, string]["chart-1", "chart-2"]the colors of the left and the right bars
format((v: number) => string)—text for one value, for example `(v) => v + "%"`
labelstring"Chart"names the chart and its table for screen readers
labelsPartial<{ left: string; right: string; row: string; }>—

Released under the MIT License. Character names and artwork belong to their owners.