Toggle a channel off and the other layers close the gap.
A smooth stacked area chart by channel where switching the metric restacks the layers and turning a channel off redraws the rest.
The trick
Layers are built from cumulative sums with a midpoint cubic curve, and each path replays a rise keyframe on redraw.
Every layer starts 70ms after the previous one, so the stack builds from the bottom.
Colors are color-mix steps of the ink color against the background, and at least one channel always stays on.
function smooth(p){let d='M'+p[0][0]+' '+p[0][1];
for(let i=1;i<p.length;i++){const mx=(p[i-1][0]+p[i][0])/2;
d+=' C'+mx+' '+p[i-1][1]+' '+mx+' '+p[i][1]+' '+p[i][0]+' '+p[i][1]}return d}
.lay{transform-origin:0 100%;animation:rise var(--dur) var(--fx-ease) both}
@keyframes rise{from{opacity:0;transform:scaleY(.2)}to{opacity:1;transform:none}}
Where I'd use it
Marketing and channel analytics dashboards
Rebuilding the whole SVG on each toggle is cheaper than diffing paths at this size, and it replays the entrance for free.
The prompt for this one is free: uimotion.app.

Top comments (0)