Skip to content

Commit a56e1da

Browse files
feat(spec,plugin-report): report chart showEmptyGroups — show the declared options that have no records (#38284)
repo:objectstack#3 · os-tesla · session_01L9qibyFBwGSJLARjP5asi3 <!-- claude-projects-attribution: {"github_login":"os-tesla"} --> _Requested by **Tesla** · [project thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoBV4bujns7CcBKes5NFE274)_ Fixes #36722 repo:objectstack#3 · os-tesla · session_01L9qibyUSf2nKJWW6qBemSU Clause-②: yes (widening) Metadata-protocol: added Skills-docs: none — an optional, off-by-default presentation switch; the skill's report block teaches the chart's data keys (`xAxis`, `yAxis`, `seriesBy`), and the chart chrome beside it (`showLegend`, `showDataLabels`) is not taught there either ## 维护者速读 - 报表图表多了一个开关「显示数量为 0 的分组」:打开后,选项字段(比如商机阶段)里没有记录的选项也画出来,计数和求和显示 0,平均值留空;不打开时和以前完全一样。 - 解决的是「按阶段看商机」这类图里,空阶段直接消失、看起来像不存在的问题;按日期分组的图本来就会补齐空月份,不需要这个开关。 - 只在有分类轴的图上生效(柱状、条形、折线、面积、雷达、组合);饼图、环形图、漏斗、树图、桑基图按数值定大小,0 分组画不出来,所以这些图上不补、构建器也不给这个开关。 - 只改图表的画法,不改查询和数据;有问题最多是图上多画或少画了空分组,关掉开关即可。 - 无 ## What changes - `packages/spec/src/ui/report.zod.ts`: `ReportChartSchema` gains `showEmptyGroups: z.boolean().optional()`, no default. A report that does not set it parses exactly as before. The TSDoc and the `.describe()` state every case the switch adds nothing in: a field with no declared options, an `order` that reaches the chart, and an answer with no rows (it still draws no chart). They also say that a derived measure stays empty and that an option the report's own filter excludes reads as empty. Since review round 2 (S4) they name the chart families: the switch acts on the charts with a category axis (bar, column, horizontal-bar, line, area, radar, combo); a pie, donut, funnel, treemap or sankey sizes its marks by value and gets nothing added, a scatter takes no select axis, and on a single-value or table type the key is accepted and has no effect. Generated: the report reference page, the authorable surface (`ui/ReportChart:showEmptyGroups`) and the report liveness counts. - `packages/spec/liveness/report.json` (claim amendment 3): the key's own `live` row under `chart.children` (review nit N1), citing `fillEmptyOptionGroups`, `chartDrawsEmptyGroups`, `DatasetReportChart` and their tests, beside the `seriesBy` row; its note names the families. - `ui/packages/plugin-report/src/emptyOptionGroups.ts` (new): `fillEmptyOptionGroups(rows, fill)` adds one row for each declared option of the `xAxis` field that no answer row carries. An added row carries the stored value, so relabelling, declared order and option colours treat it like a real group. Its measure cells are `emptyGroupValueFor(aggregate)` from `@objectstack/spec/data`, the table the analytics executor fills its own empty groups with: `0` for count and sum, no value for avg/min/max. With `seriesBy` an added option gets one row per series value in the answer. Added rows are appended, so every index below the answer's length still addresses the answer. Whether an option is missing is judged by the stored value the answer's `drillRawRows` carries (index-aligned with the rows): a row whose raw twin states the x-axis value is matched by that value alone, so a label the server translated at the request locale never reads as a second, zero-valued group. Only a row with no raw twin falls back to spellings (stored value, authored label, localized label). The same module exports `chartDrawsEmptyGroups(type)`, the one predicate for "this chart type can draw an empty group": bar, column, horizontal-bar, line, area, radar, combo. The renderer and the builder both read it. - `ui/packages/plugin-report/src/DatasetReportRenderer.tsx`: the report chart calls the fill when `chart.showEmptyGroups === true`, no `order` reaches the chart's selection and `chartDrawsEmptyGroups(chart.type)` holds, before relabelling and the declared-order arrangement, and hands it `state.drillRawRows`. A mark on an added group opens no record list. This is plugin-report's first runtime import of `@objectstack/spec`, so the package moves it from `devDependencies` to `dependencies` (`check:undeclared-dep-imports`). The library build externalizes every bare specifier, so the bundle does not grow, and plugin-dashboard already depends on `@objectstack/spec` and imports `@objectstack/spec/data` at runtime. No ui/ import rule refuses it. - `ui/packages/plugin-report/src/builder/`: the report builder shows a "Show groups with no records" switch only where the renderer fills (`chartDrawsEmptyGroups`: bar and line among the builder's own choices, a stored column, area, radar or combo too), and not over a date axis (`offersShowEmptyGroups`; every bucket of the period already appears). It saves `chart.showEmptyGroups: true` and turning it off removes the key. An edit keeps an authored key on every type the renderer plots as a series (`planReportChart`'s 13 series types, so a donut or a stored funnel does not lose it, S2); only a single-value or tabular type drops it. One new locale key, `report.builder.chart.showEmptyGroups`, in all 11 packs. - Docs (claim amendment 1): an "embedded chart" paragraph in `content/docs/ui/reports.mdx` and a README note in plugin-report, both naming the no-fill cases and the chart families. - Changesets: `@objectstack/spec` minor; `@object-ui/plugin-report`, `@object-ui/i18n` patch. Not changed: the analytics executor and the dataset query (route B of the pre-claim report is not built), the table under the chart, HotCRM. ## Why A grouped dataset query answers one row per value that holds rows, so a select option no record carries is absent from the answer. A "deals by stage" bar chart then has no bar for an empty stage, and the stage reads as not existing rather than as zero. The issue's date half already holds on `main`: the executor fills every bucket of a report's period (#26893), so a date axis needs no switch. ## Tests - `emptyOptionGroups.test.ts` (new, 10 cases): presence by the raw twin's stored value (a server label the client does not know is still present, with the no-raw-twin control drawing the false zero; a raw value overrules a display spelling another option carries; a row without a raw twin falls back to spellings); presence by value, label and localized label; count and sum at 0, avg with no value; one row per series value, the null series included; duplicate declarations added once; the input array returned when nothing is missing. - `DatasetReportRenderer.test.tsx`, a new top-level `describe` in the shared harness (9 cases): count fill in declared order at 0; a group the server labelled "Gewonnen" whose raw twin is `closed_won` is recognised, so no "Closed Won" at 0 is added; sum at 0 and avg empty; `seriesBy` at 0 in every series; a mark on an added stage opens no list and a real one still drills; the selection sent is identical with the switch on and off; CONTROLS that add nothing: switch off, a measure `order`, a text field with no declared options, and (S4) every value-sized type: pie, donut, funnel, treemap, sankey; a category-axis type the builder does not offer itself (area, column) is filled like a bar. - `DatasetReportRenderer.dateRange-25873.test.tsx`, a new `describe`: a date axis over a period sends the same selection and draws the same buckets, the empty month included, with the switch on and off. - `reportBuilder-36374.test.tsx`, a new `describe`: the switch saves, parses as a valid report, reopens checked, and off removes the key; it is offered on bar and line, hidden on a donut (which keeps the key) and on a number; the model keeps it across edits and drops it on metric and table; a stored funnel keeps it across a measure and a grouping edit and offers no switch, a stored gauge drops it; a date axis shows no switch and the model keeps an authored key there; and over the whole `ChartTypeSchema` vocabulary the key is kept on exactly the types `planReportChart` plans as a series and offered on exactly `chartDrawsEmptyGroups`, which is pinned to area, bar, column, combo, horizontal-bar, line, radar. - `packages/spec/src/ui/report.test.ts`: absent stays absent, and a non-boolean is refused at `showEmptyGroups`. ## Acceptance notes - Deviation from the claim's no-fill list. The claim said "not when truncated, sorted by a measure". (1) The chart's selection never sends `limit` or `offset`, and the dataset answer carries no truncation signal, so a truncated chart answer does not occur on this path; there is nothing to test. (2) The fill declines under ANY `order` that reaches the chart, a dimension order included, not only a measure order. Appended rows have no place in an authored order, and the declared-option arrangement is already off under an order. This narrows when the switch acts; it refuses nothing. - A report whose answer has zero rows still draws no chart, as before: the switch fills categories around an answer, it does not invent a chart from nothing. The TSDoc, the `.describe()`, the reports page and the README now say so. - The key is chart-only. The table rendered under the chart is not filled. - Review N3 (switch shown where it changes nothing): carried by round 2. A date axis now hides the switch. Two cases still show it, because the builder does not read a dimension's declared options or the report's order scoping: a text or lookup axis (no declared options) and a report whose `order` reaches the chart. On both the renderer adds nothing, as the contract states. ## Verification - Two-minute check: `pnpm --dir ui exec vitest run packages/plugin-report/src/__tests__/emptyOptionGroups.test.ts packages/plugin-report/src/__tests__/DatasetReportRenderer.test.tsx` passes, the new blocks included. - Read first: `fillEmptyOptionGroups` (`emptyOptionGroups.ts`), then the `chartRows` line in `DatasetReportChart` (`DatasetReportRenderer.tsx`). <details><summary>Local readings at 2ac50c0</summary> - Fill per aggregate (renderer, through the real chart props): count, an empty declared stage reads `0` at its declared place; sum reads `0`; avg has no value at the added stage (nothing to average). - No-fill controls, each with the switch on: switch off adds nothing; a measure `order` adds nothing; a text field with no declared options adds nothing. The selection sent to the dataset is identical with the switch on and off. - Date-bucket pin: a date axis over a period, switch on and off, sends the same selection and draws the same buckets, the 0 month included. - Round 2 (S4) ablations at 2ac50c0 through `scripts/ablation-replace.mjs`, restore blob == HEAD: the renderer's `chartDrawsEmptyGroups(chart.type)` bound removed, 1 failed / 69 passed in the renderer suite (the value-sized CONTROL); the builder's offer predicate widened back to every series type, 3 failed / 107 passed in the builder suite (the donut, stored-funnel and vocabulary pins). - Earlier ablations, each restore blob == HEAD: the fill condition forced false (at 6508986), 4 failed / 111 passed across the four touched suites, the four failures being the fill cases (count, sum/avg, seriesBy, drill), with the controls and the date pin green; the raw-twin branch disabled (at 0d03b6f), 3 failed / 104 passed, the three stored-value pins; the builder's switch set put back to bar/line/donut, 2 failed / 105 passed, the stored-funnel pin and the `planReportChart` parity pin. - Suites at 2ac50c0: `emptyOptionGroups`, `DatasetReportRenderer`, `reportBuilder-36374` 110 passed; `pnpm -s type-check` in `@object-ui/plugin-report` exit 0; `check:generated` and `check:liveness` exit 0 after regenerating the report reference page. - Suites at 1c290e5: `emptyOptionGroups`, `DatasetReportRenderer`, `reportBuilder-36374` 107 passed, `DatasetReportRenderer.dateRange-25873` and `report-spec-parity` green (5 files, 134 passed at 0d03b6f); at 86c2dbe the four touched files 115 passed and `pnpm --dir ui exec vitest run packages/plugin-report packages/i18n` 149 files, 2292 passed, 20 skipped. `packages/spec` `src/ui/report.test.ts` 83 passed. - Typecheck: `@object-ui/plugin-report` `type-check` exit 0 at 1c290e5, after building its dependencies' declarations. CI's Type Check UI was red at a9c6b54 on one new test line (TS2339, `chart?.type` read off `{}`), reproduced locally and fixed in 1c290e5. - Browser at 86c2dbe (showcase, `objectstack dev --fresh` plus the console on vite, Playwright): on the local fresh database the two Backlog tasks were moved to To Do, so the `status` option Backlog holds no records. "Hours by Status (Chart)" drew To Do, In Progress, In Review, Done. In the report builder the "Show groups with no records" switch sits under "Show values". Switched on, the preview drew Backlog, To Do, In Progress, In Review, Done, with Backlog first (declared order) at no height. The switch is hidden on Number, and coming back to Bar it is off (the metric drops the key). Save sent `PUT /api/v1/meta/report/showcase_hours_by_status_chart` with `chart.showEmptyGroups: true`, then publish. The reloaded report view drew the five statuses, and the builder reopened with the switch on. - `dispatch-gates --ran` with recorded exit codes, swept at 2ac50c0: 126 derived, 125 run exit 0, 1 NOT MEASURED (exit 3: `check-plugin-teardown-shape --self-test`, fixture commit outside the shallow clone), 0 unrun. - Earlier sweep at a9c6b54/1c290e5b: 126 derived, 125 run exit 0, 1 NOT MEASURED (exit 3: `check-plugin-teardown-shape --self-test`, fixture commit outside the shallow clone), 0 unrun. `check:dts-closure` and `check:dual-build-cjs-loads` first exited 1 on an incomplete local dist (no declarations for `service-cluster`, missing `platform-objects` files), packages this diff does not touch; both exit 0 after rebuilding those packages. The first sweep at 6508986 found one real red, `check:undeclared-dep-imports` (`@objectstack/spec` was a dev dependency), fixed in 86c2dbe. - PR CI at 2ac50c0: 73 check-runs, 64 success, 9 skipped, 0 failure (at 1c290e5 the same). - `overlap-check.mjs` VERDICT clean exit 0 at 2ac50c0 against main and #38307, #38192 (all merge cleanly). </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01L9qibyFBwGSJLARjP5asi3)_ <!-- signed: repo:objectstack#3 · os-tesla · session_01L9qibyFBwGSJLARjP5asi3 --> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L9qibyFBwGSJLARjP5asi3 --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2478f8e commit a56e1da

31 files changed

Lines changed: 900 additions & 12 deletions
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@object-ui/plugin-report': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
feat(plugin-report): the report chart honours `chart.showEmptyGroups`, and the report builder offers it as a switch
7+
8+
Clause-②: yes (widening)
9+
Metadata-protocol: added
10+
11+
- 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.
12+
- 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.
13+
- `@object-ui/i18n`: `report.builder.chart.showEmptyGroups` in all 11 locales.
14+
- `@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.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/spec': minor
3+
---
4+
5+
feat(spec): `chart.showEmptyGroups` on a report chart — show the declared options that have no records
6+
7+
Clause-②: yes (widening)
8+
Metadata-protocol: added
9+
10+
- `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).
11+
- 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`.
12+
- 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.

‎content/docs/references/ui/report.mdx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ const result = JoinedReportBlockSchema.parse(data);
106106
| **interaction** | `{ tooltips?: boolean; brush?: boolean }` | optional | Interaction toggles: `{ tooltips?, brush? }` |
107107
| **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. |
108108
| **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 |
109+
| **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 |
109110

110111
### Nested Shape: `Report.dateRange`
111112

@@ -177,6 +178,7 @@ const result = JoinedReportBlockSchema.parse(data);
177178
| **interaction** | `{ tooltips?: boolean; brush?: boolean }` | optional | Interaction toggles: `{ tooltips?, brush? }` |
178179
| **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. |
179180
| **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 |
181+
| **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 |
180182

181183
### Allowed Values: `ReportChart.type`
182184

‎content/docs/ui/reports.mdx‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,21 @@ export const HoursByStatusChartReport = defineReport({
210210
});
211211
```
212212

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

215230
A non-`joined` report can declare the period it covers and how its table is downloaded.

‎packages/spec/authorable-surface/ui.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,7 @@
13451345
"ui/ReportChart:series",
13461346
"ui/ReportChart:seriesBy",
13471347
"ui/ReportChart:showDataLabels",
1348+
"ui/ReportChart:showEmptyGroups",
13481349
"ui/ReportChart:showLegend",
13491350
"ui/ReportChart:subtitle",
13501351
"ui/ReportChart:title",

‎packages/spec/liveness/report.json‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@
6565
"evidenceScope": "in-repo",
6666
"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)",
6767
"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."
68+
},
69+
"showEmptyGroups": {
70+
"status": "live",
71+
"verifiedAt": "2026-11-28",
72+
"evidenceScope": "in-repo",
73+
"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`)",
74+
"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."
6875
}
6976
}
7077
},

‎packages/spec/liveness/state-counts/report.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ committed anywhere: `check:liveness` sums the shards when it reads them.
1212

1313
| Type | live | exp | elsewhere | dead | planned | classified |
1414
|---|---|---|---|---|---|---|
15-
| `report` | 40 | 0 | 0 | 1 | 2 | 43 |
15+
| `report` | 41 | 0 | 0 | 1 | 2 | 44 |

‎packages/spec/src/ui/report.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,29 @@ describe('ReportChartSchema', () => {
581581
expect(r.success).toBe(false);
582582
expect(r.error?.issues.map((i) => i.path.join('.'))).toContain('seriesBy');
583583
});
584+
585+
// objectstack#36722 — "show groups with no records". Optional with NO
586+
// default: an existing report parses to exactly the bytes it parsed to
587+
// before, so the switch is off by being absent.
588+
it('`showEmptyGroups` is optional and off by default — absent stays absent', () => {
589+
const parsed = ReportChartSchema.parse({ type: 'bar', xAxis: 'stage', yAxis: 'count' });
590+
expect('showEmptyGroups' in parsed).toBe(false);
591+
const on = ReportChartSchema.safeParse({ type: 'bar', xAxis: 'stage', yAxis: 'count', showEmptyGroups: true });
592+
expect(on.success).toBe(true);
593+
expect(on.data?.showEmptyGroups).toBe(true);
594+
const report = ReportSchema.parse({
595+
name: 'deals_by_stage', label: 'Deals by stage', type: 'summary',
596+
dataset: 'deals', rows: ['stage'], values: ['count'],
597+
chart: { type: 'bar', xAxis: 'stage', yAxis: 'count', showEmptyGroups: true },
598+
});
599+
expect(report.chart?.showEmptyGroups).toBe(true);
600+
});
601+
602+
it('refuses a non-boolean `showEmptyGroups`', () => {
603+
const r = ReportChartSchema.safeParse({ type: 'bar', xAxis: 'stage', yAxis: 'count', showEmptyGroups: 'yes' });
604+
expect(r.success).toBe(false);
605+
expect(r.error?.issues.map((i) => i.path.join('.'))).toContain('showEmptyGroups');
606+
});
584607
});
585608

586609
/**

‎packages/spec/src/ui/report.zod.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,42 @@ export const ReportChartSchema = lazySchema(() => ChartConfigSchema.extend({
5656
+ '(bound-dataset dimension, not a raw field); with it set, `series[].name` names a value of this dimension. '
5757
+ 'Refused on a single-series type (' + SINGLE_SERIES_CHART_TYPES.join('/') + ') and when it names the xAxis dimension',
5858
),
59+
/**
60+
* Show the groups that hold no records. A grouped query answers one row per
61+
* value that HOLDS rows, so a stage with no deals is absent from a
62+
* "deals by stage" chart rather than reading as zero. With this on, the
63+
* report renderer adds every DECLARED option of the `xAxis` dimension's
64+
* field that the answer left out, valued the way the analytics
65+
* executor values any empty group (`emptyGroupValueFor`: `0` for count and
66+
* sum, empty for avg/min/max). A derived measure states no aggregate, so an
67+
* added group carries no value for it.
68+
*
69+
* Acts only on a chart type that lays its groups out on a category axis
70+
* (`bar`, `column`, `horizontal-bar`, `line`, `area`, `radar`, `combo`), where
71+
* an added group is a category at zero. A chart that sizes its marks by value
72+
* (`pie`, `donut`, `funnel`, `treemap`, `sankey`) would draw a zero group as
73+
* nothing, and `scatter` takes no select axis, so nothing is added there; on a
74+
* single-value or table type the key is accepted and has no effect, as
75+
* `showLegend` is.
76+
*
77+
* Only a dimension whose field declares its options is filled (a select or
78+
* similar); a free-text or lookup dimension has no known set of values. Not
79+
* filled when the report's `order` reaches the chart: an added group has no
80+
* place in an authored order, and under a measure order it would compete for
81+
* a place it did not earn. An answer with no rows at all still draws no
82+
* chart: the options are filled around the groups an answer holds. An option
83+
* the report's own filter excludes reads as empty like any other. A date axis
84+
* needs no switch: the executor already fills every bucket of the report's
85+
* period. Omitted = off, and the chart draws exactly the groups the query
86+
* returned.
87+
*/
88+
showEmptyGroups: z.boolean().optional().describe(
89+
'Show the declared options of the xAxis dimension field that have no records, valued 0 for a count or sum '
90+
+ '(left empty for avg/min/max), on a chart with a category axis (bar, column, horizontal-bar, line, area, '
91+
+ 'radar, combo); nothing is added on any other chart type. Only a field that declares its options is filled; '
92+
+ "nothing is added when the report's order reaches the chart, and an answer with no rows still draws no chart; "
93+
+ 'omitted = off',
94+
),
5995
}));
6096

6197
/**

‎pnpm-lock.yaml‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)