Datasets and charts
Instead of every dashboard widget carrying its own ad-hoc SQL or QuerySpec, the module offers a Dataset → Chart layer: a data source is described once and reused across any number of visualizations.
Dataset
A dataset is everything a row-level data source needs, except the actual select list — table, WITH, JOINs and filters (DataLens calls this the query's "avatar") — plus named fields split into two kinds:
- dimensions — things you group and filter by (a category, a date, a status);
- measures — things you aggregate (
SUM/AVG/COUNT/MIN/MAX), each with a default aggregation.
You can also define calculated fields — formulas over regular and other calculated fields in the same dataset (e.g. margin = (price - cost) / price), also tagged dimension or measure. Formulas use the same restricted arithmetic grammar (+ - * /) as the No-Code builder's calculated fields — no arbitrary functions or string operations.
Chart
A chart picks a dataset and a handful of its fields — a dimension for the X-axis/category, one or more measures for the Y-axis/value, an optional series field to split into multiple series — nothing else, no SQL. On top of the dataset's fields, a chart can add its own filters, sort, limit, and window functions (ChartWindow) — but only over plain (non-calculated) fields, the same restriction the No-Code builder's own window-function editor has.
Dataset + Chart compiles into an ordinary QuerySpec through the same compiler the rest of the dashboards module already runs through — a chart isn't a separate execution engine, just another way of arriving at a QuerySpec.
Demo dashboards
POST /api/dashboards/demo/seed generates a set of examples on the chosen database, built entirely through the Dataset → Chart → Placement flow — multi-table JOINs, row-level and aggregate calculated fields, window functions, global filters with a KPI trend, and drill-down. Idempotent: re-running deletes any previously created demo objects (identified by a name prefix) before recreating them.