Animated Bar Chart
A bar chart stripped down to its bars: one colour, no text on screen, each bar rising from the baseline when the chart becomes visible. The surrounding page supplies the axis and the words.
Updated
This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Data has 28 effects, including 1 free. Explore the category →
3 usage examples



How it works
You write a ul.brg-chart list; every li.brg-item carries a number in data-value and a name in span.brg-label. The script slips a .brg-bar into each row, as tall as the value's share of the maximum (the largest value, or data-max if you set it on the root).
Only the bars show. Each row's name and value are in the page, but folded into a one-pixel box: screen readers get them, eyes do not. No axis, no ticks, no figure sitting on a bar: if visitors must read a value, your layout has to print it nearby.
The start is given once 35% of the list is visible. Bars then stretch from their base in 1 s on an ease curve that never overshoots the final height, each one 0.1 s after its left neighbour. The chart plays once per display: inside a panel hidden with hidden, it starts over every time the panel opens.
All bars share one background, --brg-color: a flat colour or a gradient, applied bar by bar (a short bar shows the whole gradient, not just its foot). The space between bars is set with --brg-gap, which makes twenty buckets fit in 280 px.
Accessibility
- What a screen reader gets: a list named by its
aria-label, then for each row the name followed by the value (“Week 1 60” in Chromium's accessibility tree). Withdata-unit, the unit is read after the number. - What a sighted visitor gets: heights and nothing else. A chart with no figures cannot convey a precise number on its own: print the useful markers in the page (bounds, total, legend), as the three examples do.
- Reduced animations: with that system setting on, the rise is removed and the bars are drawn at full size from the start.
- Keyboard and touch: no bar can be clicked or focused; tabbing finds nothing here.
- Contrast: a pastel bar gets lost on a light background. Aim for at least 3:1 between
--brg-colorand what sits behind.
Browser compatibility
A flex list with gap, a scaleY animation, IntersectionObserver and Intl.NumberFormat. Recorded in Chromium 149, Firefox 151 and WebKit 26.5: final heights of 95, 126, 71, 150 and 111 px for the five stock values, a second copy on the page staying flat while below the fold, the rise replayed after hiding and showing again, 24 bars of 8.8 px in 320 px with --brg-gap: 3px.
Before Chrome 84 and Safari 14.1, gap does not exist in a flex row: the bars touch. If IntersectionObserver is missing, the rise starts on load. Without JavaScript the block stays visually empty, since the bars are created by the script.
The code
HTML structure to paste into your page (the CSS + JS come with your purchase):
<div class="fx-0235-root">
<ul class="brg-chart" aria-label="Sales per week">
<li class="brg-item" data-value="60"><span class="brg-label">Week 1</span></li>
<li class="brg-item" data-value="80"><span class="brg-label">Week 2</span></li>
<li class="brg-item" data-value="45"><span class="brg-label">Week 3</span></li>
<li class="brg-item" data-value="95"><span class="brg-label">Week 4</span></li>
<li class="brg-item" data-value="70"><span class="brg-label">Week 5</span></li>
</ul>
</div>
One-time payment, no subscription — the code is yours forever
Customize
Options passed to the API or data-* attributes:
| Option / property | Default | Effect |
|---|---|---|
data-value on each li (HTML) |
60, 80, 45, 95, 70 | One bar's figure. Zero, a negative number or a forgotten attribute give a flat bar. As many li, as many bars. |
data-max on the root (HTML) |
absent | Top of the scale. Without it the tallest bar reaches the top; with it, several charts become comparable. |
data-unit on the root (HTML) |
absent | Unit appended to the value read by screen readers (“70 kg”). Nothing changes on screen. |
--brg-color (CSS) |
indigo to violet gradient | Background shared by all bars. To single one out, give its li a class and change the background of its .brg-bar. |
--brg-gap (CSS) |
12px | Space between two bars. Reduce it as soon as bars are many or the block is narrow. |
--brg-height, --brg-bar-width, --brg-max-width (CSS) |
150px, 48px, 480px | Height of the tallest bar, maximum width of a bar, maximum width of the row. |
--brg-bg, --brg-min-height (CSS) |
#0a0a0f, 300px | Background and minimum height of the block that centres the chart. Use transparent and 0 to embed it in a component. |
FAQ
--brg-gap spacing. If you want a label under each bar without building anything, the twin effect does it out of the box..fx-0235-root.brg-on .brg-bar rule (calc(var(--brg-i, 0) * .1s)); replace .1s with .03s for a tighter wave.