ObjectStackObjectStack

Chart

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

TypeScript Usage

import { ChartAggregateSchema, ChartAggregateFunctionSchema, ChartAnnotationSchema, ChartAxisSchema, ChartConfigSchema, ChartDrillDownSchema, ChartGroupBySchema, ChartInteractionSchema, ChartSeriesSchema, ChartTypeSchema } from '@objectstack/spec/ui';
import type { ChartAggregate, ChartAggregateFunction, ChartAnnotation, ChartAxis, ChartConfig, ChartDrillDown, ChartGroupBy, ChartInteraction, ChartSeries, ChartType } from '@objectstack/spec/ui';

// Validate data
const result = ChartAggregateSchema.parse(data);

ChartAggregate

Inline aggregation for an object-bound chart

Properties

PropertyTypeRequiredDescription
fieldstringoptionalField to aggregate — required for sum/avg/min/max, optional for count
functionEnum<'count' | 'sum' | 'avg' | 'min' | 'max'>Aggregation function
groupBystring | { field: string; dateGranularity?: Enum<'day' | 'week' | 'month' | 'quarter' | 'year'>; alias?: string }Field the rows are grouped by — the chart category axis

ChartAggregateFunction

Allowed Values

  • count
  • sum
  • avg
  • min
  • max

ChartAnnotation

Properties

PropertyTypeRequiredDescription
typeEnum<'line' | 'region'>
axisEnum<'x' | 'y'>
valuenumber | stringStart value
endValuenumber | stringoptionalEnd value for regions
colorstringoptional
labelstring | Record<string, string>optionalDisplay label — the default-language string, or an inline locale map ({ en, "zh-CN" }) resolved at render time
styleEnum<'solid' | 'dashed' | 'dotted'>

ChartAxis

Properties

PropertyTypeRequiredDescription
fieldstringData field key
titlestring | Record<string, string>optionalAxis display title
formatstringoptionalValue format string (e.g., "$0,0.00")
minnumberoptionalMinimum value
maxnumberoptionalMaximum value
stepSizenumberoptionalStep size for ticks
showGridLinesboolean
positionEnum<'left' | 'right' | 'top' | 'bottom'>optionalAxis position
logarithmicboolean

ChartConfig

Properties

PropertyTypeRequiredDescription
typeEnum<'bar' | 'horizontal-bar' | 'column' | 'line' | 'area' | 'pie' | 'donut' | 'funnel' | 'scatter' | 'treemap' | 'sankey' | 'combo' | 'gauge' | 'solid-gauge' | … +6 more>
titlestring | Record<string, string>optionalChart title
subtitlestring | Record<string, string>optionalChart subtitle
descriptionstring | Record<string, string>optionalAccessibility description — announced to screen readers as the chart’s label
xAxis{ field: string; title?: string | Record<string, string>; format?: string; min?: number; … }optionalX-Axis configuration
yAxis{ field: string; title?: string | Record<string, string>; format?: string; min?: number; … }[]optionalY-Axis configuration (support dual axis)
series{ name: string; label?: string | Record<string, string>; type?: Enum<'bar' | 'horizontal-bar' | 'column' | 'line' | 'area' | 'pie' | 'donut' | … +13 more>; color?: string; … }[]optionalDefined series configuration
colorsstring[] | Record<string, string>optionalColor palette (string[]) or value→color map ({ value: color })
heightnumberoptionalFixed plot height in pixels (overrides the container default)
showLegendbooleanDisplay legend
showDataLabelsbooleanDisplay data labels
annotations{ type: Enum<'line' | 'region'>; axis: Enum<'x' | 'y'>; value: number | string; endValue?: number | string; … }[]optionalReference lines/bands drawn over the plot: { type: "line" | "region", axis: "x" | "y", value, endValue?, color?, label?, style? }
interaction{ tooltips: boolean; brush: boolean }optionalInteraction toggles: { tooltips?, brush? }
aria{ ariaLabel?: string | Record<string, string>; ariaDescribedBy?: string; role?: string }optionalARIA accessibility attributes

Allowed Values: ChartConfig.type

  • bar
  • horizontal-bar
  • column
  • line
  • area
  • pie
  • donut
  • funnel
  • scatter
  • treemap
  • sankey
  • combo
  • gauge
  • solid-gauge
  • metric
  • kpi
  • bullet
  • radar
  • table
  • pivot

ChartDrillDown

Properties

PropertyTypeRequiredDescription
enabledbooleanoptionalTurn the segment drill on/off; the block being present already means on, so this is only needed to force it off
filterRecord<string, any>optionalFilter for the drilled list; values support ${event.*}. Omit to derive it from the clicked category
titlestringoptionalDrill drawer/dialog heading; supports ${event.*} interpolation
targetEnum<'drawer' | 'dialog' | 'navigate'>optionalWhere the drilled list opens: 'drawer' (default, side sheet), 'dialog' (centered modal), or 'navigate' (skip the in-place view and open the object's full list page; needs host drill navigation, else falls back to 'drawer')
columnsstring[]optionalField names to show as columns in the drilled list (default: the table's own columns)
maxRowsintegeroptionalRows per page in the drilled list

ChartGroupBy

Union Options

This schema accepts one of the following structures:

Option 1

Field to group by

Type: string


Option 2

Properties

PropertyTypeRequiredDescription
fieldstringField to group by
dateGranularityEnum<'day' | 'week' | 'month' | 'quarter' | 'year'>optionalBucket date values into uniform periods
aliasstringoptionalAlias for the projected group value (defaults to field) — this becomes the category column


ChartInteraction

Properties

PropertyTypeRequiredDescription
tooltipsbooleanShow the hover tooltip
brushbooleanShow the range selector under the plot

ChartSeries

Properties

PropertyTypeRequiredDescription
namestringField name or series identifier
labelstring | Record<string, string>optionalSeries display label
typeEnum<'bar' | 'horizontal-bar' | 'column' | 'line' | 'area' | 'pie' | 'donut' | 'funnel' | 'scatter' | 'treemap' | 'sankey' | 'combo' | 'gauge' | 'solid-gauge' | … +6 more>optionalOverride chart type for this series
colorstringoptionalSeries color (hex/rgb/token)
stackstringoptionalStack identifier to group series
yAxisEnum<'left' | 'right'>Bind to specific Y-Axis
variantEnum<'primary' | 'comparison'>optionalSeries visual role
dashArraystringoptionalSVG stroke-dasharray override
opacitynumberoptionalSeries opacity override

Allowed Values: ChartSeries.type

  • bar
  • horizontal-bar
  • column
  • line
  • area
  • pie
  • donut
  • funnel
  • scatter
  • treemap
  • sankey
  • combo
  • gauge
  • solid-gauge
  • metric
  • kpi
  • bullet
  • radar
  • table
  • pivot

ChartType

Allowed Values

  • bar
  • horizontal-bar
  • column
  • line
  • area
  • pie
  • donut
  • funnel
  • scatter
  • treemap
  • sankey
  • combo
  • gauge
  • solid-gauge
  • metric
  • kpi
  • bullet
  • radar
  • table
  • pivot

On this page