Draw charts from one categorical palette, --chart-1…8

The one-hue ramp told lines apart by lightness alone. --chart-1 is now
--primary and slots 2-8 are distinct hues (orange, violet, green, orchid,
ochre, teal, magenta) that clear 3:1 on --card and stay apart under
protanopia and deuteranopia; red and sage are left out as the status
colours. A chart takes the slots in order instead of spreading a ramp,
and a dashboard's own palette continues after its primary and listed
colours with slots 2-8 rather than tints of its scheme. Line charts stay
at five series. Tokens mirror index's, as design-check requires.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013GAeg4Jo6xjZzjwy9QDWMQ
This commit is contained in:
2026-10-06 07:05:09 +02:00
co-authored by Claude Opus 5.5
parent d7ca933478
commit 4f4de1fd9d
12 changed files with 151 additions and 149 deletions
@@ -2,7 +2,7 @@
* The dashboard palette, checked.
*
* ponytail: a script rather than a suite, like `color.check.ts` beside it —
* the frontend's only runner is Playwright and picking a ramp slot does not
* the frontend's only runner is Playwright and picking a palette slot does not
* need a browser:
*
* cd frontend && bun run src/components/Dashboard/palette.check.ts
@@ -15,77 +15,46 @@
* default safe to move afterwards.
*
* The one that is free to move is the **default** itself — where a chart that
* named no palette lands. It started as the ramp in order, which gave three
* lines the three adjacent steps 1, 2 and 3; it is now spread. That is a
* design decision, pinned here so it changes on purpose rather than by
* accident, and a five-line chart is unchanged either way.
* named no palette lands. It started as a one-hue ramp in order, was spread
* across that ramp, and is now the categorical `--chart-1…8` in order. That is
* a design decision, pinned here so it changes on purpose rather than by
* accident.
*/
import assert from "node:assert/strict"
import {
CHART_SLOTS,
MAX_SERIES,
NO_PALETTE,
slotsFor,
} from "@/components/Common/UplotChart"
// --- the default: spread, not the first n steps ---------------------------
// --- the default: the shared palette, in order ----------------------------
const SPREAD: Record<number, string[]> = {
1: ["1"],
2: ["1", "5"],
3: ["1", "3", "5"],
4: ["1", "2", "4", "5"],
5: ["1", "2", "3", "4", "5"],
}
for (const [lines, want] of Object.entries(SPREAD)) {
assert.deepEqual(
CHART_SLOTS,
["1", "2", "3", "4", "5", "6", "7", "8"],
"eight slots, named as --chart-1…8 is",
)
for (const stored of [undefined, NO_PALETTE]) {
assert.deepEqual(
slotsFor(Number(lines)),
want,
`${lines} lines with no palette named`,
slotsFor(stored),
CHART_SLOTS,
"naming no palette, however it is stored, takes the slots in order",
)
}
// Five lines take the whole ramp in order, which is what they always took.
assert.deepEqual(
slotsFor(CHART_SLOTS.length),
[...CHART_SLOTS],
"a five-line chart is drawn exactly as it was before palettes existed",
assert.ok(
MAX_SERIES <= CHART_SLOTS.length,
"a full chart never repeats a colour",
)
// A chart is never left without a colour, whatever it is handed.
for (const lines of [0, -3, 1.5, 9, Number.NaN]) {
const slots = slotsFor(lines)
assert.ok(slots?.length > 0, `${lines} lines still gets a colour`)
}
// --- inertness: a named palette is drawn as written -----------------------
// A dashboard names colours now (`ui/core/theme.ts`), and a chart draws them
// as they were written: not re-spread, not widened, not reordered.
// as they were written: not re-spread, not widened, not reordered. A chart
// with more lines than it names cycles through them.
const NAMED = ["#2a9d8f", "#e9c46a"]
assert.deepEqual(
slotsFor(2, NAMED),
NAMED,
"a named palette is never re-spread",
)
assert.deepEqual(
slotsFor(5, NAMED),
NAMED,
"and it is not widened to fit more lines either — the chart cycles",
)
// Naming none means the same thing however it is stored: the chart spreads.
for (const stored of [undefined, NO_PALETTE]) {
for (let lines = 1; lines <= CHART_SLOTS.length; lines++) {
assert.deepEqual(
slotsFor(lines, stored),
SPREAD[lines],
`${lines} lines still spread`,
)
}
}
assert.deepEqual(slotsFor(NAMED), NAMED, "a named palette is drawn as written")
console.log("palette: ok")