Dashboard-level chart palette

A dashboard names the data colours its charts draw with: an ordered, distinct
subset of the `--chart-1…5` ramp, stored on the settings channel that already
carries `theme` and `locked`. No backend or client change — `SettingDef.value`
is free-form and a name this build does not wire up is left alone rather than
refused.

Naming none is the whole ramp, which resolves to the identical token per
series as the `--chart-${(index % 5) + 1}` charts drew with before, so every
existing dashboard is unaffected. `palette.check.ts` asserts that equivalence
rather than trusting it.

Distinct slots, not free assignment with repeats: only slot 1 against slot 5
clears 3:1 within the ramp, so two traces on one slot could not be told apart.
Status colour is deliberately outside the palette — a fault is `--destructive`
because of what it means, not because of where it sits.

The provider is mounted by the editor as well as the view, so picking a
palette repaints the charts beside the panel instead of describing them.
This commit is contained in:
2026-08-23 08:45:31 +02:00
parent c378a1b763
commit 6272876f8f
7 changed files with 260 additions and 36 deletions
@@ -11,6 +11,7 @@ import {
import { MAX_SERIES, UplotChart } from "@/components/Common/UplotChart"
import { useLiveValue } from "@/components/Flow/liveStore"
import { messageHistoryQueryOptions, usePublishMessage } from "./queries"
import { usePalette } from "./settings"
import { type Series, useHeaderSlot, type WidgetProps } from "./widgets"
// The five-series ceiling is the chart host's, and the panel reads it here.
@@ -120,6 +121,9 @@ function LiveChart({ widget }: WidgetProps) {
) || DEFAULT_POINTS,
)
// The dashboard's own data colours; outside one this is the whole ramp.
const palette = usePalette()
const histories = useQueries({
queries: names.map((name) => messageHistoryQueryOptions(name)),
})
@@ -182,6 +186,7 @@ function LiveChart({ widget }: WidgetProps) {
<UplotChart
labels={labels}
plots={plots}
palette={palette}
{...presentation(widget.config as Record<string, unknown>)}
/>
)
@@ -214,6 +219,7 @@ function QueryChart({ widget, dashboard }: WidgetProps) {
// about less often.
const refreshS = refreshFor(range, cfg.refresh_s)
const palette = usePalette()
const publish = usePublishMessage()
const live = useLiveValue(message || undefined)
const [answer, setAnswer] = useState<SeriesPayload | null>(null)
@@ -285,6 +291,7 @@ function QueryChart({ widget, dashboard }: WidgetProps) {
(line.points ?? []).map(([ts, value]) => ({ ts, value })),
)}
empty="Waiting for an answer."
palette={palette}
{...presentation(cfg)}
/>
)