Back to the library
Aggregate pivot — in-out
Variant: In-out
A chart view switch from 'By plan' to 'All'. Each plan's rising trend line pivots around its own centre until the two lines join into one falling line. Use it when a group-by toggle changes what the data seems to say, and the reader has to see that both lines come from the same points. This is the reference curve: the strong in-out curve keeps both ends of the 300ms pivot calm, so it reads as one shape turning into another.
charttoggledata-vizstate-changemorph
The source
A complete HTML document. Paste it into an empty .html file and it plays — no stylesheet, script, font, or image to fetch.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Aggregate pivot — in-out</title>
<style>
:root {
/* Neutrals — fixed, never remixed. */
--ivory: #faf9f5;
--paper: #ffffff;
--oat: #e3dacc;
--slate: #141413;
/* Knobs — the remix API. A knob exists iff declared here and used below. */
--hue: 38.8;
--lift: 0;
--chroma: 1;
--round: 1;
--speed: 1;
/* Accents — derived from the knobs with the family's offsets baked in,
so one hue roll moves them together. Defaults reproduce the original hex
(#d97757 / #b85c3e / #788c5d / #b04a3f). */
--clay: oklch(calc(0.6724 + var(--lift)) calc(0.1308 * var(--chroma)) var(--hue));
--clay-d: oklch(calc(0.5797 + var(--lift)) calc(0.127 * var(--chroma)) var(--hue));
--olive: oklch(calc(0.6118 + var(--lift)) calc(0.0713 * var(--chroma)) calc(var(--hue) + 88.3));
--rust: oklch(calc(0.5408 + var(--lift)) calc(0.1357 * var(--chroma)) calc(var(--hue) - 10.3));
/* Clock — every duration in the document runs off --t. */
--cycle: 5s;
--t: calc(var(--cycle) / var(--speed));
--ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
--_muted: color-mix(in oklch, var(--slate) 58%, var(--ivory));
--_ink: color-mix(in oklch, var(--slate) 42%, var(--oat));
--_track: color-mix(in oklch, var(--oat) 60%, var(--ivory));
--_shadow: color-mix(in oklch, var(--slate) 14%, transparent);
--_up-bg: color-mix(in oklch, var(--olive) 14%, transparent);
--_down-bg: color-mix(in oklch, var(--rust) 12%, transparent);
}
* { box-sizing: border-box; }
body {
margin: 0;
min-height: 100vh;
display: grid;
place-items: center;
background: var(--ivory);
color: var(--slate);
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
.card {
width: min(360px, 92vw);
background: var(--paper);
border: 1px solid var(--oat);
border-radius: calc(14px * var(--round));
padding: clamp(12px, 3.5vw, 18px);
display: grid;
gap: clamp(6px, 2vw, 10px);
}
header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
}
.title { display: grid; gap: 1px; line-height: 1.2; }
.title b { font-size: clamp(13px, 3.6vw, 15px); font-weight: 600; }
.title small { font-size: clamp(11px, 3vw, 12px); color: var(--_muted); }
.toggle {
position: relative;
display: grid;
grid-template-columns: 1fr 1fr;
padding: 3px;
border-radius: 999px;
background: var(--_track);
font-size: clamp(11px, 3vw, 12px);
font-weight: 500;
}
.toggle span { position: relative; padding: 5px 10px; text-align: center; white-space: nowrap; }
.thumb {
position: absolute;
top: 3px;
bottom: 3px;
left: 3px;
width: calc(50% - 3px);
border-radius: 999px;
background: var(--paper);
box-shadow: 0 1px 2px var(--_shadow), 0 0 0 1px var(--oat);
/* Thumb leads the chart by 50ms so the cause reads before the effect. */
animation: slide var(--t) var(--ease-in-out) infinite;
}
.thumb.alt { left: auto; right: 3px; opacity: 0; animation: none; }
svg { display: block; width: 100%; height: auto; max-height: 52vh; overflow: visible; }
.axis { fill: none; stroke: var(--oat); stroke-width: 1.5; stroke-linecap: round; }
.dots { fill: currentColor; }
.dots.a { color: var(--clay); }
.dots.b { color: var(--olive); }
.dots.mute { color: var(--_ink); opacity: 0; animation: on var(--t) var(--ease-in-out) infinite; }
.seg { transform-box: view-box; transform-origin: 0 0; }
/* Each half pivots on its own group's centroid; both centroids sit on the
combined trend, so at 1.53x the two halves meet end to end at x=120. */
.sa {
transform: translate(70px, 38px) rotate(-26.57deg) scaleX(1);
animation: pivot-a var(--t) var(--ease-in-out) infinite;
}
.sb {
transform: translate(170px, 84px) rotate(-26.57deg) scaleX(1);
animation: pivot-b var(--t) var(--ease-in-out) infinite;
}
.ln { fill: none; stroke-width: 2.5; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.ln.a { stroke: var(--clay); }
.ln.b { stroke: var(--olive); }
.ln.agg { stroke: var(--rust); opacity: 0; animation: on var(--t) var(--ease-in-out) infinite; }
.ln.flat { stroke: var(--rust); opacity: 0; }
footer {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
font-size: clamp(11px, 3vw, 12px);
}
.legend { display: flex; gap: 10px; color: var(--_muted); animation: dim var(--t) var(--ease-in-out) infinite; }
.legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend i { width: 8px; height: 8px; border-radius: 50%; }
.legend .a i { background: var(--clay); }
.legend .b i { background: var(--olive); }
.badges { display: grid; justify-items: end; }
.badge { grid-area: 1 / 1; padding: 3px 8px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.badge.up { color: var(--olive); background: var(--_up-bg); animation: off var(--t) var(--ease-in-out) infinite; }
.badge.down { color: var(--rust); background: var(--_down-bg); opacity: 0; animation: on var(--t) var(--ease-in-out) infinite; }
/* Forward pivot 30→36% = 300ms; return 80→85% = 250ms, so leaving runs faster. */
@keyframes pivot-a {
0%, 30% { transform: translate(70px, 38px) rotate(-26.57deg) scaleX(1); }
36%, 80% { transform: translate(70px, 38px) rotate(24.7deg) scaleX(1.53); }
85%, 100% { transform: translate(70px, 38px) rotate(-26.57deg) scaleX(1); }
}
@keyframes pivot-b {
0%, 30% { transform: translate(170px, 84px) rotate(-26.57deg) scaleX(1); }
36%, 80% { transform: translate(170px, 84px) rotate(24.7deg) scaleX(1.53); }
85%, 100% { transform: translate(170px, 84px) rotate(-26.57deg) scaleX(1); }
}
@keyframes slide {
0%, 29% { transform: translateX(0); }
34%, 79% { transform: translateX(100%); }
83%, 100% { transform: translateX(0); }
}
@keyframes on {
0%, 30% { opacity: 0; }
36%, 80% { opacity: 1; }
85%, 100% { opacity: 0; }
}
@keyframes off {
0%, 30% { opacity: 1; }
36%, 80% { opacity: 0; }
85%, 100% { opacity: 1; }
}
@keyframes dim {
0%, 30% { opacity: 1; }
36%, 80% { opacity: 0.4; }
85%, 100% { opacity: 1; }
}
@media (max-width: 380px) {
.toggle span { padding: 4px 8px; }
.legend { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
.sa, .sb { animation: off calc(var(--t) * 2) var(--ease-in-out) infinite; }
.ln.agg { animation: none; }
.ln.flat { animation: on calc(var(--t) * 2) var(--ease-in-out) infinite; }
.thumb { animation: off calc(var(--t) * 2) var(--ease-in-out) infinite; }
.thumb.alt { animation: on calc(var(--t) * 2) var(--ease-in-out) infinite; }
.dots.mute, .badge.down { animation: on calc(var(--t) * 2) var(--ease-in-out) infinite; }
.badge.up { animation: off calc(var(--t) * 2) var(--ease-in-out) infinite; }
.legend { animation: dim calc(var(--t) * 2) var(--ease-in-out) infinite; }
}
</style>
</head>
<body>
<div class="card">
<header>
<div class="title"><b>Conversion</b><small>by price tier</small></div>
<div class="toggle" aria-hidden="true">
<i class="thumb"></i><i class="thumb alt"></i>
<span>By plan</span><span>All</span>
</div>
</header>
<svg viewBox="0 0 240 120" role="img" aria-label="Conversion rises with price inside each plan, but falls when the plans are combined">
<defs>
<g id="pa">
<circle cx="40" cy="55" r="3.5" /><circle cx="52" cy="44" r="3.5" /><circle cx="62" cy="45" r="3.5" />
<circle cx="74" cy="34" r="3.5" /><circle cx="84" cy="34" r="3.5" /><circle cx="96" cy="24" r="3.5" />
</g>
<g id="pb">
<circle cx="140" cy="97" r="3.5" /><circle cx="152" cy="96" r="3.5" /><circle cx="162" cy="85" r="3.5" />
<circle cx="174" cy="85" r="3.5" /><circle cx="184" cy="75" r="3.5" /><circle cx="196" cy="73" r="3.5" />
</g>
</defs>
<path class="axis" d="M8 4V114H234" />
<use href="#pa" class="dots a" />
<use href="#pb" class="dots b" />
<use href="#pa" class="dots mute" />
<use href="#pb" class="dots mute" />
<line class="ln flat" x1="20" y1="15" x2="220" y2="107" />
<g class="seg sa">
<line class="ln a" x1="-36" y1="0" x2="36" y2="0" />
<line class="ln agg" x1="-36" y1="0" x2="36" y2="0" />
</g>
<g class="seg sb">
<line class="ln b" x1="-36" y1="0" x2="36" y2="0" />
<line class="ln agg" x1="-36" y1="0" x2="36" y2="0" />
</g>
</svg>
<footer>
<div class="legend"><span class="a"><i></i>Starter</span><span class="b"><i></i>Pro</span></div>
<div class="badges"><span class="badge up">Each plan ↑</span><span class="badge down">Overall ↓</span></div>
</footer>
</div>
</body>
</html>
The variant family
Same idea, one axis moved. Compare them side by side before you commit.