Repository navigation
feat(report): compare with the previous period beside a report's period chip - #36767
Conversation
…od chip
A report that declares `dateRange` now offers 「Compare with previous
period」 next to its period chip when its chart can draw one (bar,
column, horizontal bar, line, area, or a single number, no `seriesBy`
split). The switch is the viewer's, like the period pick, and is not
saved. While it is on and the period names a window, the chart's
dataset query carries `compareTo: { kind: 'previousPeriod', dimension }`
on the window's dimension; a bar or line chart draws the earlier window
as a muted `comparison` series, a single number shows the previous
value and the change. A mark of the earlier window drills nothing, and
a refused comparison is shown where the chart was.
Clause-②: yes (widening)
Metadata-protocol: none
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbYCxqr63HW2KJGpmAq
…iod chip Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbYCxqr63HW2KJGpmAq
… report page draws the period chip and Export Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbYCxqr63HW2KJGpmAq
|
repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj Contract reviewServed-tier: Face: declaration. The PR body and the changeset each carry a line-initial ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
…f days before, paired by position on a date axis The contract's `previousPeriod` is the window of the same length ending the day before the current one, which is the previous calendar period only when the two are equally long. The docs bullet and the changeset now say so, and a test pins the chart on the window's own date axis. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbYCxqr63HW2KJGpmAq
…indow's own date axis The earlier window is the same number of days just before the current one, and on the window's own date axis its buckets pair with the current ones by position: where the two windows split into a different number of buckets (a 31-day month against the 31 days before it, by month) the bars paired with the wrong period. The switch now stays on category axes and single numbers, which compare clean totals. Docs and changeset say "the same-length window just before it"; tests pin the bar and line date-axis cases as not offered. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbYCxqr63HW2KJGpmAq
|
repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj Contract reviewServed-tier: Round 2, delta read of ① Derived judgments
No must-fix, no should-fix. ② Semver levelUnchanged: ③ Boundary flags
Implemented-by: VERDICT: PASS |
|
repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj 维护者速读报表上新增「和上一期对比」开关:打开后,单个数字下面显示上一期的值和变化幅度,按类别画的柱状图、折线图多画一组浅色的上一期数据。「上一期」指本期之前同样长度的一段。横轴是本期时间轴的图不提供这个开关,因为两期切出来的格数可能不同,会对错位。开关不保存在报表里。 席位核对 — ACCEPT (L1) · repo:objectstack#1 · head
|
|
repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj Re-queue · 2026-11-23T19:22Z: the merge-queue run 45241984728 on The seat reads this as runner slowness, not this diff:
So the seat re-queues once, on the unchanged head |
Requested by Warren · project thread
Fixes #36645 — item 3 (「和上一期对比」). Item 1 shipped in #36705; item 2 moved to its own card, #36722; so this closes the card.
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
What changes
The switch (
ui/packages/plugin-report/src/ReportDateRange.tsx)ReportCompareToggle: 「Compare with previous period」 beside the period chip. Like the chip's own pick it is the viewer's state, keyed on the report'sdateRangedeclaration, never written into the report. Off, and disabled, while the period names no window (All time, or a custom range missing an end).reportChartComparable(chart, windowDimension): offered only where the chart can draw a clean comparison —bar,column,horizontal-bar,line,areaover an x axis that is NOT the window's own date dimension, or a single number (metric,kpi) — and not on aseriesBysplit (its series are values of the split dimension, so no series pairs with the measure's earlier window). Pie / donut / funnel / treemap / sankey / table are not offered it. Nothing is offered until the window's dimension is known.reportCompareTo: the selection'scompareToonly while on AND a window exists.The chart (
ui/packages/plugin-report/src/DatasetReportRenderer.tsx)useDatasetRowstakes an optionalcompareToand sends it beside the window it shifts (compareTo: { kind: 'previousPeriod', dimension: <the window's dimension> }, the existingDatasetSelection.compareTocontract); it is part of the query signature, so toggling re-queries. Only the embedded chart passes it; the table beside the chart is not asked for a comparison.<measure>__compare(the executor's column), labelled<measure> · <dashboard.trend.vsPreviousPeriod>withvariant: 'comparison', the chart's existing muted / dashed styling — the dashboard's overlay shape. The chart is compared with the same-length window just before the current one (the contract'spreviousPeriod). On a category axis the rows merge by key, so each category's earlier total sits beside its current one.formatPeriodChange, module-local; no percent when the previous value is 0).chartDrillMeasurerule for the same series); a current mark drills as before.Strings, docs, changeset
@object-ui/i18n: one key,report.dateRange.comparePrevious, in all 11 locales. The series caption reuses the dashboard'sdashboard.trend.vsPreviousPeriod.content/docs/ui/reports.mdx› Period and export: one bullet on the switch, and the stale 「Declared, not drawn yet」 callout replaced (see Acceptance notes)..changeset/36645-report-compare-previous-period.md(patch; plugin-report, i18n).No spec key, schema, export or server change.
Read first (by risk):
DatasetReportChartinDatasetReportRenderer.tsx(the series and the drill guard) ·reportChartComparable(where the switch is offered).Why
#36374 item 6 (board 49, figure 3): the time switch offers 「和上一期对比」 and the chart draws both periods. It waited on #35395 (
{current_iso_week}left unshifted by compare-to), closed 2026-11-22 by #36416. On base460af0e4the report renderer never sentcompareTo, although the analytics executor answers it.Verification
DatasetReportRenderer.comparePrevious-36645.test.tsx:pnpm --dir ui exec vitest run packages/plugin-report/src/__tests__/DatasetReportRenderer.comparePrevious-36645.test.tsx→ 15 passed atfd8a9260. Ablation at the first head:DatasetReportRenderer.tsxchecked out fromorigin/main(the newReportDateRange.tsxexports left in place) → 8 failed | 4 passed; the 4 green by design are the "not offered" cases (donut, table,seriesBy, no period), which hold on base because base offers no switch at all. Ablation of the date-axis rule atfd8a9260:ReportDateRange.tsxandDatasetReportRenderer.tsxchecked out fromccb43920(before the rule) → 2 failed | 13 passed, the two red being the new bar / line "not offered on the window's own date axis" pins. Both restored;git statusclean before each commit.pnpm --dir ui exec vitest run --maxWorkers=3 packages/plugin-report/atfd8a9260→ 38 files, 377 passed | 7 skipped.packages/i18n/(first head) → 107 files, 2006 passed | 13 skipped (key parity across the 11 locales included).react-refresh/ testanykinds).pnpm check:new-line-citations→ 0 new.@object-ui/*declarations this container did not build); covered by CI Type Check UI.showcase_invoice_metrics,last_90_days, grouped byissued_on):{"issued_on":"2026-09","invoice_count":2,"invoice_count__compare":1},2026-102/1,2026-113/1 — the executor answerscompareTo. (That date-axis shape is the one the switch no longer offers; see Acceptance notes.)ui/source, zh-CN, admin). Frames in the project folderissue-36645/:item3-1-switch-beside-period.png(first head) — the switch beside 「今年」 on a number, off.item3-6-date-axis-bar-not-offered.png(fd8a9260) — new report → Invoice Metrics → group by Issued → 近 90 天, bar: the period chip and no switch.item3-4-number-previous-and-change.png(fd8a9260) — the same report as 数字: switch on, 7, 「较上期 3 (+133.3%)」.item3-7-category-axis-two-periods.png(fd8a9260) — report page 「按状态统计工时(图表)」, its list response intercepted in the browser to adddateRange: { dimension: 'created_at', defaultRange: 'this_month' }(showcase ships no report with a period): 本月 + switch on, a lighter earlier-window bar beside each status; the request carried"dimensions":["status"],…,"timeDimensions":[{"dimension":"created_at","dateRange":"this_month"}],"compareTo":{"kind":"previousPeriod","dimension":"created_at"}.item3-5-all-time-switch-off.png(first head) — 全部时间: switch off and disabled, one series.Acceptance notes
ReportSchema.dateRange), a separate Feature if wanted.ccb43920first documented the position pairing;fd8a9260then stops offering the switch on a chart whose x axis is the window's own date dimension (the bars could pair with the wrong period where the two windows split into different bucket counts), and words docs, changeset and this body as "the same-length window just before it". A calendar-aligned comparison would be a newcompareTokind (a spec widening) and the seat files it as a separate Feature card. TherunCompareunaligned-bucket overwrite the review escalated is an executor defect outside this diff, filed as 分析对比:对不齐的上期时间桶保留原键,会覆盖本期首桶的对比值 #36770.content/docs/ui/reports.mdx› Period and export carried the callout 「Declared, not drawn yet … there is no period chip」, false since the renderer draws the chip and the Export control (bothlivein the spec liveness ledger, soos validateno longer warns). Replaced with one paragraph saying what the page draws.Human Minimum
packages/specholds no runtime logic. (not touched)main, one pull request.packages/spectouched: n/a.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_01JQwxbYCxqr63HW2KJGpmAq