Charts A
Revenue
Rounded bars over a track, a value axis and a total that counts up.
Example
Revenue chart
Rounded bars over a track, with a period toggle, a title that counts up to the value and an outline on hover.
<article class="u-chart-card">
<div class="u-chart-panel">
<div data-u="earnings" data-u-props='{
"label": "Revenue in the period",
"ticks": [0, 2500, 5000, 7500, 10000],
"periods": [
{
"label": "Weekly",
"total": 66300,
"delta": 11.3,
"labels": ["W1", "W2", "W3", "W4", "W5", "W6", "W7", "W8", "W9", "W10", "W11", "W12"],
"values": [3400, 4700, 6900, 5200, 2800, 3900, 5600, 7400, 4300, 6100, 8800, 7200]
},
{
"label": "Monthly",
"total": 86200,
"delta": 8.7,
"labels": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
"values": [5100, 4400, 6600, 7000, 5800, 7300, 7900, 6700, 8200, 8600, 9100, 9500]
},
{
"label": "Yearly",
"total": 59000,
"delta": 19.5,
"labels": ["'15", "'16", "'17", "'18", "'19", "'20", "'21", "'22", "'23", "'24", "'25", "'26"],
"values": [1100, 1800, 2400, 3100, 3600, 4500, 4900, 5800, 6600, 7500, 8400, 9300]
}
]
}'></div>
</div>
<h3 class="u-chart-title">Revenue chart</h3>
<p class="u-chart-desc">Rounded bars over a track, with a period toggle, a title that counts up to the value and an outline on hover.</p>
</article>Installation
Just this chart, with the core and the tokens:
curl -fsSL unslop.leallabs.dev/i | sh -s add earningsNo dependency The chart file already brings its own shell.
The full card from the example, as HTML ready to paste:
curl -fsSL unslop.leallabs.dev/i | sh -s add chart-earningsFamily A: shell u-chart-card > u-chart-panel > the data-u, then h3.u-chart-title and p.u-chart-desc.
Props
They go in data-u-props, as JSON. Each item in periods becomes an option in the picker and the chart animates from the old data to the new.
| Prop | Type | Default | What it does |
|---|---|---|---|
label | string | no default | Small label at the top of the card. |
ticks | array | [0, 3000, 5000, 10000] | Axis ticks. The last one is the ceiling. |
periods | array | no default | List of {label, total, delta, labels, values}. All with the same number of bars. |
period | number | 0 | Index of the period that opens selected. |
Accessibility and keyboard
State and roles
| Where | Attribute | What it says |
|---|---|---|
| chart svg | role="img" and aria-label | "Label by period". |
| period toggle | role="radiogroup", role="radio" | Current period in aria-checked. |
| period list | role="listbox", role="option" | Opens with aria-expanded and marks the option in aria-selected. |
Keyboard
| Key | Does |
|---|---|
| Left and right arrows | change the period in the toggle |
| Enter or Space | opens the period list |
| Up and down arrows | moves through the options |
| Esc | closes without changing |
| Tab | closes and moves focus on |
Events and API
No public events. The period change happens inside the card.