Charts A
Area
Stacked series with gradients and a hover that follows the month.
Example
Area chart
Stacked series with gradient fills. Hover a month and the title, legend and tiles follow it.
<article class="u-chart-card">
<div class="u-chart-panel">
<div data-u="area" data-u-props='{
"label": "Visits",
"series": [{"label": "Search"}, {"label": "Referral"}, {"label": "Ads"}],
"periods": [
{
"label": "This year",
"delta": 7.4,
"labels": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
"data": [
[2160, 2260, 2450, 2410, 2600, 2700, 2750, 2800, 2900, 2990, 3140, 3240],
[1200, 1250, 1350, 1300, 1390, 1440, 1440, 1490, 1540, 1640, 1780, 1830],
[650, 690, 740, 780, 830, 880, 920, 970, 1010, 1110, 1240, 1380]
]
},
{
"label": "Last year",
"delta": 4.9,
"labels": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
"data": [
[1750, 1800, 1950, 1950, 2100, 2150, 2200, 2250, 2300, 2400, 2500, 2600],
[1050, 1100, 1150, 1100, 1200, 1250, 1250, 1300, 1300, 1400, 1550, 1550],
[450, 500, 550, 550, 600, 650, 650, 700, 750, 800, 900, 1000]
]
},
{
"label": "Last 12 months",
"delta": 6.2,
"labels": ["Dec", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov"],
"data": [
[3350, 2250, 2350, 2550, 2500, 2700, 2800, 2850, 2900, 3000, 3100, 3250],
[1900, 1250, 1300, 1400, 1350, 1450, 1500, 1500, 1550, 1600, 1700, 1850],
[1500, 700, 750, 800, 850, 900, 950, 1000, 1050, 1100, 1200, 1350]
]
}
]
}'></div>
</div>
<h3 class="u-chart-title">Area chart</h3>
<p class="u-chart-desc">Stacked series with gradient fills. Hover a month and the title, legend and tiles follow it.</p>
</article>Installation
Just this chart, with the core and the tokens:
curl -fsSL unslop.leallabs.dev/i | sh -s add areaNo 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-areaFamily 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. |
series | array | no default | List of {label}, one per series. |
periods | array | no default | List of {label, delta, labels, data}. data has one array per series, one value per label. |
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 month". |
| 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.