Many at once
Solid 2The studio's year, as a chart
Each of the 288 glazes a point: switch the measure and every point moves in one wave; pick a family and the rest shrink away.
The numbers
| Glaze | Family | Pieces sold |
|---|---|---|
| Celadon 1 | Celadon | 64 |
| Celadon 2 | Celadon | 76 |
| Celadon 3 | Celadon | 51 |
| Celadon 4 | Celadon | 68 |
| Celadon 5 | Celadon | 40 |
| Celadon 6 | Celadon | 75 |
| Celadon 7 | Celadon | 84 |
| Celadon 8 | Celadon | 49 |
| Celadon 9 | Celadon | 47 |
| Celadon 10 | Celadon | 81 |
| Celadon 11 | Celadon | 39 |
| Celadon 12 | Celadon | 53 |
| Celadon 13 | Celadon | 51 |
| Celadon 14 | Celadon | 39 |
| Celadon 15 | Celadon | 75 |
| Celadon 16 | Celadon | 76 |
| Celadon 17 | Celadon | 34 |
| Celadon 18 | Celadon | 48 |
| Celadon 19 | Celadon | 69 |
| Celadon 20 | Celadon | 81 |
| Celadon 21 | Celadon | 57 |
| Celadon 22 | Celadon | 44 |
| Celadon 23 | Celadon | 45 |
| Celadon 24 | Celadon | 34 |
| Celadon 25 | Celadon | 56 |
| Celadon 26 | Celadon | 64 |
| Celadon 27 | Celadon | 38 |
| Celadon 28 | Celadon | 78 |
| Celadon 29 | Celadon | 65 |
| Celadon 30 | Celadon | 40 |
| Celadon 31 | Celadon | 73 |
| Celadon 32 | Celadon | 39 |
| Celadon 33 | Celadon | 39 |
| Celadon 34 | Celadon | 54 |
| Celadon 35 | Celadon | 54 |
| Celadon 36 | Celadon | 78 |
| Celadon 37 | Celadon | 65 |
| Celadon 38 | Celadon | 45 |
| Celadon 39 | Celadon | 49 |
| Celadon 40 | Celadon | 71 |
| Celadon 41 | Celadon | 79 |
| Celadon 42 | Celadon | 55 |
| Celadon 43 | Celadon | 78 |
| Celadon 44 | Celadon | 39 |
| Celadon 45 | Celadon | 34 |
| Celadon 46 | Celadon | 39 |
| Celadon 47 | Celadon | 41 |
| Celadon 48 | Celadon | 78 |
| Tenmoku 1 | Tenmoku | 20 |
| Tenmoku 2 | Tenmoku | 27 |
| Tenmoku 3 | Tenmoku | 46 |
| Tenmoku 4 | Tenmoku | 31 |
| Tenmoku 5 | Tenmoku | 27 |
| Tenmoku 6 | Tenmoku | 65 |
| Tenmoku 7 | Tenmoku | 65 |
| Tenmoku 8 | Tenmoku | 36 |
| Tenmoku 9 | Tenmoku | 26 |
| Tenmoku 10 | Tenmoku | 27 |
| Tenmoku 11 | Tenmoku | 28 |
| Tenmoku 12 | Tenmoku | 45 |
| Tenmoku 13 | Tenmoku | 27 |
| Tenmoku 14 | Tenmoku | 50 |
| Tenmoku 15 | Tenmoku | 28 |
| Tenmoku 16 | Tenmoku | 43 |
| Tenmoku 17 | Tenmoku | 63 |
| Tenmoku 18 | Tenmoku | 54 |
| Tenmoku 19 | Tenmoku | 55 |
| Tenmoku 20 | Tenmoku | 43 |
| Tenmoku 21 | Tenmoku | 65 |
| Tenmoku 22 | Tenmoku | 24 |
| Tenmoku 23 | Tenmoku | 26 |
| Tenmoku 24 | Tenmoku | 30 |
| Tenmoku 25 | Tenmoku | 61 |
| Tenmoku 26 | Tenmoku | 23 |
| Tenmoku 27 | Tenmoku | 44 |
| Tenmoku 28 | Tenmoku | 21 |
| Tenmoku 29 | Tenmoku | 38 |
| Tenmoku 30 | Tenmoku | 23 |
| Tenmoku 31 | Tenmoku | 57 |
| Tenmoku 32 | Tenmoku | 62 |
| Tenmoku 33 | Tenmoku | 32 |
| Tenmoku 34 | Tenmoku | 62 |
| Tenmoku 35 | Tenmoku | 38 |
| Tenmoku 36 | Tenmoku | 27 |
| Tenmoku 37 | Tenmoku | 46 |
| Tenmoku 38 | Tenmoku | 27 |
| Tenmoku 39 | Tenmoku | 42 |
| Tenmoku 40 | Tenmoku | 29 |
| Tenmoku 41 | Tenmoku | 12 |
| Tenmoku 42 | Tenmoku | 58 |
| Tenmoku 43 | Tenmoku | 33 |
| Tenmoku 44 | Tenmoku | 40 |
| Tenmoku 45 | Tenmoku | 52 |
| Tenmoku 46 | Tenmoku | 32 |
| Tenmoku 47 | Tenmoku | 40 |
| Tenmoku 48 | Tenmoku | 37 |
| Shino 1 | Shino | 74 |
| Shino 2 | Shino | 85 |
| Shino 3 | Shino | 60 |
| Shino 4 | Shino | 48 |
| Shino 5 | Shino | 73 |
| Shino 6 | Shino | 48 |
| Shino 7 | Shino | 44 |
| Shino 8 | Shino | 78 |
| Shino 9 | Shino | 74 |
| Shino 10 | Shino | 40 |
| Shino 11 | Shino | 43 |
| Shino 12 | Shino | 89 |
| Shino 13 | Shino | 64 |
| Shino 14 | Shino | 89 |
| Shino 15 | Shino | 76 |
| Shino 16 | Shino | 72 |
| Shino 17 | Shino | 47 |
| Shino 18 | Shino | 79 |
| Shino 19 | Shino | 59 |
| Shino 20 | Shino | 49 |
| Shino 21 | Shino | 68 |
| Shino 22 | Shino | 78 |
| Shino 23 | Shino | 51 |
| Shino 24 | Shino | 47 |
| Shino 25 | Shino | 75 |
| Shino 26 | Shino | 77 |
| Shino 27 | Shino | 74 |
| Shino 28 | Shino | 66 |
| Shino 29 | Shino | 69 |
| Shino 30 | Shino | 38 |
| Shino 31 | Shino | 52 |
| Shino 32 | Shino | 68 |
| Shino 33 | Shino | 42 |
| Shino 34 | Shino | 48 |
| Shino 35 | Shino | 81 |
| Shino 36 | Shino | 61 |
| Shino 37 | Shino | 39 |
| Shino 38 | Shino | 45 |
| Shino 39 | Shino | 76 |
| Shino 40 | Shino | 50 |
| Shino 41 | Shino | 69 |
| Shino 42 | Shino | 57 |
| Shino 43 | Shino | 73 |
| Shino 44 | Shino | 77 |
| Shino 45 | Shino | 60 |
| Shino 46 | Shino | 37 |
| Shino 47 | Shino | 81 |
| Shino 48 | Shino | 58 |
| Ash 1 | Ash | 58 |
| Ash 2 | Ash | 60 |
| Ash 3 | Ash | 42 |
| Ash 4 | Ash | 86 |
| Ash 5 | Ash | 81 |
| Ash 6 | Ash | 70 |
| Ash 7 | Ash | 68 |
| Ash 8 | Ash | 74 |
| Ash 9 | Ash | 77 |
| Ash 10 | Ash | 68 |
| Ash 11 | Ash | 37 |
| Ash 12 | Ash | 70 |
| Ash 13 | Ash | 58 |
| Ash 14 | Ash | 56 |
| Ash 15 | Ash | 35 |
| Ash 16 | Ash | 69 |
| Ash 17 | Ash | 71 |
| Ash 18 | Ash | 44 |
| Ash 19 | Ash | 69 |
| Ash 20 | Ash | 63 |
| Ash 21 | Ash | 55 |
| Ash 22 | Ash | 62 |
| Ash 23 | Ash | 46 |
| Ash 24 | Ash | 39 |
| Ash 25 | Ash | 77 |
| Ash 26 | Ash | 75 |
| Ash 27 | Ash | 34 |
| Ash 28 | Ash | 33 |
| Ash 29 | Ash | 38 |
| Ash 30 | Ash | 34 |
| Ash 31 | Ash | 43 |
| Ash 32 | Ash | 35 |
| Ash 33 | Ash | 76 |
| Ash 34 | Ash | 41 |
| Ash 35 | Ash | 48 |
| Ash 36 | Ash | 59 |
| Ash 37 | Ash | 33 |
| Ash 38 | Ash | 52 |
| Ash 39 | Ash | 73 |
| Ash 40 | Ash | 33 |
| Ash 41 | Ash | 34 |
| Ash 42 | Ash | 45 |
| Ash 43 | Ash | 25 |
| Ash 44 | Ash | 37 |
| Ash 45 | Ash | 41 |
| Ash 46 | Ash | 39 |
| Ash 47 | Ash | 71 |
| Ash 48 | Ash | 40 |
| Copper red 1 | Copper red | 46 |
| Copper red 2 | Copper red | 32 |
| Copper red 3 | Copper red | 75 |
| Copper red 4 | Copper red | 65 |
| Copper red 5 | Copper red | 60 |
| Copper red 6 | Copper red | 31 |
| Copper red 7 | Copper red | 50 |
| Copper red 8 | Copper red | 45 |
| Copper red 9 | Copper red | 40 |
| Copper red 10 | Copper red | 27 |
| Copper red 11 | Copper red | 59 |
| Copper red 12 | Copper red | 36 |
| Copper red 13 | Copper red | 33 |
| Copper red 14 | Copper red | 65 |
| Copper red 15 | Copper red | 24 |
| Copper red 16 | Copper red | 53 |
| Copper red 17 | Copper red | 55 |
| Copper red 18 | Copper red | 28 |
| Copper red 19 | Copper red | 55 |
| Copper red 20 | Copper red | 53 |
| Copper red 21 | Copper red | 41 |
| Copper red 22 | Copper red | 37 |
| Copper red 23 | Copper red | 31 |
| Copper red 24 | Copper red | 41 |
| Copper red 25 | Copper red | 52 |
| Copper red 26 | Copper red | 40 |
| Copper red 27 | Copper red | 53 |
| Copper red 28 | Copper red | 67 |
| Copper red 29 | Copper red | 35 |
| Copper red 30 | Copper red | 59 |
| Copper red 31 | Copper red | 51 |
| Copper red 32 | Copper red | 67 |
| Copper red 33 | Copper red | 43 |
| Copper red 34 | Copper red | 41 |
| Copper red 35 | Copper red | 35 |
| Copper red 36 | Copper red | 37 |
| Copper red 37 | Copper red | 25 |
| Copper red 38 | Copper red | 55 |
| Copper red 39 | Copper red | 38 |
| Copper red 40 | Copper red | 41 |
| Copper red 41 | Copper red | 40 |
| Copper red 42 | Copper red | 33 |
| Copper red 43 | Copper red | 32 |
| Copper red 44 | Copper red | 55 |
| Copper red 45 | Copper red | 29 |
| Copper red 46 | Copper red | 53 |
| Copper red 47 | Copper red | 27 |
| Copper red 48 | Copper red | 64 |
| Cobalt 1 | Cobalt | 78 |
| Cobalt 2 | Cobalt | 63 |
| Cobalt 3 | Cobalt | 74 |
| Cobalt 4 | Cobalt | 32 |
| Cobalt 5 | Cobalt | 32 |
| Cobalt 6 | Cobalt | 58 |
| Cobalt 7 | Cobalt | 66 |
| Cobalt 8 | Cobalt | 30 |
| Cobalt 9 | Cobalt | 63 |
| Cobalt 10 | Cobalt | 51 |
| Cobalt 11 | Cobalt | 40 |
| Cobalt 12 | Cobalt | 64 |
| Cobalt 13 | Cobalt | 30 |
| Cobalt 14 | Cobalt | 51 |
| Cobalt 15 | Cobalt | 67 |
| Cobalt 16 | Cobalt | 53 |
| Cobalt 17 | Cobalt | 29 |
| Cobalt 18 | Cobalt | 58 |
| Cobalt 19 | Cobalt | 39 |
| Cobalt 20 | Cobalt | 63 |
| Cobalt 21 | Cobalt | 36 |
| Cobalt 22 | Cobalt | 68 |
| Cobalt 23 | Cobalt | 28 |
| Cobalt 24 | Cobalt | 27 |
| Cobalt 25 | Cobalt | 46 |
| Cobalt 26 | Cobalt | 53 |
| Cobalt 27 | Cobalt | 51 |
| Cobalt 28 | Cobalt | 58 |
| Cobalt 29 | Cobalt | 31 |
| Cobalt 30 | Cobalt | 44 |
| Cobalt 31 | Cobalt | 43 |
| Cobalt 32 | Cobalt | 52 |
| Cobalt 33 | Cobalt | 71 |
| Cobalt 34 | Cobalt | 71 |
| Cobalt 35 | Cobalt | 60 |
| Cobalt 36 | Cobalt | 51 |
| Cobalt 37 | Cobalt | 21 |
| Cobalt 38 | Cobalt | 69 |
| Cobalt 39 | Cobalt | 39 |
| Cobalt 40 | Cobalt | 64 |
| Cobalt 41 | Cobalt | 55 |
| Cobalt 42 | Cobalt | 43 |
| Cobalt 43 | Cobalt | 63 |
| Cobalt 44 | Cobalt | 33 |
| Cobalt 45 | Cobalt | 58 |
| Cobalt 46 | Cobalt | 33 |
| Cobalt 47 | Cobalt | 66 |
| Cobalt 48 | Cobalt | 28 |
Reduced motion: The points are at their new heights at once, and the families you didn't pick fade rather than shrink.
Why
A chart is many like things that move together: switch from pieces sold to price and every point heads for a new height. The points are SVG circles, one createBatch keyed by glaze: a new measure is one change of what animate reads, and each point moves from where it is, its stagger() a short wave across the chart.
A circle is a member like any element: the Batch moves it by its transform and scales it about its own centre (transform-box: fill-box). Under an <AnimatePresence>, picking a family shrinks the other points away before their circles go, stagger() counting the ones leaving, and brings them back up from the axis. One set of listeners hears every point's hover, when("hoverStart") with the glaze it's over.
The chart is drawn for the eye; the same numbers are a table under it, for a screen reader or to read them.
In the docs: Many elements at once
The code
import { colourOf, FAMILIES, type FamilyId, familyName, type Glaze } from "@wardic/example-storefront-shared/glazes"
import { type GlazeYear, highest, type MeasureId, MEASURES, YEAR } from "@wardic/example-storefront-shared/year"
import { AnimatePresence, createBatch, stagger } from "@wardic/solid"
import { createEffect, createMemo, createSignal, For, Show } from "solid-js"
/** The plot's edges in the chart's own units: room on the left for the axis's numbers, below for its words. */
const PLOT = { left: 52, right: 620, top: 16, bottom: 312 }
/** Across: the palest glazes on the left, the darkest on the right. */
const xOf = (glaze: Glaze) => PLOT.left + ((92 - glaze.lightness) / 82) * (PLOT.right - PLOT.left)
/** The studio's year, a glaze a point: one Batch of SVG circles, a measure or a family one change for all of them. */
export default function StudioYear() {
const [measure, setMeasure] = createSignal<MeasureId>("sold")
const [family, setFamily] = createSignal<FamilyId | "all">("all")
const [hovered, setHovered] = createSignal<GlazeYear>()
const shown = createMemo(() => YEAR.filter((one) => family() === "all" || one.glaze.family === family()))
const top = createMemo(() => highest(measure()))
const yOf = (one: GlazeYear) => PLOT.bottom - (one[measure()] / top()) * (PLOT.bottom - PLOT.top)
// Keyed by glaze: a new measure moves every point up or down in one change, from where it is;
// a family picked shrinks the rest away, and brings them back from the axis.
const points = createBatch({
each: shown,
key: (one) => one.glaze.id,
initial: (one) => ({ x: xOf(one.glaze), y: PLOT.bottom, scale: 0, opacity: 0 }),
animate: (one) => ({ x: xOf(one.glaze), y: yOf(one), scale: 1, opacity: 1 }),
transition: { type: "spring", visualDuration: 0.5, bounce: 0.2, delay: stagger(0.002) },
exit: { scale: 0, opacity: 0, transition: { duration: 0.2, delay: stagger(0.002) } },
whileHover: { scale: 2, transition: { duration: 0.15 } },
})
createEffect(points.when("hoverStart"), ({ item }) => {
setHovered(item as GlazeYear)
})
createEffect(points.when("hoverEnd"), () => {
setHovered(undefined)
})
const unit = () => MEASURES.find((one) => one.id === measure())!.unit
const said = (one: GlazeYear) => `${unit()}${one[measure()]}`
return (
<figure class="chart">
<div class="chart-tools">
<div class="segmented chart-measures" role="group" aria-label="Measure">
<For each={MEASURES}>
{(one) => (
<button aria-pressed={measure() === one.id ? "true" : "false"} onClick={() => setMeasure(one.id)}>
{one.name}
</button>
)}
</For>
</div>
<div class="chips" role="group" aria-label="Family">
<For each={[{ id: "all", name: "All" } as const, ...FAMILIES]}>
{(one) => (
<button class="chip" aria-pressed={family() === one.id ? "true" : "false"} onClick={() => setFamily(one.id)}>
{one.name}
</button>
)}
</For>
</div>
</div>
<svg class="chart-plot" viewBox="0 0 640 352" aria-hidden="true">
<line class="chart-axis" x1={PLOT.left} y1={PLOT.bottom} x2={PLOT.right} y2={PLOT.bottom} />
<line class="chart-axis" x1={PLOT.left} y1={PLOT.top} x2={PLOT.left} y2={PLOT.bottom} />
<For each={[0, 0.5, 1]}>
{(share) => (
<text class="chart-tick" x={PLOT.left - 8} y={PLOT.bottom - share * (PLOT.bottom - PLOT.top) + 4} text-anchor="end">
{unit()}
{Math.round(share * top())}
</text>
)}
</For>
<text class="chart-tick" x={PLOT.left} y={PLOT.bottom + 26}>
← paler glazes
</text>
<text class="chart-tick" x={PLOT.right} y={PLOT.bottom + 26} text-anchor="end">
darker glazes →
</text>
{/* A leaving point's circle stays until its exit lands. */}
<AnimatePresence>
<For each={shown()}>{(one) => <circle class="chart-point" r="4" fill={colourOf(one.glaze)} {...points.member(one.glaze.id)} />}</For>
</AnimatePresence>
</svg>
<figcaption class="chart-caption">
<Show when={hovered()} fallback={<span class="muted">Point at a glaze to read it.</span>}>
{(one) => (
<>
<span class="glaze-chip" style={{ background: colourOf(one().glaze) }} />
<strong>{one().glaze.name}</strong> · {MEASURES.find((each) => each.id === measure())!.name.toLowerCase()}: {said(one())}
</>
)}
</Show>
</figcaption>
{/* The chart as a table, for a screen reader, or to read the numbers. */}
<details class="chart-numbers">
<summary>The numbers</summary>
<table>
<thead>
<tr>
<th scope="col">Glaze</th>
<th scope="col">Family</th>
<th scope="col">{MEASURES.find((one) => one.id === measure())!.name}</th>
</tr>
</thead>
<tbody>
<For each={shown()}>
{(one) => (
<tr>
<td>{one.glaze.name}</td>
<td>{familyName(one.glaze.family)}</td>
<td>{said(one)}</td>
</tr>
)}
</For>
</tbody>
</table>
</details>
</figure>
)
}