From 4537393ead20738d09a96b5ced58bbb991b81870 Mon Sep 17 00:00:00 2001 From: os-zhuang Date: Wed, 24 Jun 2026 12:21:02 +0800 Subject: [PATCH] =?UTF-8?q?feat(spec):=20type=20ChartConfig=20colors=20as?= =?UTF-8?q?=20palette=20or=20value=E2=86=92color=20map?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ChartConfigSchema.colors now accepts a positional palette (string[]) OR an explicit value→color map (Record, kanban-style). A value→color map — and a select/lookup dimension's option colors — take precedence over the positional palette per category. Co-Authored-By: Claude Opus 4.8 --- .changeset/chart-config-colors-map.md | 11 +++++++++++ packages/spec/src/ui/chart.zod.ts | 11 +++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 .changeset/chart-config-colors-map.md diff --git a/.changeset/chart-config-colors-map.md b/.changeset/chart-config-colors-map.md new file mode 100644 index 0000000000..966ad7cc8e --- /dev/null +++ b/.changeset/chart-config-colors-map.md @@ -0,0 +1,11 @@ +--- +"@objectstack/spec": patch +--- + +feat(spec): type ChartConfig `colors` as a palette OR a value→color map + +`ChartConfigSchema.colors` now accepts either a positional palette (`string[]`) +or an explicit value→color map (`Record`, kanban-style). A +value→color map — and a select/lookup dimension's option colors — take +precedence over the positional palette per category, so semantic charts +(health, status) paint their own colors instead of the generic palette. diff --git a/packages/spec/src/ui/chart.zod.ts b/packages/spec/src/ui/chart.zod.ts index 09f1281956..0f2a6ccfe0 100644 --- a/packages/spec/src/ui/chart.zod.ts +++ b/packages/spec/src/ui/chart.zod.ts @@ -185,8 +185,15 @@ export const ChartConfigSchema = lazySchema(() => z.object({ /** Series Configuration */ series: z.array(ChartSeriesSchema).optional().describe('Defined series configuration'), - /** Appearance */ - colors: z.array(z.string()).optional().describe('Color palette'), + /** Appearance. Either a positional palette (string[]) applied per category in + * order, or a value→color map ({ value: color }, kanban-style). A value→color + * map — and a select/lookup dimension's option colors — take precedence over + * the positional palette per category, so semantic charts (health, status) + * paint their own colors instead of the generic palette. */ + colors: z.union([ + z.array(z.string()), + z.record(z.string(), z.string()), + ]).optional().describe('Color palette (string[]) or value→color map ({ value: color })'), height: z.number().optional().describe('Fixed height in pixels'), /** Components */