Skip to content

Commit cb03bc3

Browse files
os-zhuangclaude
andauthored
feat(types): type object-chart colors as palette or value→color map (#1936)
ObjectChartSchema.colors now accepts a positional palette (string[]) OR an explicit value→color map (Record<value,color>, kanban-style), matching the renderer that resolves select/lookup option colors per category and lets them win over the positional palette. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 48963f9 commit cb03bc3

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@object-ui/types": patch
3+
---
4+
5+
feat(types): type `object-chart` `colors` as a palette OR a value→color map
6+
7+
`ObjectChartSchema.colors` now accepts either a positional palette (`string[]`)
8+
or an explicit value→color map (`Record<value, color>`, kanban-style). This
9+
matches the chart renderer, which resolves a select/lookup dimension's option
10+
colors per category and lets them (and any explicit map) win over the
11+
positional palette — so health green/red/yellow paints semantically.

‎packages/types/src/zod/objectql.zod.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,15 @@ export const ObjectChartSchema = BaseSchema.extend({
465465
dataset: z.string().optional().describe('Semantic-layer dataset name (ADR-0021)'),
466466
dimensions: z.array(z.string()).optional().describe('Dataset dimension names'),
467467
values: z.array(z.string()).optional().describe('Dataset measure names'),
468+
// Colors are overloaded kanban-style: a string[] is the positional palette
469+
// (applied per category in order; fallback only), while a Record<value,color>
470+
// is an explicit value→color map. A select/lookup dimension's option colors —
471+
// and any explicit map — take precedence over the positional palette per
472+
// category, so health green/red/yellow paints semantically.
473+
colors: z.union([
474+
z.array(z.string()),
475+
z.record(z.string(), z.string()),
476+
]).optional().describe('Positional palette (string[]) OR a value→color map ({ value: color }, kanban-style). Select/lookup option colors and explicit maps win over the palette per category.'),
468477
});
469478

470479
/**

0 commit comments

Comments
 (0)