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 */