| title | Chart |
|---|---|
| description | Chart protocol schemas |
{/*
Unified Chart Type Taxonomy
Shared by Dashboard and Report widgets.
Provides a comprehensive set of chart types for data visualization.
**Source:** `packages/spec/src/ui/chart.zod.ts`import { ChartAggregate, ChartAggregateFunction, ChartAnnotation, ChartAxis, ChartConfig, ChartGroupBy, ChartInteraction, ChartSeries, ChartType } from '@objectstack/spec/ui';
import type { ChartAggregate, ChartAggregateFunction, ChartAnnotation, ChartAxis, ChartConfig, ChartGroupBy, ChartInteraction, ChartSeries, ChartType } from '@objectstack/spec/ui';
// Validate data
const result = ChartAggregate.parse(data);Inline aggregation for an object-bound chart
| Property | Type | Required | Description |
|---|---|---|---|
| field | string |
optional | Field to aggregate — required for sum/avg/min/max, optional for count |
| function | Enum<'count' | 'sum' | 'avg' | 'min' | 'max'> |
✅ | Aggregation function |
| groupBy | string | { field: string; dateGranularity?: Enum<'day' | 'week' | 'month' | 'quarter' | 'year'>; alias?: string } |
✅ | Field the rows are grouped by — the chart category axis |
countsumavgminmax
| Property | Type | Required | Description |
|---|---|---|---|
| type | Enum<'line' | 'region'> |
✅ | |
| axis | Enum<'x' | 'y'> |
✅ | |
| value | number | string |
✅ | Start value |
| endValue | number | string |
optional | End value for regions |
| color | string |
optional | |
| label | string |
optional | Display label (plain string; i18n keys are auto-generated by the framework) |
| style | Enum<'solid' | 'dashed' | 'dotted'> |
✅ |
| Property | Type | Required | Description |
|---|---|---|---|
| field | string |
✅ | Data field key |
| title | string |
optional | Axis display title |
| format | string |
optional | Value format string (e.g., "$0,0.00") |
| min | number |
optional | Minimum value |
| max | number |
optional | Maximum value |
| stepSize | number |
optional | Step size for ticks |
| showGridLines | boolean |
✅ | |
| position | Enum<'left' | 'right' | 'top' | 'bottom'> |
optional | Axis position |
| logarithmic | boolean |
✅ |
| Property | Type | Required | Description |
|---|---|---|---|
| type | Enum<'bar' | 'horizontal-bar' | 'column' | 'line' | 'area' | 'pie' | 'donut' | 'funnel' | 'scatter' | 'treemap' | 'sankey' | 'gauge' | 'solid-gauge' | 'metric' | 'kpi' | 'bullet' | 'radar' | 'table' | 'pivot'> |
✅ | |
| title | string |
optional | Chart title |
| subtitle | string |
optional | Chart subtitle |
| description | string |
optional | Accessibility description |
| xAxis | { field: string; title?: string; format?: string; min?: number; … } |
optional | X-Axis configuration |
| yAxis | { field: string; title?: string; format?: string; min?: number; … }[] |
optional | Y-Axis configuration (support dual axis) |
| series | { name: string; label?: string; type?: Enum<'bar' | 'horizontal-bar' | 'column' | 'line' | 'area' | 'pie' | 'donut' | 'funnel' | 'scatter' | 'treemap' | 'sankey' | 'gauge' | 'solid-gauge' | 'metric' | 'kpi' | 'bullet' | 'radar' | 'table' | 'pivot'>; color?: string; … }[] |
optional | Defined series configuration |
| colors | string[] | Record<string, string> |
optional | Color palette (string[]) or value→color map ({ value: color }) |
| height | number |
optional | Fixed height in pixels |
| showLegend | boolean |
✅ | Display legend |
| showDataLabels | boolean |
✅ | Display data labels |
| annotations | { type: Enum<'line' | 'region'>; axis: Enum<'x' | 'y'>; value: number | string; endValue?: number | string; … }[] |
optional | |
| interaction | { tooltips: boolean; zoom: boolean; brush: boolean; clickAction?: string } |
optional | |
| aria | { ariaLabel?: string; ariaDescribedBy?: string; role?: string } |
optional | ARIA accessibility attributes |
This schema accepts one of the following structures:
Field to group by
Type: string
| Property | Type | Required | Description |
|---|---|---|---|
| field | string |
✅ | Field to group by |
| dateGranularity | Enum<'day' | 'week' | 'month' | 'quarter' | 'year'> |
optional | Bucket date values into uniform periods |
| alias | string |
optional | Alias for the projected group value (defaults to field) — this becomes the category column |
| Property | Type | Required | Description |
|---|---|---|---|
| tooltips | boolean |
✅ | |
| zoom | boolean |
✅ | |
| brush | boolean |
✅ | |
| clickAction | string |
optional | Action ID to trigger on click |
| Property | Type | Required | Description |
|---|---|---|---|
| name | string |
✅ | Field name or series identifier |
| label | string |
optional | Series display label |
| type | Enum<'bar' | 'horizontal-bar' | 'column' | 'line' | 'area' | 'pie' | 'donut' | 'funnel' | 'scatter' | 'treemap' | 'sankey' | 'gauge' | 'solid-gauge' | 'metric' | 'kpi' | 'bullet' | 'radar' | 'table' | 'pivot'> |
optional | Override chart type for this series |
| color | string |
optional | Series color (hex/rgb/token) |
| stack | string |
optional | Stack identifier to group series |
| yAxis | Enum<'left' | 'right'> |
✅ | Bind to specific Y-Axis |
| variant | Enum<'primary' | 'comparison'> |
optional | Series visual role |
| dashArray | string |
optional | SVG stroke-dasharray override |
| opacity | number |
optional | Series opacity override |
barhorizontal-barcolumnlineareapiedonutfunnelscattertreemapsankeygaugesolid-gaugemetrickpibulletradartablepivot