Uh oh!
There was an error while loading. Please reload this page.
fix(plugin-dashboard): 交叉表(pivot ≥2 维)单元格内叠加 compareTo 对比值 (#3614) - #3757
Merged
Conversation
…-tab (#3614) The matrix branch of `DatasetWidget` (`type: 'pivot'` with two or more dimensions) was the one render path PR #3612 left out. It lays out `bucket x measure` and never admitted the `<measure>__compare` columns the executor returns, so a pivot with a bounded date window and a `compareTo` ran a correct comparison query, received correct comparison data, and showed none of it — headers, cells and all three subtotals silent. That is objectui#3337's "silently no comparison", relocated to another widget family. Maintainer ruling 2026-08-07 chose form 2, in-cell stacking: - The comparison stacks INSIDE the cell — current value on top, comparison value and delta beneath in smaller type. The column structure stays `bucket x measure`: a comparison column would make it `bucket x measure x window`, doubling the width and adding a third header level on the widget family whose width is already the scarce resource. - rowTotalById / colTotalById / grandTotal stack it identically. A Total that alone showed no comparison reads as "this row has none" — a different, false statement. - `exportColumns` drops its `isMatrix` exception, so the cross-tab exports a flat `<measure>__compare` column per compared measure with bare numbers in the cells. Display stacks; export is data, and a spreadsheet can still compute on it (never "$120 $100 20%"). - One caption names the window for the whole table, from the same `dashboard.trend.*` vocabulary the KPI/flat-table paths use, and the delta comes from the same `computeMetricDelta` — a cross-tab cell and a dataset KPI over the same two windows agree on sign and rounding rather than each rolling their own percentage. A cross-tab has no per-window column header to qualify, which is exactly what stacking traded away. Presence is detected from the DATA via the existing `comparedValues`, not a new config flag, so nothing is opted into per path and a pivot the executor sent no comparison for renders byte-identically to before. Tests extend the package's own compareTo suite: stacked cells (rise / fall / flat / empty cell), all three subtotals, the flat CSV export asserted to carry no display formatting at all, plus three regression pins (no compareTo; a compareTo the executor answered without comparison columns; stray `__compare` columns the widget never asked to compare). Reverse verification, predicted before running: reverting the render change alone turns the two stacking tests red on the missing `matrix-cell-compare` and leaves the export test and all three pins green; reverting the export change alone turns only the export test red ("Status,Priority,Amount" vs the expected comparison column). Both matched. Fixes#3614 Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
yinlianghui
marked this pull request as ready for review
August 8, 2026 12:05
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes#3614
问题
DatasetWidget的 matrix 分支(type: 'pivot'且dimensions.length >= 2)是 PR #3612 唯一留白的渲染路径。它按桶 × 度量铺cellCols,执行器返回的对比列(度量名加__compare后缀,如amount__compare)既不进表头、也不进单元格,行/列/总计三处小计同样丢弃 —— 于是一个配了有界日期窗口 +compareTo的 pivot:查询正确、对比数据真的返回了、界面一个字看不到。这正是 #3337 要终结的「静默无对比」,只是换了 widget 家族。实现(按 2026-08-07 维护者裁决:形态 2 单元格内叠加)
桶 × 度量不变 —— 给对比单独开列会变成桶 × 度量 × 窗口,列数翻倍、表头三层,而交叉表的宽度本来就是最紧张的资源。rowTotalById/colTotalById/grandTotal与数据单元格同一套处理。只有 Total 列不显示对比,读起来是「这一行没有对比」—— 那是另一个、且错误的陈述。exportColumns去掉isMatrix例外,交叉表也为每个参与对比的度量导出一列扁平的度量名__compare,单元格仍是裸数字,表格软件可以继续计算。显示叠加,导出是数据,绝不导出"$120 $100 20%"这种「CSV 外衣的截图」。dashboard.trend.*词汇;delta 复用同一个computeMetricDelta,所以同样两个窗口下的 KPI 与交叉表单元格在符号和取整上一致,不各算一套百分比。交叉表没有「按窗口的列表头」可以限定 —— 那恰好是叠加换掉的东西,所以标签落在 caption 与单元格title上。对比是否存在从数据判定(沿用既有的
comparedValues),没有新增配置开关:执行器没送对比的 pivot,渲染结果与改动前完全一致。测试
扩写本包既有的
DatasetWidget.compareTo.test.tsx:Status,Priority,Amount,Amount · vs last year,数据行Open,High,120,100,并断言整份 CSV 里没有$也没有%(任何显示格式都没漏进数据)。compareTo(逐格断言 td 文本与改前一致);配了compareTo但执行器没返回对比列;结果里带__compare而 widget 没要求对比。逆向验证(先预测后跑,两个方向都对上):只回退渲染改动 → 两条叠加测试红在缺失的
matrix-cell-compare,导出测试与三条回归钉全绿;只回退导出改动 → 只有导出测试红(得到Status,Priority,Amount,缺对比列)。Changeset:
.changeset/pivot-compare-stacking-3614.md(patch,user-visible)。文档:packages/plugin-dashboard/SKILL.md的compareTo章节补上 pivot 一条与导出形状说明。Generated by Claude Code