Dashboard metadata — charts and KPIs
Build analytics dashboards with chart widgets, global filters, and auto-refresh
A Dashboard defines an analytics page with chart widgets, key metrics, and data visualizations. Dashboards support configurable layouts, global date filters, and auto-refresh.
Basic Structure
Every widget binds to a dataset (the semantic layer, ADR-0021) and selects
the dataset's dimensions and values by name. The dataset owns the base
object, joins, and measures, so the same numbers stay consistent
across every dashboard and report.
const salesDashboard = {
name: 'sales_overview',
label: 'Sales Overview',
description: 'Key sales metrics and pipeline analysis',
refreshIntervalSeconds: 300, // Refresh every 5 minutes
dateRange: {
field: 'close_date',
defaultRange: 'this_quarter',
allowCustomRange: true,
},
widgets: [
{
id: 'total_revenue',
title: 'Total Revenue',
type: 'metric',
dataset: 'sales',
values: ['revenue'],
layout: { x: 0, y: 0, w: 3, h: 2 },
},
{
id: 'revenue_by_region',
title: 'Revenue by Region',
type: 'bar',
dataset: 'sales',
dimensions: ['region'],
values: ['revenue'],
layout: { x: 3, y: 0, w: 6, h: 4 },
},
{
id: 'deals_by_month',
title: 'Deals by Month',
type: 'pie',
dataset: 'sales',
dimensions: ['close_month'],
values: ['deal_count'],
layout: { x: 9, y: 0, w: 3, h: 4 },
},
],
};Dashboard Properties
| Property | Type | Required | Description |
|---|---|---|---|
name | string | ✅ | Machine name (snake_case) |
label | string | ✅ | Display label |
description | string | optional | Dashboard description |
widgets | DashboardWidget[] | ✅ | Chart and metric widgets |
refreshIntervalSeconds | number | optional | Auto-refresh interval (seconds) |
dateRange | object | optional | Global date range filter |
globalFilters | GlobalFilter[] | optional | Global filter controls |
Widgets
Each widget defines a data visualization. A widget binds to a dataset and
selects dimensions (X / group / split) and values (the measures to plot):
{
id: 'monthly_revenue',
title: 'Monthly Revenue',
type: 'line',
dataset: 'invoicing',
dimensions: ['invoice_month'],
values: ['paid_total'],
filter: { status: 'paid' },
layout: { x: 0, y: 0, w: 6, h: 4 },
}Widget Properties
| Property | Type | Required | Description |
|---|---|---|---|
id | string | ✅ | Unique widget id (snake_case) |
dataset | string | ✅ | Dataset name to bind |
values | string[] | ✅ | Measure names (at least one) |
dimensions | string[] | optional | Dimension names — X / group / split |
type | ChartType | optional | Visualization type (default metric, see below) |
title | string | optional | Widget display title |
description | string | optional | Text shown below the title |
filter | FilterCondition | optional | Presentation-scope filter (runtimeFilter) |
layout | object | optional | Grid position and size (auto-flowed into the grid when omitted) |
chartConfig | object | optional | Chart appearance: title, subtitle, description, colors, height, showLegend, showDataLabels, annotations, interaction. The bound dataset decides which series exist and which column each one reads, so type, xAxis, yAxis and series are refused here — see below |
colorVariant | enum | optional | KPI/card accent color |
compareTo | object | optional | Period-over-period comparison: { kind: 'previousPeriod' | 'previousYear', dimension? }. Omit dimension when the selection dates exactly one time dimension — the runtime resolves it, and errors naming the candidates rather than guessing when it cannot. The window's date key must be a dimension the dataset declares, so the date field it comes from must be a field of the dataset's own object — see The Date Key of a Compare Widget. The delta is coloured by the measure's polarity: 'lower' draws a rise red and a fall green, 'neutral' draws neither; undeclared, a rise is green. |
options | object | optional | The query keys below. Presentation does not go here — see below |
What chartConfig does not carry
A dashboard widget is always bound to a dataset (dataset is required), and the
dataset owns the chart's structure: which series exist, and which column
each one reads. chartConfig carries appearance. So four keys that the
shared chart config declares are refused on a dashboard widget by name, each
refusal naming where the intent belongs:
you wrote inside chartConfig | write this on the widget instead |
|---|---|
type: 'line' | type: 'line' — the widget's own type is the chart family, and it always won |
xAxis: { field: 'stage' } | dimensions: ['stage'] — the dataset dimension the category axis plots |
yAxis: [{ field: 'amount' }] | values: ['amount'] — the dataset measures, one entry per mark |
series: [{ name: 'amount' }] | values (+ a second dimensions entry to split) — series membership follows the selection |
Axis titles, number formats, axis bounds and per-series labels, colours and mark
types went with those keys: a dataset-bound chart takes them from the dataset's
own dimension and measure declarations. colors on the chart config is the
palette channel that remains.
The keys are not gone from the chart config everywhere. A react-tier
<ObjectChart data={…} /> binds inline rows with no dataset behind them, so its
axes are the author's and are unchanged; a report chart names its bound
dataset's dimension and measure directly in xAxis / yAxis.
Existing sources: os migrate meta --from 17 lists the mechanical edits.
Widget options
options carries five declared keys, and four of them change the query the
dataset compiles to. The bag is open, so any other key parses, but a dashboard
widget is always bound to a dataset and nothing on that render path reads
another key: an icon, columns, format or color written here styles
nothing. os validate, os build and os lint warn on each such key by name
(unconsumed-widget-option) and list the keys that are read.
Presentation has declared homes instead:
| You want | Write it here |
|---|---|
| A number's format or currency | The dataset measure's format and currency |
| A KPI delta's good/bad colour (lower is better for turnaround, cost) | The dataset measure's polarity: 'higher', 'lower' or 'neutral' |
| A KPI tile's accent color | The widget's colorVariant |
| A chart's look (colors, legend, data labels, height) | The widget's chartConfig |
A key that something outside the renderer genuinely reads can say so with
suppressWarnings: ['unconsumed-widget-option'] on the widget.
The declared keys:
| Key | Type | Effect |
|---|---|---|
dateGranularity | day | week | month | quarter | year | Buckets this widget's selected date dimensions. Overrides the dataset dimension's own default for this widget only. |
sortBy | string | Orders rows by a dimension or measure this widget selects. |
sortOrder | asc | desc | Direction for sortBy (default asc). |
limit | number | Max rows, applied after ordering. |
stageOrder | (string | number | boolean)[] | Explicit stage order for a funnel widget, as the dimension's stored values. funnel is the only widget type that reads it, and the schema refuses it on any other type; order those with sortBy / sortOrder. Omit to use the dimension field's picklist option order. |
Because they are declared, a wrong value (sortOrder: 'sideways') is an
author-time error. A misspelled key (sortDirection, granularity) is
not declared, so it parses like any other extra and changes nothing; the
unconsumed-widget-option warning is what names it.
{
id: 'revenue_trend',
type: 'area',
dataset: 'opportunity_metrics',
dimensions: ['close_date'],
values: ['total_amount'],
// Group by month rather than by raw timestamp.
options: { dateGranularity: 'month' },
}Notes on behaviour:
sortBymust name something the widget selects; the server rejects an order key it cannot resolve rather than ignoring it.- A
limitwith nosortByorders by the selected dimensions first, so it truncates a reproducible window instead of an arbitrary subset. - Ordering is applied to the finished grid, so a derived measure is a valid
sortByeven though no single SQL statement computes it. - A
sortBynaming a dimension whose field carriesoptions, or a reference dimension, orders by the display label the rows render (the option label / the related record's name), not the stored value or foreign-key id — and the label is resolved beforelimitapplies, so a top-N by name truncates the right N. The option arm keys on theoptionslist being there, not on the field's type, so it is not limited toselect; reference is the whole class of fields whose stored value is another record's id, so auserperson axis sorts by name too. Sorting by a measure (the common case) involves no label lookup and is unaffected. - A
funnelwith no declared stage order falls back to sorting by value descending.
Datasets
Every widget binds to a dataset — the single semantic layer (ADR-0021). A dataset defines the base object, allowed relationship joins, reusable dimensions, measures, and intrinsic filters once; dashboards and reports then reference the same names so "revenue", "pipeline", or "win rate" stay consistent across surfaces.
The legacy inline-query shape (
object+categoryField+valueField+aggregatedirectly on the widget) was removed in the ADR-0021 single-form cutover. Define a dataset and bind widgets to it instead.
import { defineDataset } from '@objectstack/spec/ui';
export const salesDataset = defineDataset({
name: 'sales',
label: 'Sales',
object: 'opportunity',
include: ['account'],
dimensions: [
{ name: 'region', field: 'account.region', type: 'string', synonyms: ['territory', 'area'] },
{
name: 'close_month', field: 'close_date', type: 'date', dateGranularity: 'month',
synonyms: ['closing month', 'month closed'],
},
],
measures: [
{
name: 'revenue', field: 'amount', aggregate: 'sum',
synonyms: ['sales', 'pipeline value'],
description: 'The total amount of every opportunity, open or closed.',
},
{ name: 'deal_count', aggregate: 'count', synonyms: ['deals', 'number of deals'] },
],
});
export const salesDashboard = {
name: 'sales_overview',
label: 'Sales Overview',
widgets: [
{
id: 'revenue_by_region',
title: 'Revenue by Region',
type: 'bar',
dataset: 'sales',
dimensions: ['region'],
values: ['revenue'],
layout: { x: 0, y: 0, w: 6, h: 4 },
},
],
};Each widget requires a dataset and at least one values entry. The widget's
dimensions and values must reference names declared on the bound dataset.
At runtime, dataset queries are executed through the analytics service. When
@objectstack/plugin-security is registered, analytics auto-bridges to
security.getReadFilter(object, context) and applies the caller's RLS scope to
the base object and joined objects.
ObjectUI currently renders dataset-backed metric, chart,
table/list, pivot, funnel, and gauge-style widgets with type-aware cells,
field/option labels, date bucketing, and numeric/currency formatting.
table and pivot widgets are also drill-through (see
Drill-down below); the dataset preserves raw group keys so the
generated filter navigates to the exact underlying records.
Chart Types
| Type | Description | Best For |
|---|---|---|
metric | Single number KPI | Revenue, count, percentage |
bar | Bar chart (vertical/horizontal) | Category comparison |
line | Line chart | Trends over time |
pie | Pie/donut chart | Distribution |
area | Area chart | Volume over time |
scatter | Scatter plot | Correlation |
radar | Radar chart | Multi-dimensional comparison |
funnel | Funnel chart | Conversion stages |
gauge | Gauge (single value) | Progress toward goal |
treemap | Tree map | Hierarchical proportions |
table | Data table widget | Detailed records |
pivot | Pivot table | Cross-tab summaries |
Additional types: horizontal-bar, column, donut, sankey, solid-gauge,
kpi, and bullet. The default type is metric.
Drill-down
table and pivot widgets are drill-through: clicking an aggregated row
(table) or cell (pivot) opens a side drawer listing the underlying records
behind that group. Because the dataset preserves each grouped row's raw group
keys, the drawer's filter matches the exact records — no label-to-id guessing.
The drilled record list is itself drill-to-record: click any row in the drawer to open that single record's detail. This completes the group → records → record chain (e.g. Revenue by Region → the orders in the West bucket → one order).
The drawer also offers an "Open in list →" escape hatch — escalate the peek
to the object's full list page (sort / bulk-select / export / shareable URL),
scoped by the same drill filter. In-place drawer is the default (keep context);
the escape hatch is there when you need the full surface. Not every drill gets
the link today: a drill on a dimension whose field is a relationship path,
such as region in the sales dataset above (account.region), stays in the
drawer, because the list page's URL filter has no spelling for a condition on a
related record. Reports drill
identically: a summary / matrix report opens the same in-place drawer on
row/cell click, so dashboard and report drill behave the same.
// A drill-through table widget. No drill configuration is required — it is
// automatic whenever the dataset exposes the base object and the widget groups
// by at least one dimension.
{
id: 'orders_by_region',
title: 'Orders by Region',
type: 'table',
dataset: 'sales',
dimensions: ['region'],
values: ['revenue', 'deal_count'],
layout: { x: 0, y: 0, w: 6, h: 4 },
}Drill-through is automatic — there is no per-widget drill configuration in the
dataset form. metric and chart widgets render the aggregate only and are not
click-drillable; expose the detail through a table/pivot widget instead.
Renderer note. Object/record-backed list and table surfaces (and the ObjectUI renderer's
options.drillDownblock) support a richer drill model — amode: 'filter' | 'record'discriminator, atargetof'drawer'/'dialog'/'navigate'(the last opens the list page directly), a column whitelist, and chart-segment drill for thescatter/treemap/sankeyfamilies. Those knobs live in the renderer; dataset-bound dashboards drill through the semantic layer as described above (and get the "Open in list →" escape hatch from the host app, e.g. the console, except today on a relationship-path dimension, as noted above).
Aggregation Functions
Aggregation is declared on the dataset's measures (via aggregate), not on
the widget. Supported functions:
| Function | Description |
|---|---|
count | Count records |
sum | Sum values |
avg | Average values |
min | Minimum value |
max | Maximum value |
count_distinct | Count unique values |
Widget Layout
Widgets are positioned on a 12-column grid:
layout: {
x: 0, // Column position (0-11)
y: 0, // Row position
w: 6, // Width in columns (1-12)
h: 4, // Height in rows
}Date Range
Configure a global time filter that applies to all widgets:
dateRange: {
field: 'created_at',
defaultRange: 'this_month',
allowCustomRange: true,
}Preset Ranges
| Range | Description |
|---|---|
today | Current day |
yesterday | Previous day |
this_week | Current week |
last_week | Previous week |
this_month | Current month |
last_month | Previous month |
next_month | Following month |
this_quarter | Current quarter |
last_quarter | Previous quarter |
next_quarter | Following quarter |
this_year | Current year |
last_year | Previous year |
last_7_days | Rolling 7 days |
last_30_days | Rolling 30 days |
last_90_days | Rolling 90 days |
next_30_days | Today and the 30 days after it |
custom | User-defined range |
The named ranges are published as DATE_RANGE_PRESETS in
@objectstack/spec/ui — the vocabulary's single source of truth. custom is not
one of them: it selects no window, it opens the picker.
Global Filters
Add interactive filter controls that apply to all widgets:
globalFilters: [
// `account.region` is a DOTTED PATH walked from the bound widget's
// `dataset.object` (`opportunity`) through the `include: ['account']` the
// dataset declares. It is not the dataset's dimension that is also spelled
// `region` — a filter's `field` never reads dimension names.
{ name: 'region', field: 'account.region', label: 'Region', type: 'select' },
{ field: 'owner', label: 'Sales Rep', type: 'lookup' },
]Each filter's name is its stable identity: the key its value is published
under as a dashboard-level variable (readable in widget expressions as
page.<name>) and the key widgets reference in filterBindings. It defaults
to field. The
filter above names itself region for exactly that reason — left to default it
would be keyed account.region, dots and all, in every expression and binding.
On a dashboard that declares dateRange, the name dateRange is reserved for
that built-in date range: an entry keyed dateRange (by name, or by field
when unnamed) is refused, because it would replace the date range's control and
every widget's filterBindings.dateRange binding. On a dashboard that does not
declare dateRange, the name is free and such an entry is an ordinary filter.
Filter controls and options
Each entry renders one control in the filter bar above the widgets, and its type decides
the condition it adds to every bound widget's query, AND-combined with the widget's own
filter:
type | Control | Condition |
|---|---|---|
text | Text input | { field: { $contains: value } } |
number | Numeric input | { field: value } |
select, lookup | Dropdown | { field: value }, or $in for several values |
date | Preset / custom range | { field: { $gte: from, $lte: to } } |
Static options are { value, label } pairs, where label is a string or an inline locale
map ({ en: 'AMER', 'zh-CN': '美洲' }). The bare-string shorthand (options: ['EMEA', 'APAC']) is refused at publish, and a stored filter written that way renders with an empty
option list. Options can instead be read from an object:
globalFilters: [
{
name: 'industry',
field: 'industry',
label: 'Industry',
type: 'select',
// object, valueField and labelField are all required; with no separate label
// column, name the value field again. `filter` is a condition object, not an array.
optionsFrom: { object: 'account', valueField: 'industry', labelField: 'industry', filter: { status: 'active' } },
},
]The Console resolves optionsFrom as distinct values on the server, so the list is complete
whatever the row count. A filter that declares object (the object its field lives on, not
the optionsFrom source) takes its label and option labels from the app's
translation bundle (objects.<object>.fields.<field>.label and
.options.<value>), as lists and forms do; the authored label is then the fallback.
Where a Filter's field Resolves
A global filter's field resolves against the object behind each bound
widget's dataset (dataset.object) — never against that dataset's declared
dimensions. Widget dimensions are selected from the dataset by name.
They are two different namespaces:
| Key | Resolved against | Rejected by |
|---|---|---|
globalFilters[].field (after any filterBindings re-target) | The bound widget's dataset.object — a bare name against that object's own fields, a dotted relationship.field path hop by hop with its prefix declared in the dataset's include | dashboard-filter-field-unknown, severity error |
widgets[].dimensions[] | The dataset's declared dimensions, by name | widget-dimension-unknown, severity error |
widgets[].filterBindings keys | The dashboard's declared filters, by name: each globalFilters[].name (its field when unnamed), and dateRange only when the dashboard declares dateRange | dashboard-filter-binding-unknown, severity error |
Two consequences follow, and their asymmetry is the part that surprises authors:
- A filter needs no dataset dimension. The Complete Example
below filters on
projectandassignee, neither of which theproject_tasksdataset declares — both are fine, because theproject_taskobject has those fields. - Declaring a dimension confers no filterability, and a filterable field is not group-by-able. The same field can be filterable and un-group-by-able on one dataset: to filter on it the object must have it, and to group by it the dataset must declare it as a dimension. Declaring either buys the other nothing.
A filter naming a field the widget's own object lacks makes that widget's query
address a column that does not exist. os validate and the runtime publish door
both refuse the board rather than shipping it — see
Dangling widget bindings.
Opt a single widget out with filterBindings: { <name>: false } (see
Per-Widget Filter Bindings below).
The dataset query that renders a widget holds the same line at runtime: it
answers only the measures and dimensions its dataset declares, by their declared
names, and refuses an object's own field named as a dimension with
400 INVALID_FIELD (see Datasets).
widget-dimension-unknown refuses the same mistake at author time. Only the
cube query (POST /analytics/query), which is not a dataset, still groups by an
object's own field without a declaration.
The Date Key of a Compare Widget
A widget with compareTo compares over a date window, and the runtime takes that
window from the widget's filter, the dashboard's dateRange filter included. The
window is sent to the dataset query as a time dimension named after the filtered
field (dateRange.field, created_at by default). A dataset query answers
only declared dimensions, so when that field is a field of the dataset's own
object, its name must also be the name of a date dimension the dataset
declares:
dimensions: [
// The dashboard's dateRange filters `close_date`, so a compare widget's
// window arrives as the dimension "close_date".
{
name: 'close_date', label: 'Close date', field: 'close_date', type: 'date',
synonyms: ['closing date', 'date closed'],
},
],Otherwise the widget's query is refused with 400 INVALID_FIELD, and the message
names the remedy: declare a date dimension named after the date-range field.
A date field of a related record — a dotted relationship.field such as
account.signed_at, which a dashboard filter may otherwise name (see
Filtering on a Related Record's Field) —
cannot be a dimension name, because a dimension name is a snake_case identifier
with no dot. Declare a date dimension over the path instead, under any name
(the relationship is listed in the dataset's include, as for any dimension over
a path):
dimensions: [
// The dashboard's dateRange filters `account.signed_at`; the compare widget
// reads the dataset and sends its window as the dimension "account_signed".
{ name: 'account_signed', label: 'Account signed', field: 'account.signed_at', type: 'date' },
],When the window's key is such a path, the widget reads the dataset definition
and sends the window under the one declared dimension with type: 'date' and
field equal to the path. A widget compareTo.dimension may name it by either
spelling, the path or the declared name. When no declared date dimension covers
the path, or two or more do, the widget sends the dotted key as it is, and the
dataset query refuses the comparison with 400 INVALID_FIELD. A key that can be
a dimension name, such as close_date, is always sent as it is.
No author-time rule checks a compare widget's date key yet.
Filtering on a Related Record's Field
A dotted relationship.field filter — a global filter's field, a widget's
filter, or a dataset query's runtimeFilter — filters the base rows by a field
of the record they point at, such as leaving out the plan lines of cancelled
orders with { 'order.status': { $ne: 'cancelled' } }. The analytics service
evaluates it on one of two paths, and the path decides how deep it may reach:
| Path | When it serves the query | Depth |
|---|---|---|
| Native SQL | A SQL datasource (SQLite, PostgreSQL, MySQL, SQL Server, Turso), unless the query buckets a date by granularity, reads a federated object, or reads an object with an engine-enforced read gate (an engine middleware, or a controlled_by_parent read scope) | Every hop, as a LEFT JOIN per relationship |
| Engine aggregate | Every query the native SQL path does not serve | Up to three relationships (ADR-0071's hop limit), each read as the caller |
On the engine-aggregate path the filter reads the related object as the caller, with that object's row-level security and field permissions, and keeps the base rows whose relationship points at a record it returned:
- A row with no related record, or one the caller cannot read, is not
selected, whatever the operator,
$neand$ninincluded. To keep such rows, add the relationship itself as another branch:{ $or: [{ 'order.status': { $ne: 'cancelled' } }, { order: { $null: true } }] }. - When no related record matches, the widget shows no rows, never the unfiltered set.
- A related field the caller cannot read is refused (
403 PERMISSION_DENIED), as filtering on it directly would be. - On a SQL datasource a condition through a single-valued relation usually
runs inside the same statement, as a subquery, so the number of matching
related records is not limited. Where the engine reads the matching related
ids first instead (a multi-valued relation, on every driver; a related object
on another datasource, a federated one, one whose reads an object-scoped
middleware or an
afterFindhook shapes, or one read under different driver options than the queried object, its tenant scope most commonly; the full list is in Query Syntax), more than 1,000 of them are refused (400 INVALID_FILTER), never truncated. Narrow the related condition. On a driver that cannot run it in one read (MongoDB, OData), a condition through a single-valued relation is refused before anything is read (400 INVALID_FILTER), naming the two-step route. - These are refused (
400 INVALID_FIELD) rather than answered differently: a path of four or more relationships (line.plan.order.customer.tier), a related-field condition under$not(write$ne/$nininside the condition instead), and a related field compared with another field ($field).
On the native SQL path, too, a related-field condition that is not under
$not never selects a row with no related record (an empty relationship, or
one naming a record that no longer exists), whether it sits in the query's
filter, a measure's own filter or the dataset's own filter: $ne, $nin,
$notContains, $null: true, $eq: null, $exists: false and $empty: true
included, so the two paths agree on such rows. The same $or brings back the
rows with an empty relationship on both paths; a row naming a record that no
longer exists is not brought back by it. A related record that exists with no
value in the field still satisfies $ne and $nin, and $nin: [] (an empty
list, which excludes no value) selects every row whose related record exists.
One native-path exception remains, under $not, which the engine path refuses:
the native path still selects such a row when the negated condition is one a
missing value does not satisfy, such as a comparison with a value
({ $not: { 'order.status': 'open' } }) or a presence test ($null: false,
$exists: true, $ne: null, $empty: false), so write $ne / $nin inside
the condition instead. Two $nots cancel: { $not: { $not: CONDITION } }
selects exactly the rows CONDITION selects, so it leaves such a row out
wherever CONDITION does.
A related field in a dataset's own filter is evaluated on both paths, as
in the query's filter. A related field in a measure's own filter is still
evaluated only on the native SQL path; the engine-aggregate path refuses it
(400 INVALID_FIELD) rather than count rows it cannot join.
Date Filter Defaults
A type: 'date' filter's defaultValue must be a value the dashboard can
actually resolve to a window. Three spellings qualify:
| Spelling | Example | Means |
|---|---|---|
| Preset name | last_7_days | The preset range of that name (table above) |
| ISO date | 2026-01-15, 2026-01-15T08:30:00Z | That day exactly |
| Date macro | {today}, {30_days_ago} | Resolved at query time |
globalFilters: [
{ field: 'created_at', label: 'Date Range', type: 'date', defaultValue: 'last_7_days' },
]Anything else is rejected at author time. This matters because the failure it
replaces was silent: an unrecognised name cannot be lifted to a range, so it fell
through to "a bare string date means equality on that day" and produced
created_at = 'last_7_dayz' — a condition no row matches, which the backend
answers 200 OK with a zero. Every tile read 0 while the filter bar showed
"All time", so the dashboard looked deliberately empty rather than misconfigured.
custom is not accepted here. It is a dateRange.defaultRange sentinel
meaning "open the picker with no preset applied", and a bare filter value gives
it no from/to to hand over.
Defaulting to the Current ISO Week
Weekly data is often keyed by an ISO week rather than by a date: a text field
such as cost_week holds 2026-W47. A text filter over that field can default
to the current week with the placeholder {current_iso_week}:
globalFilters: [
{ field: 'cost_week', label: 'Week', type: 'text', defaultValue: '{current_iso_week}' },
]Each time the dashboard opens, the placeholder resolves to the current week's
key, and the filter box shows that key (2026-W47), not the placeholder. The
user can edit it like any typed value, and it filters the field the same way.
- The week. The key is the ISO-8601 week, written
YYYY-Www. Weeks start on Monday, and week 1 is the week that holds the year's first Thursday. Near New Year the year in the key can differ from the calendar year: Friday 2027-01-01 is in2026-W53, and Monday 2027-01-04 starts2027-W01. This is the same label an analyticsweekbucket groups by. - The day. "Today" is the calendar day in the workspace time zone, the
same day the date macros such as
{today}read. - A fixed week. A literal key,
defaultValue: '2026-W47', stays a fixed default. - Widget filters.
{current_iso_week}also works as a value in any filter condition, such as a widget'sfilter: { cost_week: '{current_iso_week}' }. It resolves before the query runs, in the browser and on the server. - Not a date. The key is text. A
type: 'date'filter refuses it as a default, and so does a calendar view'sinitialDate. To filter a date field to this week, use thethis_weekpreset or{current_week_start}/{current_week_end}. In a filter on a date, datetime or time field the placeholder is refused (INVALID_FILTER, 400), as the literal key is: use it only on fields that store week keys.
Per-Widget Filter Bindings
By default a filter applies to its own field on every widget (the date
range defaults to dateRange.field ?? 'created_at'). When a widget stores
the concept under a different field — or should ignore a filter — declare
filterBindings on the widget:
widgets: [
// Default binding: dateRange → created_at, region → region.
{ id: 'invoices_by_status', /* … */ },
// This widget's own fields differ — map each filter explicitly.
{
id: 'accounts_signed',
filterBindings: { dateRange: 'signed_at', region: 'sales_region' },
/* … */
},
// Opt out of a filter with `false`.
{ id: 'total_invoices', filterBindings: { region: false }, /* … */ },
]Binding precedence: an explicit filterBindings entry (string override or
false opt-out) → the filter's legacy targetWidgets allow-list → the
filter's own field.
Each key must name a filter the dashboard declares. The dashboard looks a
binding up by the declared filter's name, so a misspelled key (regoin for
region) is never read and the widget keeps the filter it was meant to drop
or re-target. os validate and the publish door refuse such a key with
dashboard-filter-binding-unknown, naming the declared filters.
In the Console
- The filter bar. The date range and each global filter render as controls above the widgets; a Reset button appears once any of them differs from its default. Changing one re-reads every bound widget in place.
- Presets stay symbolic. A preset compiles to date-macro tokens (
{30_days_ago},{current_month_start}) that each widget resolves at query time, so a dashboard saved today still means "last 30 days" tomorrow. - Values in expressions. Filter values are dashboard variables, read as
page.<name>. The date range is an object underpage.dateRange:{ preset: 'last_30_days' }for a preset,{ from: '2026-01-01', to: '2026-03-31' }for a custom range (either bound may be absent). A dashboard embedded in a page that declares its ownvariablesmerges the two scopes: a filter shadows only an outer variable of the same name, and a write goes to the scope that defines the variable. - Bindings in Studio. The dashboard widget inspector has a Follows the filters at the
top of the page section, one row per declared filter, named by the filter's label (the
date range reads Date; a filter with no label reads its dimension's label), with an
apply toggle (the
falseopt-out) and a field picker for the override. The panel names fields, metrics and data sources by their labels; a machine name shows on hover only. - Refresh. The page header has a Refresh All button, and
refreshIntervalSecondsre-reads the widgets every that many seconds (0or unset: no automatic refresh). Widgets re-read in place rather than remounting, single-value tiles included.
Complete Example
First define the dataset the widgets bind to:
import { defineDataset } from '@objectstack/spec/ui';
export const projectTasksDataset = defineDataset({
name: 'project_tasks',
label: 'Project Tasks',
object: 'project_task',
dimensions: [
{ name: 'status', field: 'status', type: 'string', synonyms: ['state', 'progress'] },
{ name: 'priority', field: 'priority', type: 'string', synonyms: ['urgency', 'importance'] },
{
name: 'completed_month', field: 'completed_at', type: 'date', dateGranularity: 'month',
synonyms: ['month completed', 'finish month'],
},
],
measures: [
{
name: 'open_count', aggregate: 'count', filter: { status: { $ne: 'done' } },
synonyms: ['open tasks', 'unfinished tasks'],
},
{
name: 'done_count', aggregate: 'count', filter: { status: 'done' },
synonyms: ['done tasks', 'completed tasks'],
},
{ name: 'task_count', aggregate: 'count', synonyms: ['tasks', 'number of tasks'] },
],
});Then bind the dashboard widgets to it:
const projectDashboard = {
name: 'project_overview',
label: 'Project Overview',
description: 'Real-time project health metrics',
refreshIntervalSeconds: 60,
dateRange: {
field: 'created_at',
defaultRange: 'this_month',
allowCustomRange: true,
},
globalFilters: [
{ field: 'project', label: 'Project', type: 'lookup' },
{ field: 'assignee', label: 'Team Member', type: 'lookup' },
],
widgets: [
{
id: 'open_tasks',
title: 'Open Tasks',
type: 'metric',
dataset: 'project_tasks',
values: ['open_count'],
layout: { x: 0, y: 0, w: 3, h: 2 },
},
{
id: 'completed_this_week',
title: 'Completed This Week',
type: 'metric',
dataset: 'project_tasks',
values: ['done_count'],
layout: { x: 3, y: 0, w: 3, h: 2 },
},
{
id: 'tasks_by_status',
title: 'Tasks by Status',
type: 'pie',
dataset: 'project_tasks',
dimensions: ['status'],
values: ['task_count'],
layout: { x: 6, y: 0, w: 3, h: 4 },
},
{
id: 'tasks_by_priority',
title: 'Tasks by Priority',
type: 'bar',
dataset: 'project_tasks',
dimensions: ['priority'],
values: ['task_count'],
layout: { x: 9, y: 0, w: 3, h: 4 },
},
{
id: 'completion_trend',
title: 'Completion Trend',
type: 'line',
dataset: 'project_tasks',
dimensions: ['completed_month'],
values: ['task_count'],
layout: { x: 0, y: 4, w: 12, h: 4 },
},
],
};Related
- App Metadata — Reference dashboards in app navigation
- View Metadata — List views for record browsing
- Page Metadata — Custom pages with component layouts
Actions
Declare buttons as metadata with server-side behavior — bind them to lists, records and navigation, permission-check both sides, and expose them to AI.
Report Metadata
Analytics reports as metadata — the four report shapes, dataset binding, drill-through, and how a report differs from a list view and a dashboard widget