Many at once

Solid 2

The 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.

Live demo
Point at a glaze to read it.
The numbers
GlazeFamilyPieces sold
Celadon 1Celadon64
Celadon 2Celadon76
Celadon 3Celadon51
Celadon 4Celadon68
Celadon 5Celadon40
Celadon 6Celadon75
Celadon 7Celadon84
Celadon 8Celadon49
Celadon 9Celadon47
Celadon 10Celadon81
Celadon 11Celadon39
Celadon 12Celadon53
Celadon 13Celadon51
Celadon 14Celadon39
Celadon 15Celadon75
Celadon 16Celadon76
Celadon 17Celadon34
Celadon 18Celadon48
Celadon 19Celadon69
Celadon 20Celadon81
Celadon 21Celadon57
Celadon 22Celadon44
Celadon 23Celadon45
Celadon 24Celadon34
Celadon 25Celadon56
Celadon 26Celadon64
Celadon 27Celadon38
Celadon 28Celadon78
Celadon 29Celadon65
Celadon 30Celadon40
Celadon 31Celadon73
Celadon 32Celadon39
Celadon 33Celadon39
Celadon 34Celadon54
Celadon 35Celadon54
Celadon 36Celadon78
Celadon 37Celadon65
Celadon 38Celadon45
Celadon 39Celadon49
Celadon 40Celadon71
Celadon 41Celadon79
Celadon 42Celadon55
Celadon 43Celadon78
Celadon 44Celadon39
Celadon 45Celadon34
Celadon 46Celadon39
Celadon 47Celadon41
Celadon 48Celadon78
Tenmoku 1Tenmoku20
Tenmoku 2Tenmoku27
Tenmoku 3Tenmoku46
Tenmoku 4Tenmoku31
Tenmoku 5Tenmoku27
Tenmoku 6Tenmoku65
Tenmoku 7Tenmoku65
Tenmoku 8Tenmoku36
Tenmoku 9Tenmoku26
Tenmoku 10Tenmoku27
Tenmoku 11Tenmoku28
Tenmoku 12Tenmoku45
Tenmoku 13Tenmoku27
Tenmoku 14Tenmoku50
Tenmoku 15Tenmoku28
Tenmoku 16Tenmoku43
Tenmoku 17Tenmoku63
Tenmoku 18Tenmoku54
Tenmoku 19Tenmoku55
Tenmoku 20Tenmoku43
Tenmoku 21Tenmoku65
Tenmoku 22Tenmoku24
Tenmoku 23Tenmoku26
Tenmoku 24Tenmoku30
Tenmoku 25Tenmoku61
Tenmoku 26Tenmoku23
Tenmoku 27Tenmoku44
Tenmoku 28Tenmoku21
Tenmoku 29Tenmoku38
Tenmoku 30Tenmoku23
Tenmoku 31Tenmoku57
Tenmoku 32Tenmoku62
Tenmoku 33Tenmoku32
Tenmoku 34Tenmoku62
Tenmoku 35Tenmoku38
Tenmoku 36Tenmoku27
Tenmoku 37Tenmoku46
Tenmoku 38Tenmoku27
Tenmoku 39Tenmoku42
Tenmoku 40Tenmoku29
Tenmoku 41Tenmoku12
Tenmoku 42Tenmoku58
Tenmoku 43Tenmoku33
Tenmoku 44Tenmoku40
Tenmoku 45Tenmoku52
Tenmoku 46Tenmoku32
Tenmoku 47Tenmoku40
Tenmoku 48Tenmoku37
Shino 1Shino74
Shino 2Shino85
Shino 3Shino60
Shino 4Shino48
Shino 5Shino73
Shino 6Shino48
Shino 7Shino44
Shino 8Shino78
Shino 9Shino74
Shino 10Shino40
Shino 11Shino43
Shino 12Shino89
Shino 13Shino64
Shino 14Shino89
Shino 15Shino76
Shino 16Shino72
Shino 17Shino47
Shino 18Shino79
Shino 19Shino59
Shino 20Shino49
Shino 21Shino68
Shino 22Shino78
Shino 23Shino51
Shino 24Shino47
Shino 25Shino75
Shino 26Shino77
Shino 27Shino74
Shino 28Shino66
Shino 29Shino69
Shino 30Shino38
Shino 31Shino52
Shino 32Shino68
Shino 33Shino42
Shino 34Shino48
Shino 35Shino81
Shino 36Shino61
Shino 37Shino39
Shino 38Shino45
Shino 39Shino76
Shino 40Shino50
Shino 41Shino69
Shino 42Shino57
Shino 43Shino73
Shino 44Shino77
Shino 45Shino60
Shino 46Shino37
Shino 47Shino81
Shino 48Shino58
Ash 1Ash58
Ash 2Ash60
Ash 3Ash42
Ash 4Ash86
Ash 5Ash81
Ash 6Ash70
Ash 7Ash68
Ash 8Ash74
Ash 9Ash77
Ash 10Ash68
Ash 11Ash37
Ash 12Ash70
Ash 13Ash58
Ash 14Ash56
Ash 15Ash35
Ash 16Ash69
Ash 17Ash71
Ash 18Ash44
Ash 19Ash69
Ash 20Ash63
Ash 21Ash55
Ash 22Ash62
Ash 23Ash46
Ash 24Ash39
Ash 25Ash77
Ash 26Ash75
Ash 27Ash34
Ash 28Ash33
Ash 29Ash38
Ash 30Ash34
Ash 31Ash43
Ash 32Ash35
Ash 33Ash76
Ash 34Ash41
Ash 35Ash48
Ash 36Ash59
Ash 37Ash33
Ash 38Ash52
Ash 39Ash73
Ash 40Ash33
Ash 41Ash34
Ash 42Ash45
Ash 43Ash25
Ash 44Ash37
Ash 45Ash41
Ash 46Ash39
Ash 47Ash71
Ash 48Ash40
Copper red 1Copper red46
Copper red 2Copper red32
Copper red 3Copper red75
Copper red 4Copper red65
Copper red 5Copper red60
Copper red 6Copper red31
Copper red 7Copper red50
Copper red 8Copper red45
Copper red 9Copper red40
Copper red 10Copper red27
Copper red 11Copper red59
Copper red 12Copper red36
Copper red 13Copper red33
Copper red 14Copper red65
Copper red 15Copper red24
Copper red 16Copper red53
Copper red 17Copper red55
Copper red 18Copper red28
Copper red 19Copper red55
Copper red 20Copper red53
Copper red 21Copper red41
Copper red 22Copper red37
Copper red 23Copper red31
Copper red 24Copper red41
Copper red 25Copper red52
Copper red 26Copper red40
Copper red 27Copper red53
Copper red 28Copper red67
Copper red 29Copper red35
Copper red 30Copper red59
Copper red 31Copper red51
Copper red 32Copper red67
Copper red 33Copper red43
Copper red 34Copper red41
Copper red 35Copper red35
Copper red 36Copper red37
Copper red 37Copper red25
Copper red 38Copper red55
Copper red 39Copper red38
Copper red 40Copper red41
Copper red 41Copper red40
Copper red 42Copper red33
Copper red 43Copper red32
Copper red 44Copper red55
Copper red 45Copper red29
Copper red 46Copper red53
Copper red 47Copper red27
Copper red 48Copper red64
Cobalt 1Cobalt78
Cobalt 2Cobalt63
Cobalt 3Cobalt74
Cobalt 4Cobalt32
Cobalt 5Cobalt32
Cobalt 6Cobalt58
Cobalt 7Cobalt66
Cobalt 8Cobalt30
Cobalt 9Cobalt63
Cobalt 10Cobalt51
Cobalt 11Cobalt40
Cobalt 12Cobalt64
Cobalt 13Cobalt30
Cobalt 14Cobalt51
Cobalt 15Cobalt67
Cobalt 16Cobalt53
Cobalt 17Cobalt29
Cobalt 18Cobalt58
Cobalt 19Cobalt39
Cobalt 20Cobalt63
Cobalt 21Cobalt36
Cobalt 22Cobalt68
Cobalt 23Cobalt28
Cobalt 24Cobalt27
Cobalt 25Cobalt46
Cobalt 26Cobalt53
Cobalt 27Cobalt51
Cobalt 28Cobalt58
Cobalt 29Cobalt31
Cobalt 30Cobalt44
Cobalt 31Cobalt43
Cobalt 32Cobalt52
Cobalt 33Cobalt71
Cobalt 34Cobalt71
Cobalt 35Cobalt60
Cobalt 36Cobalt51
Cobalt 37Cobalt21
Cobalt 38Cobalt69
Cobalt 39Cobalt39
Cobalt 40Cobalt64
Cobalt 41Cobalt55
Cobalt 42Cobalt43
Cobalt 43Cobalt63
Cobalt 44Cobalt33
Cobalt 45Cobalt58
Cobalt 46Cobalt33
Cobalt 47Cobalt66
Cobalt 48Cobalt28

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.

The code

examples/studio-year/Demo.tsx
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>
  )
}