Skip to content

Commit c1a754a

Browse files
os-zhuangclaude
andauthored
feat(spec): type ChartConfig colors as palette or value→color map (#2262)
ChartConfigSchema.colors now accepts a positional palette (string[]) OR an explicit value→color map (Record<value,color>, 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 <noreply@anthropic.com>
1 parent f505397 commit c1a754a

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@objectstack/spec": patch
3+
---
4+
5+
feat(spec): type ChartConfig `colors` as a palette OR a value→color map
6+
7+
`ChartConfigSchema.colors` now accepts either a positional palette (`string[]`)
8+
or an explicit value→color map (`Record<value, color>`, kanban-style). A
9+
value→color map — and a select/lookup dimension's option colors — take
10+
precedence over the positional palette per category, so semantic charts
11+
(health, status) paint their own colors instead of the generic palette.

packages/spec/src/ui/chart.zod.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,15 @@ export const ChartConfigSchema = lazySchema(() => z.object({
185185
/** Series Configuration */
186186
series: z.array(ChartSeriesSchema).optional().describe('Defined series configuration'),
187187

188-
/** Appearance */
189-
colors: z.array(z.string()).optional().describe('Color palette'),
188+
/** Appearance. Either a positional palette (string[]) applied per category in
189+
* order, or a value→color map ({ value: color }, kanban-style). A value→color
190+
* map — and a select/lookup dimension's option colors — take precedence over
191+
* the positional palette per category, so semantic charts (health, status)
192+
* paint their own colors instead of the generic palette. */
193+
colors: z.union([
194+
z.array(z.string()),
195+
z.record(z.string(), z.string()),
196+
]).optional().describe('Color palette (string[]) or value→color map ({ value: color })'),
190197
height: z.number().optional().describe('Fixed height in pixels'),
191198

192199
/** Components */

0 commit comments

Comments
 (0)