Repository navigation
Commit 9e73c08
fix(plugin-charts): a two-dimension sankey draws every flow, not only the first group's (#27560)
<!-- claude-projects-attribution: {"github_login":"os-sales"} -->
_Requested by **Sales** · [project
thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuPi1WuDmCwpfQHCGmcaxKEh)_
Fixes #27460
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:桑基图拿到两个维度(例如 status × category)时,画出每一条 status → category
流向,不再只画第一个 category 的流向;点一条流向可下钻到那一格的记录。
- 为什么改:第二个维度被透视成多条序列,桑基图分支只读第一条,其余全部静默丢掉,看起来像一张完整的图(卡上 Alpha
3/2/2,Beta、Gamma 不见了)。
- 风险与回滚:只动桑基图分支;单序列桑基图、对比叠加、其他图表类型不变;回滚就是 revert 本 PR。
- 先看:`ui/packages/plugin-charts/src/AdvancedChartImpl.tsx` 的
`buildSankeyCellFlows` 与 sankey
分支开头;`ui/packages/plugin-dashboard/src/DatasetWidget.tsx` 的
`chartSeries`。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/plugin-charts/src/AdvancedChartImpl.sankeyTwoDimensions-27460.test.tsx`,预期
8 条全绿,其中一条逐条断言 6 条流向及数值。
- 需要你做的:无,席位落地。
## What changes
- **The sankey arm draws a pivot as two columns of nodes.** Two or more
flow series (every series except a `variant: 'comparison'` overlay)
reaching the sankey are the groups of a pivoted second dimension: the
spec refuses a second measure on a sankey (`SINGLE_SERIES_CHART_TYPES`),
and `buildChartSeries` pivots the second dimension into series exactly
when the chart carries one measure. `buildSankeyCellFlows` makes each
row's category a source node, each series a target node, and each cell
the row carries a flow valued by the cell. One flow series keeps the
one-level arm byte for byte.
- **Absent is not omitted; non-positive is said.** A cell the row does
not carry is a combination the dataset did not answer, so it is no flow
and no omission. A carried cell that is not above zero is dropped and
the existing omitted-rows note (`chart.sankeyOmittedRows`, no new
strings) is printed once per target column that lost a cell. No carried
cell above zero is the existing `no-positive-flow` refusal, naming every
column.
- **A flow click drills to its cell.** A link is exactly one `(category,
series)` pair, the pair `findChartSeriesRow` resolves to one dataset
row; the event carries `category`, `categoryId`, `series`, `seriesLabel`
and `value`. A node spans several cells, so a node click does not drill
(as the one-level root does not).
- **`DatasetWidget` hands a sankey only the measure it renders.** A
stored sankey that declares several measures (refused at publish) would
otherwise have its later measures drawn as groups, and the
dropped-measure warning would be false. A pivot carries one measure, so
nothing is filtered from it. The `SINGLE_SERIES_CHART_FAMILIES` docblock
says so.
## Tests
- New `AdvancedChartImpl.sankeyTwoDimensions-27460.test.tsx` (8): the
pivot is built with `buildChartSeries` from the card's shape (3 statuses
× 3 categories, 6 answered pairs); it asserts the six flows `source →
target: value`, the six links and six named nodes, no note for
unanswered pairs, the note for a carried negative cell, the refusal for
all-zero cells, the flow click and no node click; controls: one series
and a comparison overlay stay one-level.
- New `DatasetWidget.sankeyTwoDimensions-27460.test.tsx` (1): the card's
widget through the real chain draws all six nodes and six links.
- `pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-charts/
packages/plugin-dashboard/`: Test Files 294 passed (294), Tests 3175
passed, 15 skipped, at `13e084eb`.
## Acceptance notes
- **Ablation (renderer).** `if (flowSeries.length >= 2)` → `if (false &&
…)` through `scripts/ablation-replace.mjs` (anchor 1 → 0, blob restored
to HEAD, `git diff HEAD` empty): 5 of 9 red, the first reading `expected
[ 'Alpha → Open: 3', …(2) ]`, the card's 3/2/2; the two one-series
controls stayed green.
- **Ablation (dashboard).** `chartType === 'sankey'` → `'ablated'` in
`chartSeries`: `DatasetWidget.singleSeriesMeasures-11417.test.tsx` goes
red on `sankey: fires iff the second measure's values leave the drawn
chart unchanged` (1 of 22), so the existing tie pins the filter.
- **pie / donut / funnel / treemap** each bind `series[0]` too (their
arms read `series[0]?.dataKey` and nothing else; read on `13e084eb`, not
rendered), so a two-dimension pivot on them draws only the first
second-dimension group. The two-level fix does not cover them (a pie has
no second column of nodes); they are reported to the seat, not fixed
here.
- **A pivot with ONE second-dimension value** reaches the arm as one
series and draws the one-level shape: that value as the root, flowing to
each first-dimension value. Every flow is drawn; only the orientation
differs from the two-level shape.
- **An inline `object-chart` sankey with two measures** (no publish-time
arity refusal on that node) now draws category → measure flows instead
of silently dropping the second measure.
- Three or more dimensions: `buildChartSeries` pivots only the second
dimension, a cross-family question outside this card.
## Verification
Local gates from `node scripts/dispatch-gates.mjs --commands` at
`13e084eb`, each exit captured before any pipe and reconciled with
`--ran`; type-check of both packages; every other family is CI's and is
cited from the PR's check runs in the report.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L6bhgWJECm7uQEkPAHKqat)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 8243694 commit 9e73c08
5 files changed
Lines changed: 465 additions & 5 deletions
File tree
- .changeset
- ui/packages
- plugin-charts/src
- plugin-dashboard/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 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 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1153 | 1153 | | |
1154 | 1154 | | |
1155 | 1155 | | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
1156 | 1243 | | |
1157 | 1244 | | |
1158 | 1245 | | |
| |||
2028 | 2115 | | |
2029 | 2116 | | |
2030 | 2117 | | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
| 2136 | + | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
2031 | 2140 | | |
| 2141 | + | |
2032 | 2142 | | |
2033 | 2143 | | |
2034 | 2144 | | |
| |||
2707 | 2817 | | |
2708 | 2818 | | |
2709 | 2819 | | |
| 2820 | + | |
| 2821 | + | |
| 2822 | + | |
| 2823 | + | |
| 2824 | + | |
| 2825 | + | |
| 2826 | + | |
| 2827 | + | |
| 2828 | + | |
| 2829 | + | |
| 2830 | + | |
| 2831 | + | |
| 2832 | + | |
| 2833 | + | |
| 2834 | + | |
| 2835 | + | |
| 2836 | + | |
| 2837 | + | |
| 2838 | + | |
| 2839 | + | |
| 2840 | + | |
| 2841 | + | |
| 2842 | + | |
| 2843 | + | |
| 2844 | + | |
| 2845 | + | |
| 2846 | + | |
| 2847 | + | |
| 2848 | + | |
| 2849 | + | |
| 2850 | + | |
| 2851 | + | |
| 2852 | + | |
| 2853 | + | |
| 2854 | + | |
| 2855 | + | |
| 2856 | + | |
| 2857 | + | |
| 2858 | + | |
| 2859 | + | |
| 2860 | + | |
| 2861 | + | |
| 2862 | + | |
| 2863 | + | |
| 2864 | + | |
| 2865 | + | |
| 2866 | + | |
| 2867 | + | |
| 2868 | + | |
| 2869 | + | |
| 2870 | + | |
| 2871 | + | |
| 2872 | + | |
2710 | 2873 | | |
2711 | 2874 | | |
2712 | 2875 | | |
| |||
0 commit comments