Charts C
Bar list
Ranking in horizontal bars, with the label inside the bar and the value beside it.
Example
Top pages
Bar list with the label inside the bar and the value on the right. Hover a row and the others fade.
<article class="u-chartc-card">
<div class="u-chartc-panel">
<div data-u="barlist" data-u-props='{
"label": "Views",
"periods": [
{
"label": "Today",
"delta": 4.3,
"total": 6940,
"items": [
{"label": "/precos", "value": 1820},
{"label": "/docs", "value": 1310},
{"label": "/blog", "value": 880},
{"label": "/componentes", "value": 640},
{"label": "/changelog", "value": 310}
],
"stats": [
{"label": "Unique visitors", "value": "3, 912"},
{"label": "Avg. time", "value": "2m 48s"},
{"label": "Bounce rate", "value": "38.2%"}
]
},
{
"label": "7 days",
"delta": 12.8,
"total": 48210,
"items": [
{"label": "/precos", "value": 12480},
{"label": "/docs", "value": 9320},
{"label": "/blog", "value": 6150},
{"label": "/componentes", "value": 4870},
{"label": "/changelog", "value": 2140}
],
"stats": [
{"label": "Unique visitors", "value": "21, 640"},
{"label": "Avg. time", "value": "3m 05s"},
{"label": "Bounce rate", "value": "36.9%"}
]
},
{
"label": "30 days",
"delta": 9.1,
"total": 198400,
"items": [
{"label": "/precos", "value": 51200},
{"label": "/docs", "value": 38400},
{"label": "/blog", "value": 24900},
{"label": "/componentes", "value": 19700},
{"label": "/changelog", "value": 9300}
],
"stats": [
{"label": "Unique visitors", "value": "84, 370"},
{"label": "Avg. time", "value": "3m 12s"},
{"label": "Bounce rate", "value": "35.4%"}
]
}
]
}'></div>
</div>
<h3 class="u-chartc-title">Top pages</h3>
<p class="u-chartc-desc">Bar list with the label inside the bar and the value on the right. Hover a row and the others fade.</p>
</article>Installation
Just this chart, with the core and the tokens:
curl -fsSL unslop.leallabs.dev/i | sh -s add barlistDependency Pulls in a-chartc (shell for C charts). The installer downloads it and puts it in the right order.
The full card from the example, as HTML ready to paste:
curl -fsSL unslop.leallabs.dev/i | sh -s add chart-barlistFamily C: shell u-chartc-card > u-chartc-panel > the data-u, then h3.u-chartc-title and p.u-chartc-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. |
periods | array | no default | List of {label, delta, total, items: [{label, value}], stats: [{label, value}]}. stats become tiles, with the value already as text. |
period | number | 0 | Index of the period that opens selected. |
Accessibility and keyboard
State and roles
| Where | Attribute | What it says |
|---|---|---|
| list | role="list", role="listitem" | Each bar is an item with an aria-label of label and value. |
| period list | role="listbox", role="option" | Opens with aria-expanded and marks the option in aria-selected. |
Keyboard
| Key | Does |
|---|---|
| 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.