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
| Age | Men | Women |
|---|---|---|
| 65+ | 2.1% | 2.8% |
| 55–64 | 4.3% | 4.9% |
| 45–54 | 7.8% | 7.1% |
| 35–44 | 11.6% | 10.2% |
| 25–34 | 15.9% | 13.4% |
| 18–24 | 9.7% | 10.2% |
datais a list of rows. Each row has alabel, aleftvalue, and arightvalue. 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.
colorssets the two colors, as token names or any CSS colors (defaultchart-1andchart-2).formatsets the text of a value.- Set the width of the middle column with the
--bless-pyramid-labelCSS variable (default4.5rem). - For screen readers, the chart is a table.
labelnames the table. Name the two sides and the rows withlabelsor a label pack:left,right, androw.
Usage
ts
import { BlessPyramid } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
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 + "%"` |
label | string | "Chart" | names the chart and its table for screen readers |
labels | Partial<{ left: string; right: string; row: string; }> | — |