DataPremium

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.

JSCSSAnimation

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

Price range above the slider — filters of a second-hand musical instruments site — Animated Bar Chart example 1

① Price range above the slider — filters of a second-hand musical instruments site

WhenOn the results page, the “Price” button opens a panel: twenty small bars, one per €50 bucket, rise above a two-handle slider. Buckets outside the range turn grey and the “193 listings” counter follows.
WhyNobody reads a value here: you look for where most listings sit before placing the handles. Bars with no figure and no label, aligned to the pixel with the slider track, are exactly what is needed.
SettingsTwenty li, --brg-height: 74px, --brg-gap: 3px, --brg-bar-width: 99px, --brg-max-width: none, --brg-min-height: 0, transparent background, --brg-color: #c2703a. The panel is a hidden block; the grey outside the range comes from an attribute the page sets on the li. In the scene, a click anywhere opens the panel and the next one narrows the range.
Visitors month by month as a backdrop to the headline — season review of a restored windmill — Animated Bar Chart example 2

② Visitors month by month as a backdrop to the headline — season review of a restored windmill

WhenAt the top of the “2026 season” page, twelve wide translucent ochre bars fill the bottom of the screen, January to December. The headline “11,010 visitors watched the sails turn” sits in front; month initials run along the bottom.
WhyThe shape of the season is understood at a glance: nothing in winter, the summer hump, the August peak. Because the chart prints nothing itself, it stays a backdrop and does not compete with the headline.
SettingsRoot placed behind the text with position: absolute, --brg-height: 236px, --brg-gap: 8px, --brg-bar-width: 999px (bars fill their column), --brg-color: linear-gradient(to top, rgba(226,160,74,.5), rgba(226,160,74,.13)), transparent background. Month initials printed by the page on a twelve-column grid with the same gap. In the scene, the rise is replayed on the first pointer movement.
Your wins by number of tries — end screen of a daily word game — Animated Bar Chart example 3

③ Your wins by number of tries — end screen of a daily word game

WhenToday's word has just been found on the fourth try. The end card appears beside the grid: games played, current streak, then six bars, one per number of tries. Today's bar, the fourth, is green.
WhyPlayers want to place themselves: how many guesses do I usually need? Six heights answer without a table, and the green bar ties the game just finished to all the earlier ones.
SettingsSix li, --brg-height: 84px, --brg-bar-width: 28px, --brg-gap: 8px, --brg-color: #46506a; today's bar is recoloured through a class added to its li. The figures 1 to 6 and the totals are printed by the page, under the bars. In the scene, the card appears on the first pointer movement.

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). With data-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-color and 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.

Chrome 84+✓ Full (measured)
Firefox 63+✓ Full (measured)
Safari 14.1+✓ WebKit engine measured, not real Safari
Edge 84+✓ Full (Chromium engine)
Safari iOS 14.5+✓ Not checked on a device
Chrome Android 84+✓ Full (Chromium engine)

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):

index.html — structure
<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 / propertyDefaultEffect
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

The engine is the same: same attributes, same height maths, same trigger. Bar Chart Animated is a self-sufficient chart: a label under each bar, an optional value on top, five gradients, a bouncy entrance. This one keeps only the bars, in a single colour, with no bounce, and adds the gap setting. Pick it when your page already provides the markers or when the bars act as decoration; there is no point buying both for the same job.
Not through a setting: the stylesheet keeps them for screen readers. The simple route is the one in the examples: print your markers in the page, on a grid that uses the same number of columns and the --brg-gap spacing. If you want a label under each bar without building anything, the twin effect does it out of the box.
Each bar waits 0.1 s longer than the one before, so the thirtieth starts 2.9 s after the first. That step is written in the .fx-0235-root.brg-on .brg-bar rule (calc(var(--brg-i, 0) * .1s)); replace .1s with .03s for a tighter wave.