Skip to content

feat(react): Default order, and say what unclear chart choices do - #965

Merged
eizedev merged 8 commits into
mainfrom
feat/clear-chart-and-sort-choices
Nov 26, 2026
Merged

eizedev merged 8 commits into
mainfrom
feat/clear-chart-and-sort-choices

Conversation

@eizedev

@eizedev eizedev commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Summary

A field's menu gets Default order (Reihenfolge › Standardreihenfolge): it removes the field's sort entry, so the field goes back to its own order, or the order the host gives it. Chart settings now says what its unclear choices do: a short line under Automatic, Every n-th, Trend and Share in the tooltip, per chart type, in English and German. A heatmap no longer offers a Legend that did nothing, and horizontal bars name their axis choice All, because they never slant. A menu's search shows a greyed-out choice greyed out, with its reason.

Fixes #916
Fixes #917
Fixes #963

Whole-change check

Docs

docs/use/charts.md (read whole). Its reader sets up a chart and wants to know what each choice in Chart settings does.

  • The settings table already answers that per setting, so I put the new facts into its rows, not into new prose:
    • Value labels: what Automatic writes on a pie with inside labels and on a treemap.
    • Legend: not offered for a treemap or a heatmap.
    • Value labels: a heatmap writes its numbers only up to 200 filled cells and only when its cells are large enough for them, as pivotkit-core's chart.js and chart-style.js do.
    • Axis labels: what Automatic and Every n-th do, that every n-th labels are still slanted, and that horizontal bars stay straight and name the choice All.
    • Share in the tooltip: only sums and counts get a share; averages and values below zero get none. The row points to the box "The share in the tooltip", which already explains the basis (the series' total or the category's total) and the category with one value left. I checked that box against sharesOf in chart-tooltip.js; it was right, so it stays as it is.
  • The paragraph about the i gets one sentence: lines under Automatic, Every n-th, All on horizontal bars, Trend and Share in the tooltip say what they do.
  • The list of left-out topics says that a heatmap has no Legend.
  • My first draft added two sentences of prose and the docs guard failed. I did not cut words to pass it. The facts moved into the table rows, where a reader looks for them, and the paragraph keeps a one-sentence pointer. The page keeps its length.

docs/use/fields.md (read whole). Its reader wants to know what a field's menu offers.

  • The Topic table gets one row, Sort order, with Default order, and links to the sorting section instead of repeating it.
  • The screenshot's alt text and the screenshot itself show the new row. After the merge of main I retook it, so it shows main's zone colours too.

docs/use/filters.md, section Sort (read whole). Its reader wants to change or undo a sort.

  • The list "In the field's menu" gets one item, Default order, after Custom order. That is where a reader looks for "how do I get the old order back".
  • It says that Default order is the field's own order (A to Z, oldest first, or the application's order), not the report's start view.

docs/concepts/filters.md, the table of menu entries and sort entries (read whole). Its reader writes views by hand and wants to know what each menu entry writes.

  • One row: Default order writes no entry, so a field order the host gives comes back.

docs/features.md, Totals and sorting. Its reader scans what pivotkit can do.

  • The sorting line adds "and back to the default order". Nothing else changed.

docs/reference/react-layout.md, the menu table (read whole). Its reader is a developer who checks what each menu's first level holds.

  • Default order goes into the first-level list of a field on Rows or Columns. Nothing else changed.

Code

packages/pivotkit-react/src/menu-topics.js (read whole).

  • defaultOrderTopic is new. Its one job is the Default order topic: whether the field already sorts as in a new view, and the change that removes the field's sort entry. I took it out of axisTopics because it is a job beside listing the topics.
    • It compares the host's order entry by entry as text, because a custom order's items can take the field's type.
    • It reuses setSort from view-ops.js. Removing the entry brings the host's order back through withHostOrders, so it needs no second path for hosted fields.
  • chartNotes is new. Its one job is to say which line goes under Automatic and Every n-th for the chart that is drawn. It follows pivotkit-core's chart.js:
    • a pie's names, or its shares with inside labels;
    • a treemap's names and values;
    • a heatmap's numbers up to 200 filled cells, when the cells are large enough (chart-style.js heatmapCellLabels hides all of them otherwise);
    • nothing on bars, lines and areas;
    • straight labels on horizontal bars, where All writes every name straight even where they overlap (chart-layout.js categoryLabelLayout).
  • axisLabelNames is new. Horizontal bars never slant their labels, so their choice is named All, not All (slanted), in the choice and in the Axis topic's state (Axis labels: "All (slanted)" on horizontal bars does not slant #963).
  • Trend gets a line, "A straight line that best fits the values". I read pivotkit-core's chart-lines.js: the trend is a least-squares straight line. The name alone does not say that it is straight, so it needs the line.
  • Default order has the search words "reset" and "unsorted" and its own undo text, "default order of Region".
  • tooltipTopic moved out of chartTopics unchanged, apart from the line under Share in the tooltip. The Tooltip topic is a job of its own, like the Reference lines and Series topics that already live beside it.
  • chartTopics now only lists the topics. A heatmap no longer gets Legend: its colour scale replaces the legend, so the four choices did nothing.
  • axisTopics keeps its job (the field menu's topics) and calls defaultOrderTopic.

packages/pivotkit-react/src/levels.jsx and popover.jsx (read MenuItem, SearchHits and Option whole).

  • The menu's search passed only a choice's text, check and icon to its hit. A greyed-out choice, such as Default order or Reset filter, looked like one to pick there and did nothing. The hit now gets the choice's disabled state, reason and note, as its level shows them.
  • The line under a choice was read as part of its name. In MenuItem it is now aria-hidden and stays only as the description (aria-describedby), for notes and reasons alike. Option, the one-line entry of the other menus, keeps its second line in its name: there it can be a field's name that the entry needs, so that is a change of its own.
  • MenuItem and Option computed the item's role the same way. They now share menuItemRole from popover.jsx. That also brings MenuItem's complexity under the limit.

packages/pivotkit-react/src/menu-labels.js and menu-labels-de.js (read the chart and sort parts whole).

  • New texts sortOrder, sortDefault, sortIsDefault, sortDefaultKeywords, axisLabelAllStraight and chartNotes, in English and German. labels.js and labels-de.js get the undo text steps.sortDefault.
  • One sentence in the Tooltip's explanation: when a share shows, and on which total.
  • I kept each line short; the test checks that no choice is left unclear in either language.

scripts/growth-baseline.json

  • chartTopics shrank: it is back under the 120-line limit, and its complexity goes from 68 to 62, so I lowered the baseline.
  • MenuItem in levels.jsx is now within the complexity limit, so its entry is gone.
  • No entry grew. totalLines stays as main has it.

Tests

  • test/chart/topics.test.js goes through every choice of every chart type in English and German. It fails when a choice is unclear and has no line, and when a German line repeats the English one. A list of the choices that need no line gives each its reason; All on horizontal bars is not on it.
  • Another test fails when a chart type has no line under Value labels › Automatic, in either language.
  • A test checks that horizontal bars name the choice All ("Alle"), in the choice and the topic's state.
  • test/menu-topics.test.js covers Default order on a text field, a date and a field with the host's order, including items that took the field's type.
  • tests/browser/sort-default.spec.js checks that the header shows no arrow after Default order and that Undo brings the sort back. A new test finds Default order in the search by "reset" and "unsorted": greyed out with its reason, Enter does nothing, and after a sort it can be picked. The first test checks the undo text "Undone: default order of Region". It also checks that the reason is the description, not part of the name. Without the fix in levels.jsx it fails, and it fails too with only the search part of the fix taken out.
  • Without the change, the unit tests fail.

Changelogs

Size budgets

  • The new texts grow two on-demand groups on an official Node 24 build: menus to 60.3 KiB gzip (61704 B, budget 59.6) and texts to 8.7 KiB (8921 B, budget 8.5). I raised their budgets to 60.3 and 8.8 KiB in build.js, and the element changelog names both. The first load stays at 179.8 KiB, within its 182.5 KiB.

Growth guards

  • The first run failed on three entries:
    • chartTopics grew to 129 lines and complexity 72;
    • axisTopics grew to complexity 35;
    • docs/use/charts.md grew by two lines.
  • I fixed the code by extracting defaultOrderTopic, chartNotes and tooltipTopic, and the page as described above.
  • In the review round, chartTopics grew by one (the name of All on horizontal bars), Option by one, and charts.md by one line. I moved the name into axisLabelNames, shared the role in menuItemRole, and kept the All fact in the settings table only, not again in the box "Axis labels".
  • Now all guards pass. The baseline changes only lower entries; none was raised.

Checklist (PRODUCT.md)

Test plan

  • npm run lint, npm run types, npm test ("tests 2677, pass 2674, fail 0, skipped 3"), npm run growth, npm run pack:check
  • npm run growth passes
  • npm run test:browser: 2916 passed, 2 failed. levels.spec.js:330 also fails on main (levels.spec Filter level test measures the menu during its opening animation #961). view-tabs.spec.js:443 passed 9 of 9 when run alone; it is flaky under load.
  • Size on Node 24: menus 60.3 KiB, texts 8.7 KiB, first load 179.8 KiB, all within their budgets.

Neutral review

A separate AI session reviewed the branch before it was pushed, in two rounds.

  • Round 1 found four medium points:
    • the Share line promised a share for every value;
    • the heatmap line left out its limits;
    • "All (slanted)" was wrong on horizontal bars;
    • search hits dropped the greyed-out state and reason.
  • It also found low points: the reason was read as part of the name, the German reason, Trend's line, the Default order wording, and an undo text.
  • All of these are fixed in b682b97 and b9c6361.
  • Round 2 found nothing medium or worse. Its open low points:

🤖 Generated with Claude Code

eizedev and others added 8 commits November 26, 2026 02:33
A field's menu on Rows or Columns gets Default order in a group named
"Sort order". It removes the field's sort entry, so the field returns to
the order of a new view: A to Z, oldest first, or the host's order. It is
disabled with a reason while the field already sorts this way (#917).

Chart settings gets a line under each choice whose name alone does not
say what it does: Automatic under Value labels, Legend and Axis labels
follows what the chart draws, plus Every n-th and Share in the tooltip.
The Tooltip's explanation mentions the share. A heatmap no longer lists
Legend, whose choices changed nothing there. A test walks every choice
of every chart type in English and German (#916).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tions of their own

axisTopics and chartTopics grew with the last change. Default order and
the lines under Chart settings' choices are jobs beside theirs, as is the
Tooltip topic, so each is a function of its own now. chartTopics is back
within the length limit; its complexity baseline goes down from 68 to 62.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rs look

The menu-entry table, the feature list and the chart page's list of
left-out topics now say what the last two commits changed. The element
changelog names the growth of its menus and texts groups.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Share in the tooltip: the note, the Tooltip's i and the docs say that
  only sums and counts get a share, which total it is, and when none shows.
- Heatmap Automatic: up to 200 filled cells, when the cells are large enough.
- Axis Automatic: every n-th labels are still slanted.
- Horizontal bars name the axis choice All, not All (slanted), with a line
  that says it writes every name straight (#963).
- Trend gets a line: a straight line that best fits the values.
- A test fails when a chart type has no Value labels note.
- The menu search keeps a choice's disabled state, reason and note, so a
  greyed-out Default order or Reset filter no longer looks clickable.
- The line under a menu choice is its description only, not part of its
  name (MenuItem and Option share the item role helper).
- Default order: German reason "Bereits die Standardreihenfolge.", search
  words reset and unsorted, its own undo text, and the docs say it is the
  field's own order, not the report's start view.

Fixes #963

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The field menu's screenshots conflicted: retaken on the merged code, with
main's zone colours and Default order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ew sizes

The element's changelog names the menus and texts groups as an official
Node 24 build measures them after the review round: 60.3 KiB and 8.7 KiB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…'s undo text

The change to Option had no test and also moved every hint, such as a
point menu's field name, out of the name. Option keeps its line in the name
as before; MenuItem's notes and reasons stay descriptions. The browser test
checks the undo text "Undone: default order of Region". The charts page
names the line under All on horizontal bars too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Default order choice and the chart notes grow the menus group to
60.3 KiB and the texts group to 8.7 KiB on an official Node 24 build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eizedev
eizedev merged commit 71d609d into main Nov 26, 2026
27 checks passed
@eizedev
eizedev deleted the feat/clear-chart-and-sort-choices branch November 26, 2026 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant