Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .changeset/36722-report-chart-show-empty-groups-ui.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
'@object-ui/plugin-report': patch
'@object-ui/i18n': patch
---

feat(plugin-report): the report chart honours `chart.showEmptyGroups`, and the report builder offers it as a switch

Clause-②: yes (widening)
Metadata-protocol: added

- On a chart with a category axis (bar, column, horizontal-bar, line, area, radar, combo), the dataset report chart adds the `xAxis` field's declared options that the answer left out when `chart.showEmptyGroups` is on: in their declared place, with the option's label and colour, valued `0` for a count or sum and left empty for avg/min/max. With a `seriesBy` split an added option reads the empty value in every series. Whether an option is missing is judged by the stored value the answer's `drillRawRows` carries wherever the answer has it, so a label the server translated differently is not drawn as a second, zero-valued group; a row with no raw value falls back to matching the option's spellings. A value-sized chart (pie, donut, funnel, treemap, sankey) and scatter get nothing added. Nothing is added for a field with no declared options, when the report's `order` reaches the chart's query, or on an answer with no rows. A bar on an added option opens no record list.
- The report builder's chart settings gain a "Show groups with no records" switch on the category-axis charts (bar and line among the builder's choices, and a stored column, area or other category-axis type). It writes `chart.showEmptyGroups: true`; off removes the key. An edit keeps an authored key on every series chart type, the donut included, and only a single-value or table chart drops it.
- `@object-ui/i18n`: `report.builder.chart.showEmptyGroups` in all 11 locales.
- `@object-ui/plugin-report` now lists `@objectstack/spec` under `dependencies` (it was a dev dependency): the chart reads the analytics executor's empty-group values from `@objectstack/spec/data` at runtime.
12 changes: 12 additions & 0 deletions .changeset/36722-report-chart-show-empty-groups.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@objectstack/spec': minor
---

feat(spec): `chart.showEmptyGroups` on a report chart — show the declared options that have no records

Clause-②: yes (widening)
Metadata-protocol: added

- `ReportChartSchema` gains an optional boolean `showEmptyGroups`. A grouped query returns only the values that have rows, so a select option no record carries was missing from a report chart rather than drawn at zero. With `showEmptyGroups: true` the report renderer adds every declared option of the `xAxis` field the answer left out, valued the way the analytics executor values any empty group (`emptyGroupValueFor`: `0` for count and sum, empty for avg/min/max).
- Optional with no default: a report that does not set it parses exactly as before and its chart draws exactly the groups the query returned. A non-boolean value is refused at `chart.showEmptyGroups`.
- Acts on a chart with a category axis (bar, column, horizontal-bar, line, area, radar, combo); a chart that sizes its marks by value (pie, donut, funnel, treemap, sankey) and scatter get nothing added, and on a single-value or table chart the key has no effect. Only a field that declares its options is filled. Nothing is added when the report's `order` reaches the chart, and an answer with no rows at all still draws no chart. A date axis needs no switch: the executor already returns every bucket of the report's period.
2 changes: 2 additions & 0 deletions content/docs/references/ui/report.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const result = JoinedReportBlockSchema.parse(data);
| **interaction** | `{ tooltips?: boolean; brush?: boolean }` | optional | Interaction toggles: `{ tooltips?, brush? }` |
| **aria** | `never` | optional | [REMOVED] `ChartConfig.aria` — authored as `dashboard.widgets[].chartConfig.aria`, `report.chart.aria` and `report.blocks[].chart.aria` — was removed in @objectstack/spec 17 (ADR-0049 D2). No chart renderer ever applied it: the chart implementation declares no `aria` prop, the presentation lowering names it nowhere, and the react `<ObjectChart>` block never published it, so ARIA attributes declared here parsed and then silently did not reach the DOM. Delete the key. The accessible name that IS applied on this same chart config is its sibling `description`, which the chart renderer lowers onto the chart graphic as `role="img"` plus `aria-label`. The shared `AriaProps` shape is NOT gone — `ariaLabel` / `ariaDescribedBy` / `role` stay live in the `aria` block on `page.aria`, `page.components[].aria` and the list view `aria`. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. |
| **seriesBy** | `string` | optional | Dataset dimension name that splits the yAxis measure into one series per value of it (bound-dataset dimension, not a raw field); with it set, `series[].name` names a value of this dimension. Refused on a single-series type (pie/donut/funnel/treemap/sankey) and when it names the xAxis dimension |
| **showEmptyGroups** | `boolean` | optional | Show the declared options of the xAxis dimension field that have no records, valued 0 for a count or sum (left empty for avg/min/max), on a chart with a category axis (bar, column, horizontal-bar, line, area, radar, combo); nothing is added on any other chart type. Only a field that declares its options is filled; nothing is added when the report's order reaches the chart, and an answer with no rows still draws no chart; omitted = off |

### Nested Shape: `Report.dateRange`

Expand Down Expand Up @@ -177,6 +178,7 @@ const result = JoinedReportBlockSchema.parse(data);
| **interaction** | `{ tooltips?: boolean; brush?: boolean }` | optional | Interaction toggles: `{ tooltips?, brush? }` |
| **aria** | `never` | optional | [REMOVED] `ChartConfig.aria` — authored as `dashboard.widgets[].chartConfig.aria`, `report.chart.aria` and `report.blocks[].chart.aria` — was removed in @objectstack/spec 17 (ADR-0049 D2). No chart renderer ever applied it: the chart implementation declares no `aria` prop, the presentation lowering names it nowhere, and the react `<ObjectChart>` block never published it, so ARIA attributes declared here parsed and then silently did not reach the DOM. Delete the key. The accessible name that IS applied on this same chart config is its sibling `description`, which the chart renderer lowers onto the chart graphic as `role="img"` plus `aria-label`. The shared `AriaProps` shape is NOT gone — `ariaLabel` / `ariaDescribedBy` / `role` stay live in the `aria` block on `page.aria`, `page.components[].aria` and the list view `aria`. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. |
| **seriesBy** | `string` | optional | Dataset dimension name that splits the yAxis measure into one series per value of it (bound-dataset dimension, not a raw field); with it set, `series[].name` names a value of this dimension. Refused on a single-series type (pie/donut/funnel/treemap/sankey) and when it names the xAxis dimension |
| **showEmptyGroups** | `boolean` | optional | Show the declared options of the xAxis dimension field that have no records, valued 0 for a count or sum (left empty for avg/min/max), on a chart with a category axis (bar, column, horizontal-bar, line, area, radar, combo); nothing is added on any other chart type. Only a field that declares its options is filled; nothing is added when the report's order reaches the chart, and an answer with no rows still draws no chart; omitted = off |

### Allowed Values: `ReportChart.type`

Expand Down
15 changes: 15 additions & 0 deletions content/docs/ui/reports.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,21 @@ export const HoursByStatusChartReport = defineReport({
});
```

**`showEmptyGroups: true`** shows the groups that hold no records. A grouped query returns only
the values that have rows, so a status no task carries is missing from the chart rather than
drawn at zero. With the switch on, every declared option of the `xAxis` field that the answer
left out appears; an empty one reads `0` for a count or sum and stays empty for an average,
minimum or maximum. An option the report's own filter excludes reads as empty too. Only a field
that declares its options (a select) is filled. Nothing is added when the report's `order`
reaches the chart, and an answer with no rows at all still draws no chart. A date axis needs no
switch: every bucket of the report's period already appears. The switch acts on the charts with
a category axis (bar, column, horizontal bar, line, area, radar, combo), where an empty group is
a category at zero. A pie, donut, funnel, treemap or sankey sizes its marks by value and would
draw a zero group as nothing, and a scatter takes no select axis, so nothing is added there; on a
number or a table the key has no effect. The report builder shows the switch on the category-axis
charts grouped by something other than a date, and keeps an authored one when the chart type
changes to another series chart.

## Period and export

A non-`joined` report can declare the period it covers and how its table is downloaded.
Expand Down
1 change: 1 addition & 0 deletions packages/spec/authorable-surface/ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,7 @@
"ui/ReportChart:series",
"ui/ReportChart:seriesBy",
"ui/ReportChart:showDataLabels",
"ui/ReportChart:showEmptyGroups",
"ui/ReportChart:showLegend",
"ui/ReportChart:subtitle",
"ui/ReportChart:title",
Expand Down
7 changes: 7 additions & 0 deletions packages/spec/liveness/report.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@
"evidenceScope": "in-repo",
"evidence": "ui/packages/plugin-report/src/DatasetReportRenderer.tsx#DatasetReportChart (reads `chart.seriesBy`, queries `[xAxis, seriesBy]` × `[yAxis]` and pivots the rows through `buildChartSeries` into one series per value); ui/packages/plugin-report/src/__tests__/DatasetReportRenderer.chartSeriesBy-28206.test.tsx; packages/lint/src/validate-chart-bindings.ts#validateChartBindings (resolves it against the report's bound dataset dimensions exactly as `xAxis`, `chart-dimension-unknown` at error, at os validate / os build and the report publish door)",
"note": "The report chart series split (#27974 spec half, #28206 renderer half): a second dataset dimension that splits the one `yAxis` measure into a series per value, the report's spelling of a dashboard widget's two-entry `dimensions` selection. LIVE: DatasetReportChart widens its own query to `[xAxis, seriesBy]` × `[yAxis]` and hands both dimensions to `buildChartSeries` (ui/packages/core/src/utils/chart-series.ts), whose pivot branch draws one row per x bucket and one series per `seriesBy` value, the null group included; the series follow the split dimension's declared option order, and a `series[]` entry whose `name` is a split value lands its presentation on that series. Without `seriesBy` the chart queries and draws exactly what it did before. The other children of `chart` inherit the row's `live` verdict through `childrenDefault`; this row stays to carry the reader as evidence."
},
"showEmptyGroups": {
"status": "live",
"verifiedAt": "2026-11-28",
"evidenceScope": "in-repo",
"evidence": "ui/packages/plugin-report/src/emptyOptionGroups.ts#fillEmptyOptionGroups (adds the declared options of the `xAxis` field the answer left out, valued by `emptyGroupValueFor`); ui/packages/plugin-report/src/DatasetReportRenderer.tsx#DatasetReportChart (calls it when `chart.showEmptyGroups === true`, no `order` reaches the chart and `chartDrawsEmptyGroups(chart.type)`); ui/packages/plugin-report/src/__tests__/emptyOptionGroups.test.ts; ui/packages/plugin-report/src/__tests__/DatasetReportRenderer.test.tsx (describe `chart.showEmptyGroups`)",
"note": "The report chart's show-the-groups-with-no-records switch (#36722). LIVE: with it on, DatasetReportChart adds every declared option of the x-axis dimension's field that no answer row carries, judged by the stored value `drillRawRows` states (spellings only for a row without one), appended after the answer's rows so the drill still addresses them by index; count and sum read 0, avg/min/max and a derived measure stay empty. Filled only on a chart type with a category axis (bar, column, horizontal-bar, line, area, radar, combo; `chartDrawsEmptyGroups`), never on a value-sized chart (pie, donut, funnel, treemap, sankey) or scatter. Not filled when the field declares no options, when the report's `order` reaches the chart, or on an answer with no rows. The report builder offers it on the category-axis types and keeps an authored key on every series type. Off or absent, the chart draws exactly the groups the query returned. The other children of `chart` inherit `live` through `childrenDefault`; this row stays to carry the reader as evidence."
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/spec/liveness/state-counts/report.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ committed anywhere: `check:liveness` sums the shards when it reads them.

| Type | live | exp | elsewhere | dead | planned | classified |
|---|---|---|---|---|---|---|
| `report` | 40 | 0 | 0 | 1 | 2 | 43 |
| `report` | 41 | 0 | 0 | 1 | 2 | 44 |
23 changes: 23 additions & 0 deletions packages/spec/src/ui/report.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,29 @@ describe('ReportChartSchema', () => {
expect(r.success).toBe(false);
expect(r.error?.issues.map((i) => i.path.join('.'))).toContain('seriesBy');
});

// objectstack#36722 — "show groups with no records". Optional with NO
// default: an existing report parses to exactly the bytes it parsed to
// before, so the switch is off by being absent.
it('`showEmptyGroups` is optional and off by default — absent stays absent', () => {
const parsed = ReportChartSchema.parse({ type: 'bar', xAxis: 'stage', yAxis: 'count' });
expect('showEmptyGroups' in parsed).toBe(false);
const on = ReportChartSchema.safeParse({ type: 'bar', xAxis: 'stage', yAxis: 'count', showEmptyGroups: true });
expect(on.success).toBe(true);
expect(on.data?.showEmptyGroups).toBe(true);
const report = ReportSchema.parse({
name: 'deals_by_stage', label: 'Deals by stage', type: 'summary',
dataset: 'deals', rows: ['stage'], values: ['count'],
chart: { type: 'bar', xAxis: 'stage', yAxis: 'count', showEmptyGroups: true },
});
expect(report.chart?.showEmptyGroups).toBe(true);
});

it('refuses a non-boolean `showEmptyGroups`', () => {
const r = ReportChartSchema.safeParse({ type: 'bar', xAxis: 'stage', yAxis: 'count', showEmptyGroups: 'yes' });
expect(r.success).toBe(false);
expect(r.error?.issues.map((i) => i.path.join('.'))).toContain('showEmptyGroups');
});
});

/**
Expand Down
36 changes: 36 additions & 0 deletions packages/spec/src/ui/report.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,42 @@ export const ReportChartSchema = lazySchema(() => ChartConfigSchema.extend({
+ '(bound-dataset dimension, not a raw field); with it set, `series[].name` names a value of this dimension. '
+ 'Refused on a single-series type (' + SINGLE_SERIES_CHART_TYPES.join('/') + ') and when it names the xAxis dimension',
),
/**
* Show the groups that hold no records. A grouped query answers one row per
* value that HOLDS rows, so a stage with no deals is absent from a
* "deals by stage" chart rather than reading as zero. With this on, the
* report renderer adds every DECLARED option of the `xAxis` dimension's
* field that the answer left out, valued the way the analytics
* executor values any empty group (`emptyGroupValueFor`: `0` for count and
* sum, empty for avg/min/max). A derived measure states no aggregate, so an
* added group carries no value for it.
*
* Acts only on a chart type that lays its groups out on a category axis
* (`bar`, `column`, `horizontal-bar`, `line`, `area`, `radar`, `combo`), where
* an added group is a category at zero. A chart that sizes its marks by value
* (`pie`, `donut`, `funnel`, `treemap`, `sankey`) would draw a zero group as
* nothing, and `scatter` takes no select axis, so nothing is added there; on a
* single-value or table type the key is accepted and has no effect, as
* `showLegend` is.
*
* Only a dimension whose field declares its options is filled (a select or
* similar); a free-text or lookup dimension has no known set of values. Not
* filled when the report's `order` reaches the chart: an added group has no
* place in an authored order, and under a measure order it would compete for
* a place it did not earn. An answer with no rows at all still draws no
* chart: the options are filled around the groups an answer holds. An option
* the report's own filter excludes reads as empty like any other. A date axis
* needs no switch: the executor already fills every bucket of the report's
* period. Omitted = off, and the chart draws exactly the groups the query
* returned.
*/
showEmptyGroups: z.boolean().optional().describe(
'Show the declared options of the xAxis dimension field that have no records, valued 0 for a count or sum '
+ '(left empty for avg/min/max), on a chart with a category axis (bar, column, horizontal-bar, line, area, '
+ 'radar, combo); nothing is added on any other chart type. Only a field that declares its options is filled; '
+ "nothing is added when the report's order reaches the chart, and an answer with no rows still draws no chart; "
+ 'omitted = off',
),
}));

/**
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4469,6 +4469,7 @@ const ar = {
metric: "رقم",
table: "جدول",
showValues: "إظهار القيم",
showEmptyGroups: "إظهار المجموعات التي لا تحتوي على سجلات",
targetLine: "خط الهدف",
targetLabel: "الهدف",
secondLayerTableOnly: "يرسم هذا المخطط التجميع الأول؛ أما الثاني ففي القيم المحسوبة.",
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4119,6 +4119,7 @@ const de = {
metric: "Zahl",
table: "Tabelle",
showValues: "Werte anzeigen",
showEmptyGroups: "Gruppen ohne Datensätze anzeigen",
targetLine: "Ziellinie",
targetLabel: "Ziel",
secondLayerTableOnly: "Dieses Diagramm zeigt die erste Gruppierung; die zweite steht in den berechneten Werten.",
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2290,6 +2290,7 @@ const en = {
metric: 'Number',
table: 'Table',
showValues: 'Show values',
showEmptyGroups: 'Show groups with no records',
targetLine: 'Target line',
targetLabel: 'Target',
secondLayerTableOnly: 'This chart draws the first grouping; the second is in the computed values.',
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4207,6 +4207,7 @@ const es = {
metric: "Número",
table: "Tabla",
showValues: "Mostrar valores",
showEmptyGroups: "Mostrar grupos sin registros",
targetLine: "Línea objetivo",
targetLabel: "Objetivo",
secondLayerTableOnly: "Este gráfico dibuja la primera agrupación; la segunda está en los valores calculados.",
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4203,6 +4203,7 @@ const fr = {
metric: "Nombre",
table: "Tableau",
showValues: "Afficher les valeurs",
showEmptyGroups: "Afficher les groupes sans enregistrements",
targetLine: "Ligne d’objectif",
targetLabel: "Objectif",
secondLayerTableOnly: "Ce graphique trace le premier regroupement ; le second figure dans les valeurs calculées.",
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4121,6 +4121,7 @@ const ja = {
metric: "数値",
table: "表",
showValues: "値を表示",
showEmptyGroups: "レコードのないグループを表示",
targetLine: "目標線",
targetLabel: "目標",
secondLayerTableOnly: "このグラフは最初のグループ化のみを描画します。2 つ目は計算値にあります。",
Expand Down
Loading
Loading