Spread a chart's default colours across the ramp
A chart that named no palette took the ramp in order, so three lines drew slots 1, 2 and 3 — adjacent steps of a ramp that carries identity by lightness alone, which at a 2px stroke read as close to one picture. Each count now takes the slots furthest apart that the ramp allows: 1 -> 1, 2 -> 1/5, 3 -> 1/3/5, 4 -> 1/2/4/5. Five lines are unchanged. Moving a default is only safe because the mechanism around it is inert: a palette a dashboard wrote down is still drawn exactly as written, so no stored document means anything different than it did. `palette.check.ts` now pins the spread table and says which of the two properties is permanent. An unnamed palette is empty rather than the whole ramp, so the settings panel shows nothing picked when a dashboard is on automatic — and deselecting the last colour is now the way back to it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016ZeGnqVsf5VHQqvz4HdUhN
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { createContext, useContext } from "react"
|
||||
|
||||
import type { DashboardDef_Output, SettingDef } from "@/client"
|
||||
import { DEFAULT_PALETTE, paletteOf } from "@/components/Common/UplotChart"
|
||||
import { NO_PALETTE, paletteOf } from "@/components/Common/UplotChart"
|
||||
import { useLiveValue } from "@/components/Flow/liveStore"
|
||||
|
||||
/**
|
||||
@@ -100,14 +100,18 @@ export function useDashboardLocked(
|
||||
return useSetting(dashboard, "locked") === true
|
||||
}
|
||||
|
||||
const PaletteContext = createContext(DEFAULT_PALETTE)
|
||||
const PaletteContext = createContext(NO_PALETTE)
|
||||
|
||||
/**
|
||||
* The data colours everything drawn under it uses.
|
||||
*
|
||||
* Mounted by the view *and* the editor: an editor showing the default ramp
|
||||
* while the panel beside it showed the dashboard's own palette would be a
|
||||
* preview that lies.
|
||||
* Empty when the dashboard names none, which is not the same as "the ramp":
|
||||
* a chart with no palette spreads itself across the ramp by how many lines it
|
||||
* draws (`slotsFor`), and only a named palette overrides that.
|
||||
*
|
||||
* Mounted by the view *and* the editor: an editor drawing the automatic
|
||||
* spread while the panel beside it showed the dashboard's own palette would
|
||||
* be a preview that lies.
|
||||
*
|
||||
* Data colour only. A fault stays `--destructive` and a condition stays its
|
||||
* `ICON_COLORS` entry, because those name a state rather than tell one series
|
||||
@@ -130,7 +134,7 @@ export function PaletteProvider({
|
||||
)
|
||||
}
|
||||
|
||||
/** The ramp slots the dashboard around this widget draws its data with. */
|
||||
/** The ramp slots the dashboard around this widget named, or none. */
|
||||
export const usePalette = () => useContext(PaletteContext)
|
||||
|
||||
const LockedContext = createContext(false)
|
||||
|
||||
Reference in New Issue
Block a user