Repository navigation
Commit a56e1da
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
File tree
- .changeset
- content/docs
- references/ui
- ui
- packages/spec
- authorable-surface
- liveness
- state-counts
- src/ui
- ui/packages
- i18n/src/locales
- plugin-report
- src
- __tests__
- builder
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| |||
177 | 178 | | |
178 | 179 | | |
179 | 180 | | |
| 181 | + | |
180 | 182 | | |
181 | 183 | | |
182 | 184 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
213 | 228 | | |
214 | 229 | | |
215 | 230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1345 | 1345 | | |
1346 | 1346 | | |
1347 | 1347 | | |
| 1348 | + | |
1348 | 1349 | | |
1349 | 1350 | | |
1350 | 1351 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
68 | 75 | | |
69 | 76 | | |
70 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
581 | 581 | | |
582 | 582 | | |
583 | 583 | | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
584 | 607 | | |
585 | 608 | | |
586 | 609 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
59 | 95 | | |
60 | 96 | | |
61 | 97 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments