No.240 · Stats
Split Bar Stats
A breakdown in one bar. Point at a share and it springs wider while its neighbours give way; its colour floods in from the side you came from and the label inverts along the edge. Switch month and year and the shares slide while the numbers roll.
The prompt
The design brief behind this component — reuse it to regenerate, remix, or explain it.
Build a spending breakdown: a big total with a Month/Year radiogroup, one tall bar of shares, and a legend. The bar is a flex row with 3px gaps; each share's flex-grow is its percentage, transitioned with a springy curve (640ms, cubic-bezier(0.34,1.36,0.64,1)), so changing one share moves its neighbours. At rest each segment is a pale tint of its colour (color-mix 20%) with ink text: the name and a large percentage. Hovering a segment (or focusing its legend entry) raises its flex-grow to max(1.25 × share, 24) so even a small share has room for its label. Each segment is printed twice; the second copy has the full colour and inverted ink and is revealed with clip-path: inset(), wiping in from the side the pointer crossed (left or right half on pointerenter) and draining out toward the side it leaves — so the label inverts exactly along the moving edge. When the entry side changes, jump the hidden fill to the new side with transitions off for two frames before lighting it, so the wipe always starts from the right place. The total, percentages and legend amounts are digit reels keyed from the right; switching period re-flows the bar and rolls every number (700ms, 40ms stagger). Legend entries are buttons named with the amount and share, linked both ways to the bar (the bar itself is aria-hidden). Paper and Night.
Notes
- Interaction
- Hover a segment or a legend entry to open it up; switch Month/Year to re-flow the bar.
- Motion
- Width spring 640ms with overshoot; colour wipe 560ms from the entry side; numbers roll 700ms.
- Accessibility
- The legend carries the data as buttons with full accessible names, and focusing one opens its segment; the drawn bar is aria-hidden. The period switch is a radiogroup with arrow keys. Reduced motion jumps widths and numbers and swaps colours instantly.
- Responsive
- Fills its container; the legend auto-fits and becomes two columns under 560px.
- On touch
- Tap a legend entry to open its segment.