Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 13 additions & 0 deletions .changeset/36645-report-compare-previous-period.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@object-ui/plugin-report': patch
'@object-ui/i18n': patch
---

feat(report): 「Compare with previous period」 beside a report's period chip — the chart draws the earlier window beside the current one

Clause-②: yes (widening) — one new `@object-ui/i18n` key, `report.dateRange.comparePrevious`, in all 11 locales; no export, spec key, schema or server change
Metadata-protocol: none

- **The switch**: a report that declares `dateRange` now shows 「Compare with previous period」 next to its period chip when its chart can draw a comparison: bar, column, horizontal bar, line or area over a category axis, or a single number. It is not offered on a `seriesBy` split, nor on a chart whose x axis is the window's own date dimension, where the earlier window's date buckets would not line up with the current ones. Like the period pick it is the viewer's and is not saved into the report. It is off, and cannot be turned on, while the period is All time or a custom range missing an end.
- **What it asks for**: the chart's dataset query carries the contract's `compareTo: { kind: 'previousPeriod', dimension }`, on the same dimension and window the period chip already sends. The chart is compared with the same-length window just before the current one (the contract's `previousPeriod`). The table beside the chart is not asked for a comparison.
- **What it draws**: a bar or line chart gets one more series, the measure's earlier window, labelled 「<measure> · vs previous period」 and drawn muted by the chart's existing `comparison` styling; a single number shows the previous period's value and the change in percent under it. A click on an earlier-window mark opens no record list, the dashboard's rule for the same series. A comparison the server refuses is shown where the chart was, instead of the chart disappearing.
19 changes: 13 additions & 6 deletions content/docs/ui/reports.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,16 @@ same custom-range switch, on by default.
- **The window is a filter, not a bucket.** It is applied with the report's `runtimeFilter`
and the dataset's own filter. How rows are grouped by date stays with the dimension's
`dateGranularity` and the report's `rows` / `columns`.
- **Compare with the previous period** is a switch beside the period chip, not a report key.
Like the chip's own pick, it belongs to the viewer and is not saved. While it is on and the
period names a window, the chart is compared with **the same-length window just before it**
(`compareTo: { kind: 'previousPeriod' }` on the window's dimension): a bar or line chart draws
the earlier window as a muted series, and a single number shows the previous value and the
change under it. All time names no window, so nothing is compared.
- **Where it is offered**: a chart that can draw a second series (`bar`, `column`,
`horizontal-bar`, `line`, `area`) over a category axis, or a single number (`metric`, `kpi`).
It is not offered on a `seriesBy` split, nor on a chart whose x axis is the window's own date
dimension: there the earlier window's date buckets would not line up with the current ones.

**`exportOptions`** uses the list export's key and member names: `formats`,
`includeHeaders`, `fileNamePrefix`. A report table downloads as `csv` or `xlsx`. Export is on
Expand All @@ -260,12 +270,9 @@ rows are already aggregated.
permissions allow **export of the dataset's base object**. That is the permission-set
`allowExport` axis the list toolbar uses (see [Permissions and protection](#permissions-and-protection)).

<Callout type="warn">
**Declared, not drawn yet.** The Console report page does not read either key yet: there is
no period chip and no export control on it today. Until the renderer ships, `os validate`
warns on both keys so the gap is visible. The declarations are the contract the renderer
implements.
</Callout>
On the Console report page, a report that declares `dateRange` draws a period chip above the
report, and every query the report makes runs inside the chosen window. The Export control is
drawn once the table has rows.

What is deliberately **not** offered: a `joined` report refuses both keys, because its blocks
may bind different datasets and it draws one table per block. A report has no subscription or
Expand Down
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 @@ -4419,6 +4419,7 @@ const ar = {
dateRange: {
from: "من",
to: "إلى",
comparePrevious: "مقارنة بالفترة السابقة",
datasetUnreadable: "لا تحدد الفترة الزمنية لهذا التقرير أي بُعد، وتعذّرت قراءة مجموعة البيانات \"{{dataset}}\" للعثور على بُعد التاريخ ({{reason}}).",
noSingleDateDimension: "لا تحدد الفترة الزمنية لهذا التقرير أي بُعد، وتعلن مجموعة البيانات \"{{dataset}}\" عن {{total}} من أبعاد التاريخ ({{found}}) بينما يلزم بُعد واحد بالضبط. حدّد بُعد التاريخ في dateRange.dimension الخاص بالتقرير.",
},
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 @@ -4061,6 +4061,7 @@ const de = {
dateRange: {
from: "Von",
to: "Bis",
comparePrevious: "Mit vorheriger Periode vergleichen",
datasetUnreadable: "Der Zeitraum dieses Berichts nennt keine Dimension, und das Dataset {{dataset}} konnte nicht gelesen werden, um seine Datumsdimension zu finden ({{reason}}).",
noSingleDateDimension: "Der Zeitraum dieses Berichts nennt keine Dimension, und das Dataset {{dataset}} deklariert {{total}} Datumsdimensionen ({{found}}), benötigt wird genau eine. Nennen Sie die Datumsdimension in dateRange.dimension des Berichts.",
},
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 @@ -2157,6 +2157,7 @@ const en = {
dateRange: {
from: 'From',
to: 'To',
comparePrevious: 'Compare with previous period',
datasetUnreadable: 'This report’s date range names no dimension, and the “{{dataset}}” dataset could not be read to find its date dimension ({{reason}}).',
noSingleDateDimension: 'This report’s date range names no dimension, and the “{{dataset}}” dataset declares {{total}} date dimensions ({{found}}) where it needs exactly one. Name the date dimension in the report’s dateRange.dimension.',
},
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 @@ -4151,6 +4151,7 @@ const es = {
dateRange: {
from: "Desde",
to: "Hasta",
comparePrevious: "Comparar con el período anterior",
datasetUnreadable: "El periodo de este informe no indica ninguna dimensión y no se pudo leer el conjunto de datos «{{dataset}}» para encontrar su dimensión de fecha ({{reason}}).",
noSingleDateDimension: "El periodo de este informe no indica ninguna dimensión y el conjunto de datos «{{dataset}}» declara {{total}} dimensiones de fecha ({{found}}) cuando necesita exactamente una. Indique la dimensión de fecha en dateRange.dimension del informe.",
},
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 @@ -4147,6 +4147,7 @@ const fr = {
dateRange: {
from: "Du",
to: "Au",
comparePrevious: "Comparer avec la période précédente",
datasetUnreadable: "La période de ce rapport ne nomme aucune dimension, et le jeu de données « {{dataset}} » n’a pas pu être lu pour trouver sa dimension de date ({{reason}}).",
noSingleDateDimension: "La période de ce rapport ne nomme aucune dimension, et le jeu de données « {{dataset}} » déclare {{total}} dimensions de date ({{found}}) alors qu’il en faut exactement une. Nommez la dimension de date dans dateRange.dimension du rapport.",
},
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 @@ -4063,6 +4063,7 @@ const ja = {
dateRange: {
from: "開始",
to: "終了",
comparePrevious: "前期と比較",
datasetUnreadable: "このレポートの期間はディメンションを指定しておらず、データセット「{{dataset}}」を読み込んで日付ディメンションを特定できませんでした({{reason}})。",
noSingleDateDimension: "このレポートの期間はディメンションを指定しておらず、データセット「{{dataset}}」は日付ディメンションを {{total}} 個宣言しています({{found}})。ちょうど 1 個である必要があります。レポートの dateRange.dimension で日付ディメンションを指定してください。",
},
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4060,6 +4060,7 @@ const ko = {
dateRange: {
from: "시작",
to: "종료",
comparePrevious: "이전 기간과 비교",
datasetUnreadable: "이 보고서의 기간에 차원이 지정되지 않았으며, 날짜 차원을 찾기 위해 “{{dataset}}” 데이터셋을 읽을 수 없습니다({{reason}}).",
noSingleDateDimension: "이 보고서의 기간에 차원이 지정되지 않았으며, “{{dataset}}” 데이터셋은 날짜 차원을 {{total}}개 선언합니다({{found}}). 정확히 하나여야 합니다. 보고서의 dateRange.dimension에 날짜 차원을 지정하세요.",
},
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4146,6 +4146,7 @@ const pt = {
dateRange: {
from: "De",
to: "Até",
comparePrevious: "Comparar com o período anterior",
datasetUnreadable: "O período deste relatório não indica nenhuma dimensão, e não foi possível ler o conjunto de dados “{{dataset}}” para encontrar sua dimensão de data ({{reason}}).",
noSingleDateDimension: "O período deste relatório não indica nenhuma dimensão, e o conjunto de dados “{{dataset}}” declara {{total}} dimensões de data ({{found}}) quando precisa de exatamente uma. Indique a dimensão de data em dateRange.dimension do relatório.",
},
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4250,6 +4250,7 @@ const ru = {
dateRange: {
from: "С",
to: "По",
comparePrevious: "Сравнить с предыдущим периодом",
datasetUnreadable: "Период этого отчёта не указывает измерение, и не удалось прочитать набор данных «{{dataset}}», чтобы найти его измерение даты ({{reason}}).",
noSingleDateDimension: "Период этого отчёта не указывает измерение, а набор данных «{{dataset}}» объявляет измерений даты: {{total}} ({{found}}), тогда как нужно ровно одно. Укажите измерение даты в dateRange.dimension отчёта.",
},
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/zh-Hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1809,6 +1809,7 @@ const zh = {
dateRange: {
from: '开始',
to: '结束',
comparePrevious: '和上一期对比',
datasetUnreadable: '该报表的时间范围未指定维度,且无法读取数据集“{{dataset}}”以确定其日期维度({{reason}})。',
noSingleDateDimension: '该报表的时间范围未指定维度,而数据集“{{dataset}}”声明了 {{total}} 个日期维度({{found}}),这里需要恰好一个。请在报表的 dateRange.dimension 中指定日期维度。',
},
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/zh-Hant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1809,6 +1809,7 @@ const zhHant = {
dateRange: {
from: '開始',
to: '結束',
comparePrevious: '和上一期對比',
datasetUnreadable: '該報表的時間範圍未指定維度,且無法讀取資料集“{{dataset}}”以確定其日期維度({{reason}})。',
noSingleDateDimension: '該報表的時間範圍未指定維度,而資料集“{{dataset}}”聲明瞭 {{total}} 個日期維度({{found}}),這裡需要恰好一個。請在報表的 dateRange.dimension 中指定日期維度。',
},
Expand Down
Loading
Loading