Skip to content

Commit 2c3dc72

Browse files
fix(plugin-charts): a sankey names its nodes and colours its flows, a funnel labels every stage, the sankey footnote is translated (objectui#13404) (#13425)
Closes #13404 Clause-②: no ## What changed All three defects are in `packages/plugin-charts/src/AdvancedChartImpl.tsx`. 1. **Sankey: node names and link colours.** `node` and `link` were plain objects, so Recharts drew bare rectangles with no text and every link was the same `muted-foreground` grey. There are now two module-scope renderers: - `SankeyNodeShape` draws the rect plus the node's name. The name goes to the right of the node, or to the left for a node with no outgoing link. Under `align: 'justify'` those are exactly the last-column nodes, which sit against the right edge. - `SankeyLinkShape` draws the same curve Recharts' default draws, stroked at opacity 0.4 in the colour of the node the link flows into. Each category node takes `palette[idx % palette.length]` through `resolveColor`, the same positional palette the funnel and treemap arms use, and it honours a caller's `colors`. The root keeps `muted-foreground` because it is the total, not a category. The renderers are at module scope because Recharts lists `node` and `link` in the dependencies of its layout memo. The `as any` on `node` is gone. 2. **Funnel: labels clipped.** `LabelList position="right"` put every label past its trapezoid's right edge. The widest stage's edge is the plot edge, so those labels drew off the surface. Labels are now `position="center"` with foreground text inside a background halo (`HALO_LABEL_PROPS`). 3. **Sankey footnote is English-only.** "Showing N of M rows ..." now comes from a new count family, `chart.sankeyOmittedRows` (base, `_one`, `_other`, plus each language's extra CLDR slots), translated in all ten packs. The English text is unchanged. The measure key is still drawn as a `code` chip: the sentence is interpolated with a private-use mark in `{{field}}` and split on it, the same construction as `withChips` in `metadata-viewer`, so each language decides where the chip goes. ## Judgment calls - **Links take the TARGET's colour, not the source's.** The card asks for "the source node's palette colour", but in this arm every link leaves the same root node: `links = rows.map((r, i) => ({ source: 0, target: i + 1, ... }))`. Colouring by source would paint every link one colour again, which is the defect. The target is the category the link carries, so each link matches the node it ends in. For the same reason the test cannot build "two links with different sources", so it pins two flows into two categories carrying two different strokes, each equal to its node's fill. - **Funnel labels inside the segments rather than a reserved right margin.** A centred label is anchored on the funnel's axis, the vertical line through the middle of the chart, so no stage name can be pushed off the surface. Reserving room on the right would shrink every funnel by its longest name and still clip a name longer than the reserve. A single contrasting fill fails on the narrowest stage: a white label disappears once it is wider than the segment and spills onto the background. The foreground-on-background halo reads on both the segment and the background, in light and dark themes (both colours are theme tokens). Recharts' centre position also wraps a multi-word name to the segment's mid-height width in a real browser. - **`createSafeTranslation`, not the file's `useSafeTranslate`.** The sentence agrees with a count ("1 row has" / "2 rows have"), so it is an i18next count family and the call has to pass `count`, which `useSafeTranslate` cannot. Its defaults map is what a host without a provider renders, and it picks `_one` / `_other` the way i18next does. `check:i18n-keys` confirms each defaults row repeats the `en` pack value. ## Tests New: `AdvancedChartImpl.sankeyFunnelLabels-13404.test.tsx` (13 tests, jsdom, asserting on rendered SVG text and attributes): - Sankey: every node name is a `text` (root series label plus each category). The root's name is right of its node with `text-anchor` start. Each last-column name is left of its node with `text-anchor` end, inside the 480px surface. The three links carry three distinct strokes, equal to their target nodes' fills and to `--chart-1..3`. The root fill is not used by any link. A caller `colors` palette reaches the links. - Funnel: one label per stage. Every label is anchored between 25% and 75% of the width, all on one x (the narrowest stage on the same axis as the widest), with `text-anchor` middle. The narrowest stage's label carries the foreground fill, background stroke and `paint-order` stroke. - Footnote: en with no provider reads exactly the old text in the plural and the singular, with the key still in `code`. en under `I18nProvider` reads the same, which pins the defaults map to the en pack. zh renders the zh `_other` row with the counts filled in and the chip kept. Every pack carries the family with all four placeholders, translated. - Control: a bar chart's data labels are unchanged and carry no halo. Treemap leaf names are still white and no sankey labels appear. A pie draws no halo labels. Results on head f0a3687126 (after merging origin/main and re-running `pnpm run setup` for the moved pin): - `pnpm exec vitest run packages/plugin-charts/ packages/i18n/ --maxWorkers=2`: Test Files 183 passed (183), Tests 2609 passed, 22 skipped (2631). - `turbo run type-check --filter=@object-ui/plugin-charts --filter=@object-ui/i18n` (no dependents): Tasks 11 successful, 11 total. - eslint on the touched files: 0 errors. The only warnings in new code are 7 `no-explicit-any` in the new test file, from the same `vi.mock` and `series as any` shape its sibling tests use. - `check:i18n-keys`, `check:i18n-drift`, `check:i18n-dead-keys`, `check:new-line-citations` and `check-changeset-presence`: all exit 0. Ablation, one leg per fix. Each mutation went through the anchor-must-hit replace tool and was restored to the HEAD blob with an empty `git diff HEAD`: - `node={SankeyNodeShape}` changed back to the old `{ fill: ... }` object: 3 failed, 10 passed (no node text, and the node-fill comparison fails). - `link={SankeyLinkShape}` changed back to the old grey object: 2 failed, 11 passed (link strokes and caller palette). - Funnel `LabelList` changed back to `position="right"`: 2 failed, 11 passed. "Qualification is anchored inside the plot: expected 433 to be less than 360", and the halo assertion also fails. - `SankeyOmittedRowsNote` changed back to the old English JSX: 1 failed, 24 passed with `AdvancedChartImpl.sankeyOmittedRows.test.tsx` included. Only the zh test fails, so the en output is byte-identical to the old JSX. ## Acceptance notes - The other footnotes and refusals in this file are still English-only JSX: `unsizedRowsNote`, `MagnitudeRefusal`, the sankey `no-positive-flow` refusal, and the axis-position and unplotted-points notes. They have the same defect but this card does not name them, so they are not changed here. - The `en` pack is in the eager closure. This adds one three-row family to it, so the `Bundle Analysis` performance-budget check in CI is the reading for its size. - The line/area `XAxis` that PR #13420 changed is not touched. - [x] Adds no product-specific widget, dialog, hook or string (see AGENTS.md › Product-neutral renderer) 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WJozybDmRH8z2c5SD7vJkj --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 7f60e9d commit 2c3dc72

13 files changed

Lines changed: 494 additions & 15 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@object-ui/plugin-charts": patch
3+
"@object-ui/i18n": patch
4+
---
5+
6+
charts: a sankey now names every node and colours its flows, and a funnel labels every stage. Sankey nodes were bare bars with no text and every link was one grey, so the chart could not be read without hovering. Each node now carries its name (to its right, or to its left in the last column so it stays on the chart), and each link is stroked in the palette colour of the category it flows into. Every link leaves the same root node, so colouring by source would paint them all one colour again. A funnel labelled each stage to the right of its segment, past the plot's edge, so only the narrowest stage's label showed. Labels now sit centred inside their segments, in foreground text with a background halo so a name wider than the narrowest segment stays legible. The sankey's "Showing N of M rows" footnote now comes from the locale packs under the new count family `chart.sankeyOmittedRows`, translated in all ten packs. The English text is unchanged (objectui#13404).

‎packages/i18n/src/locales/ar.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,6 +1464,13 @@ const ar = {
14641464
refreshing: "جارٍ التحديث…",
14651465
nullCategory: "(غير محدد)",
14661466
scatterOneMeasure: "المخطط المبعثر يرسم مقياسًا واحدًا فقط. أبقِ سلسلة واحدة:",
1467+
sankeyOmittedRows: "الصفوف المعروضة: {{shown}} من {{total}} — صفوف بلا {{field}} أكبر من الصفر: {{count}}، ولا يمكن للتدفق رسمها.",
1468+
sankeyOmittedRows_zero: "الصفوف المعروضة: {{shown}} من {{total}} — {{count}} صف لا يحتوي على {{field}} أكبر من الصفر، ولا يمكن للتدفق رسمه.",
1469+
sankeyOmittedRows_one: "الصفوف المعروضة: {{shown}} من {{total}} — {{count}} صف لا يحتوي على {{field}} أكبر من الصفر، ولا يمكن للتدفق رسمه.",
1470+
sankeyOmittedRows_two: "الصفوف المعروضة: {{shown}} من {{total}} — صفّان ({{count}}) لا يحتويان على {{field}} أكبر من الصفر، ولا يمكن للتدفق رسمهما.",
1471+
sankeyOmittedRows_few: "الصفوف المعروضة: {{shown}} من {{total}} — {{count}} صفوف لا تحتوي على {{field}} أكبر من الصفر، ولا يمكن للتدفق رسمها.",
1472+
sankeyOmittedRows_many: "الصفوف المعروضة: {{shown}} من {{total}} — {{count}} صفًا لا تحتوي على {{field}} أكبر من الصفر، ولا يمكن للتدفق رسمها.",
1473+
sankeyOmittedRows_other: "الصفوف المعروضة: {{shown}} من {{total}} — {{count}} صف لا يحتوي على {{field}} أكبر من الصفر، ولا يمكن للتدفق رسمها.",
14671474
unconfigured: {
14681475
noCategoryAxis: "محور فئات الرسم البياني مطلوب — الرسم البياني المرتبط بكائن لا يخترع محورًا. أعلن أحد التالي:",
14691476
},

‎packages/i18n/src/locales/de.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,9 @@ const de = {
13051305
refreshing: "Wird aktualisiert…",
13061306
nullCategory: "(Ohne Angabe)",
13071307
scatterOneMeasure: "Ein Streudiagramm zeichnet genau eine Kennzahl. Behalten Sie nur eine Datenreihe:",
1308+
sankeyOmittedRows: "{{shown}} von {{total}} Zeilen angezeigt — bei {{count}} Zeilen ist {{field}} nicht größer als null, und ein Fluss kann sie nicht darstellen.",
1309+
sankeyOmittedRows_one: "{{shown}} von {{total}} Zeilen angezeigt — bei {{count}} Zeile ist {{field}} nicht größer als null, und ein Fluss kann sie nicht darstellen.",
1310+
sankeyOmittedRows_other: "{{shown}} von {{total}} Zeilen angezeigt — bei {{count}} Zeilen ist {{field}} nicht größer als null, und ein Fluss kann sie nicht darstellen.",
13081311
unconfigured: {
13091312
noCategoryAxis: "Kategorieachse des Diagramms erforderlich — ein objektgebundenes Diagramm erfindet keine. Deklarieren Sie eine davon:",
13101313
},

‎packages/i18n/src/locales/en.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,6 +1618,13 @@ const en = {
16181618
// eagerly loaded and the `framework` chunk's gzip ceiling has ~0.2 KB of
16191619
// headroom; the series keys are rendered by the chart as data, after it.
16201620
scatterOneMeasure: 'A scatter plots one measure. Keep exactly one series:',
1621+
// The note under a sankey that drew only some of its rows (objectui#7148,
1622+
// translated by objectui#13404): a flow has no negative width, so rows whose
1623+
// measure is not above zero are left out. A count family on the OMITTED
1624+
// rows; `{{field}}` is where the chart draws the measure key as a code chip.
1625+
sankeyOmittedRows: 'Showing {{shown}} of {{total}} rows — {{count}} rows have no {{field}} above zero, which a flow cannot draw.',
1626+
sankeyOmittedRows_one: 'Showing {{shown}} of {{total}} rows — {{count}} row has no {{field}} above zero, which a flow cannot draw.',
1627+
sankeyOmittedRows_other: 'Showing {{shown}} of {{total}} rows — {{count}} rows have no {{field}} above zero, which a flow cannot draw.',
16211628
// The refusal an object-bound chart renders when it declares no category
16221629
// axis (objectui#8168) — `aggregate.groupBy` / `xAxisKey` / `xAxis.field`
16231630
// all absent, so `runAggregate` would have grouped on a name nobody wrote.

‎packages/i18n/src/locales/es.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,10 @@ const es = {
13471347
refreshing: "Actualizando…",
13481348
nullCategory: "(Sin especificar)",
13491349
scatterOneMeasure: "Un gráfico de dispersión traza una sola medida. Conserve una sola serie:",
1350+
sankeyOmittedRows: "Filas mostradas: {{shown}} de {{total}} — {{count}} filas no tienen {{field}} mayor que cero, algo que un flujo no puede dibujar.",
1351+
sankeyOmittedRows_one: "Filas mostradas: {{shown}} de {{total}} — {{count}} fila no tiene {{field}} mayor que cero, algo que un flujo no puede dibujar.",
1352+
sankeyOmittedRows_many: "Filas mostradas: {{shown}} de {{total}} — {{count}} de filas no tienen {{field}} mayor que cero, algo que un flujo no puede dibujar.",
1353+
sankeyOmittedRows_other: "Filas mostradas: {{shown}} de {{total}} — {{count}} filas no tienen {{field}} mayor que cero, algo que un flujo no puede dibujar.",
13501354
unconfigured: {
13511355
noCategoryAxis: "Se requiere el eje de categorías del gráfico — un gráfico vinculado a un objeto no lo inventa. Declare uno de:",
13521356
},

‎packages/i18n/src/locales/fr.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,6 +1343,10 @@ const fr = {
13431343
refreshing: "Actualisation…",
13441344
nullCategory: "(Non défini)",
13451345
scatterOneMeasure: "Un nuage de points trace une seule mesure. Ne conservez qu’une série :",
1346+
sankeyOmittedRows: "Lignes affichées : {{shown}} sur {{total}} — {{count}} lignes n’ont pas de {{field}} supérieur à zéro, ce qu’un flux ne peut pas représenter.",
1347+
sankeyOmittedRows_one: "Lignes affichées : {{shown}} sur {{total}} — {{count}} ligne n’a pas de {{field}} supérieur à zéro, ce qu’un flux ne peut pas représenter.",
1348+
sankeyOmittedRows_many: "Lignes affichées : {{shown}} sur {{total}} — {{count}} de lignes n’ont pas de {{field}} supérieur à zéro, ce qu’un flux ne peut pas représenter.",
1349+
sankeyOmittedRows_other: "Lignes affichées : {{shown}} sur {{total}} — {{count}} lignes n’ont pas de {{field}} supérieur à zéro, ce qu’un flux ne peut pas représenter.",
13461350
unconfigured: {
13471351
noCategoryAxis: "Axe de catégories requis — un graphique lié à un objet n’en invente pas. Déclarez l’un des suivants :",
13481352
},

‎packages/i18n/src/locales/ja.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,9 @@ const ja = {
13051305
refreshing: "更新中…",
13061306
nullCategory: "(未設定)",
13071307
scatterOneMeasure: "散布図は1つの指標だけを描画します。系列は1つだけ残してください:",
1308+
sankeyOmittedRows: "{{total}} 行中 {{shown}} 行を表示 — {{count}} 行は {{field}} が 0 より大きくないため、フローとして描画できません。",
1309+
sankeyOmittedRows_one: "{{total}} 行中 {{shown}} 行を表示 — {{count}} 行は {{field}} が 0 より大きくないため、フローとして描画できません。",
1310+
sankeyOmittedRows_other: "{{total}} 行中 {{shown}} 行を表示 — {{count}} 行は {{field}} が 0 より大きくないため、フローとして描画できません。",
13081311
unconfigured: {
13091312
noCategoryAxis: "チャートのカテゴリ軸が必要です — オブジェクト連携チャートは軸を推測しません。次のいずれかを宣言してください:",
13101313
},

‎packages/i18n/src/locales/ko.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,9 @@ const ko = {
13051305
refreshing: "새로고침 중…",
13061306
nullCategory: "(미지정)",
13071307
scatterOneMeasure: "산점도는 측정값 하나만 그립니다. 계열을 하나만 남기세요:",
1308+
sankeyOmittedRows: "{{total}}개 행 중 {{shown}}개 표시 — {{count}}개 행은 {{field}} 값이 0보다 크지 않아 흐름으로 그릴 수 없습니다.",
1309+
sankeyOmittedRows_one: "{{total}}개 행 중 {{shown}}개 표시 — {{count}}개 행은 {{field}} 값이 0보다 크지 않아 흐름으로 그릴 수 없습니다.",
1310+
sankeyOmittedRows_other: "{{total}}개 행 중 {{shown}}개 표시 — {{count}}개 행은 {{field}} 값이 0보다 크지 않아 흐름으로 그릴 수 없습니다.",
13081311
unconfigured: {
13091312
noCategoryAxis: "차트 범주 축이 필요합니다 — 객체 바인딩 차트는 축을 임의로 만들지 않습니다. 다음 중 하나를 선언하세요:",
13101313
},

‎packages/i18n/src/locales/pt.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,10 @@ const pt = {
13421342
refreshing: "Atualizando…",
13431343
nullCategory: "(Não especificado)",
13441344
scatterOneMeasure: "Um gráfico de dispersão traça uma única medida. Mantenha apenas uma série:",
1345+
sankeyOmittedRows: "Exibindo {{shown}} de {{total}} linhas — {{count}} linhas não têm {{field}} acima de zero, o que um fluxo não consegue desenhar.",
1346+
sankeyOmittedRows_one: "Exibindo {{shown}} de {{total}} linhas — {{count}} linha não tem {{field}} acima de zero, o que um fluxo não consegue desenhar.",
1347+
sankeyOmittedRows_many: "Exibindo {{shown}} de {{total}} linhas — {{count}} de linhas não têm {{field}} acima de zero, o que um fluxo não consegue desenhar.",
1348+
sankeyOmittedRows_other: "Exibindo {{shown}} de {{total}} linhas — {{count}} linhas não têm {{field}} acima de zero, o que um fluxo não consegue desenhar.",
13451349
unconfigured: {
13461350
noCategoryAxis: "Eixo de categorias do gráfico obrigatório — um gráfico vinculado a um objeto não o inventa. Declare um destes:",
13471351
},

‎packages/i18n/src/locales/ru.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,11 @@ const ru = {
13891389
refreshing: "Обновление…",
13901390
nullCategory: "(Не указано)",
13911391
scatterOneMeasure: "Точечная диаграмма строит только одну меру. Оставьте один ряд:",
1392+
sankeyOmittedRows: "Показано строк: {{shown}} из {{total}} — строк, где {{field}} не больше нуля: {{count}}. Поток не может их нарисовать.",
1393+
sankeyOmittedRows_one: "Показано строк: {{shown}} из {{total}} — у {{count}} строки {{field}} не больше нуля, и поток не может её нарисовать.",
1394+
sankeyOmittedRows_few: "Показано строк: {{shown}} из {{total}} — у {{count}} строк {{field}} не больше нуля, и поток не может их нарисовать.",
1395+
sankeyOmittedRows_many: "Показано строк: {{shown}} из {{total}} — у {{count}} строк {{field}} не больше нуля, и поток не может их нарисовать.",
1396+
sankeyOmittedRows_other: "Показано строк: {{shown}} из {{total}} — у {{count}} строки {{field}} не больше нуля, и поток не может их нарисовать.",
13921397
unconfigured: {
13931398
noCategoryAxis: "Требуется ось категорий диаграммы — диаграмма, привязанная к объекту, не придумывает её. Объявите одно из:",
13941399
},

0 commit comments

Comments
 (0)