Skip to content

Show UK areas withheld by disclosure control on the hex maps as not reported - #1447

Closed
anth-volk wants to merge 8 commits into
chore/remove-uk-area-xyfrom
fix/uk-hex-maps-show-not-reported
Closed

anth-volk wants to merge 8 commits into
chore/remove-uk-area-xyfrom
fix/uk-hex-maps-show-not-reported

Conversation

@anth-volk

@anth-volk anth-volk commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1446

Stacked on #1436 (which is stacked on #1433). Like the rest of the UK clean-up, it waits to merge until after the UK Budget on 28 October.

What changes

Local-area breakdowns (breakdown=local_areas) come from .py with disclosure control, and an area whose estimate fails the disclosure rules is absent from the result. Until now the v2 and v3 hex maps drew only the areas in the result, so a withheld area left a gap.

For a level from a breakdown, the v3 "Local areas" hex map and the four v2 hex charts (absolute and relative change, by constituency and by local authority) now draw every area of the report's region:

  • all 650 constituencies and 361 local authorities for a UK-wide report;
  • the nation's areas for a nation's report.

An area the result leaves out:

  • is drawn in its place, hatched with grey stripes on the map's background and edged in grey, where a valued hexagon's edge is the background colour, so no colour on the scale resembles it;
  • reads "name: Not reported" in its tooltip;
  • has no value, so it takes no part in the colour range, isn't in v3's rankings or area finder, and can't be selected.

The note under the maps now reads "N of M constituencies are not reported" (or local authorities), and the geographic maps' tooltip for a withheld boundary reads "Not reported", so the map, its tooltips and the note use the same term. The note is one component (UKAreaDisclosureNotes), shown under v3's maps (with or without areas) and under each of the four v2 charts.

Unchanged

  • A saved level (results from before .py 6.10.0, which aren't disclosure-controlled) draws only its own areas.
  • A result in which any area has no code, or a code outside the region's layout (such as a pre-2023 local authority), can't be matched to the layout, so its hex map draws only its own areas, as before.

Geographic map

UKAreaChoroplethMap already drew every boundary: a withheld one was solid gray[300] with "Not published" in its tooltip. It now reads "Not reported". v3 also used that text on a saved level whenever the other level came from a breakdown. It now uses it only on the breakdown's level, as the hex map does, and a saved level's boundary without a result reads "No data". The fill is unchanged. gray[300] sits between two stops on the scale's grey side, so a later change could hatch it as the hex map now does.

How

  • HexagonalMap takes missingAreas (areas it places without a value) and missingAreaText. It hatches them with an SVG pattern sized to the hexagons, with stripes never closer than 4 SVG units (pixels at full width) so they don't blend into a flat grey, gives them a grey edge, and fits its frame to them as well as to the valued areas.
  • withheldUKHexAreas(level, points, region) in ukHexLayout.ts lists the region's layout codes that the result lacks, each at its layout position. It returns none when the result can't be matched, or when the region is neither the UK nor a nation.
  • The withheld areas are named from two new files beside the layouts, constituency_names_2024.json and local_authority_names_2023.json, built from the boundary files' PCON24NM and LAD23NM. ukBoundaryFiles.test.ts checks them against the boundary files. They add about 34 KB, before compression, to the bundle that already holds the layouts.

Commits

Each commit was done red-green: its tests were written first and seen failing for the expected reason, then the code was written and committed with them.

  1. Say "not reported" for UK areas disclosure control withholds: the note and the geographic tooltips, with new note and tooltip tests for the three v2 charts that had none.
  2. Draw areas without a value on the hex map, hatched (HexagonalMap).
  3. List the areas of a report's region that a UK result leaves out (withheldUKHexAreas and the name files).
  4. Draw UK areas disclosure control withheld on the hex maps, in v3 and the four v2 charts. The v2 constituency and local authority tab tests now expect 649 and 360 withheld hexagons beside the computed area.
  5. Read "Not reported" only on a breakdown level's v3 geographic map.
  6. Keep a withheld hexagon's hatching distinct on the dense UK map (review fix): on the UK-wide constituency map the stripes were 2.3 pixels apart and blended into a grey on the scale's grey side.
  7. Say in the hex map's docs that a withheld hexagon has a grey edge.
  8. Merge chore/remove-uk-area-xy, which drops Remove the app's handling of x and y on UK area results #1436's note on areas the layout can't place. The conflicts were imports in the v2 chart tests, and v3's test of an uncoded breakdown area no longer checks that note. The "not reported" note stays.

Testing

  • Focused vitest runs on Node 26 for the changed and related suites, plus make format, make lint and make typecheck.
  • Two review-code rounds: the first found the blended stripes (fixed red-green in commit 6), and the second found no bugs.
  • Not checked in a browser: how the hatching and edge look at UK-wide and nation scale, while zoomed, and in a downloaded image. On a v2 chart narrower than 600 pixels, its fixed 600-unit drawing area puts the stripes under 4 pixels apart; the grey edge still marks the hexagon.

🤖 Generated with Claude Code

anth-volk and others added 5 commits October 27, 2026 19:50
The note under the UK local-area maps now reads "N of M constituencies
are not reported" (or local authorities), and a withheld boundary's
tooltip on the geographic map reads "Not reported", in v3 and in the
four v2 charts. Tests for the three v2 charts that had none check the
note and the tooltip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HexagonalMap takes `missingAreas`: areas it places but has no value
for, such as ones disclosure control withheld. Each is drawn in its
place with grey stripes on the map's background, which no colour on
the scale resembles, and its tooltip reads its name and
`missingAreaText` ("No data" by default). Missing areas take no part in
the colour range, cannot be selected, and the map's frame fits them
with the valued areas.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
withheldUKHexAreas gives the constituencies or local authorities of a
report's region that a result does not hold, each at its hex layout
position and named, with its ONS code as its id: every area of the
layout for a UK-wide report, and the nation's for a nation's report.
It lists none when the result cannot be matched to the layout: an area
with no code, a code outside the region's layout, or a region that is
neither the UK nor a nation.

The names come from two new files beside the layouts, built from the
boundary files' PCON24NM and LAD23NM, which a test checks against
them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
For a level from a local-area breakdown, the v3 and v2 constituency and
local authority hex maps draw every area of the report's region: all
650 constituencies or 361 local authorities for a UK-wide report, and
the nation's for a nation's report. An area the result leaves out is
drawn hatched in its place, outside the colour scale, and its tooltip
reads its name and "Not reported". It has no value, so it is not in the
colour range or v3's rankings, and it cannot be selected.

A saved level, a result with an area that has no code, or one with a
code outside the region's layout still draws only its own areas, and
the note on areas the layout cannot place stays separate from the note
on withheld areas.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v3's geographic map labelled every boundary without a result "Not
reported" whenever the report had a breakdown, including on a saved
level beside it, which disclosure control did not apply to. It now
does so only on a level the breakdown supplied, as the hex map does; a
saved level's boundary without a result reads "No data".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
policyengine-calculator-next Ready Ready Preview Oct 27, 2026 4:22pm UTC
policyengine-website Ready Ready Preview Oct 27, 2026 4:22pm UTC

Request Review

anth-volk and others added 2 commits October 27, 2026 20:16
On the UK-wide constituency hex map each hexagon's radius is about 4.7
pixels, so the hatching's stripes repeated 2.3 pixels apart. That is
close enough to blend into a flat light grey, which the colour scale's
grey arm holds, so a withheld constituency could read as a small loss.
The stripes now repeat no closer than 4 SVG units (pixels at full
width), and a withheld hexagon has a grey edge where a valued one's is
the background colour, kept at the same screen width when zoomed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#1436 drops the note under the UK hex maps about areas the layout
cannot place. The conflicts were the v2 chart tests' imports, resolved
to keep this branch's withheld-area fixtures without the dropped
note's. v3's test of a breakdown area without a code no longer checks
that note; it still checks that the hex map draws no withheld areas.
The "not reported" note for withheld areas stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anth-volk

Copy link
Copy Markdown
Collaborator Author

Superseded by #1448, which is based on main instead of #1436. It carries this PR's commits cherry-picked with -x, adapted to a base where areas still carry x and y (withheld areas are drawn only when every area of the result is in the layout), together with #1433's v2 layout placement.

@anth-volk anth-volk closed this Oct 27, 2026
anth-volk added a commit that referenced this pull request Oct 27, 2026
#1448 (1A · 2) holds #1433's six commits, cherry-picked unchanged, and
#1447's work adapted to main: the hex maps draw the areas a
disclosure-controlled breakdown withheld, hatched, as "Not reported",
but only on the tiled grid, because areas still carry x and y there.
This branch now builds on it. The conflicts keep this branch's
behaviour and #1448's withheld areas:

- The app reads no x or y: placeOnUKHexLayout takes the adapters'
  UKAreaChoroplethDataPoint, leaves out an area the layout cannot
  place, and returns only the placed points. #1448's Welsh fixture
  points lose their positions, and its fixture with every API position
  at the origin is dropped.
- HexagonalMap draws only the tiled grid. #1448's missingAreas are
  positioned as the valued areas are, by a positionOnGrid with no
  coordinate scale or row-spacing argument, and count in the bounds.
  The duplicate "tiled frame" tests and the missing-area tests'
  tiled config are dropped.
- No note says which areas are left off.
- The withheld areas are kept. Under this branch every map tiles, so
  the callers' "only when tiled" checks are gone: v3's UKLocalAreaMaps
  and the four v2 charts ask withheldUKHexAreas for a breakdown level's
  withheld areas whenever the level is disclosure-controlled.

withheldUKHexAreas still lists none when any of the result's areas has
no code or a code outside the region's layout. That check is about
matching the result to the layout, not about the grid: a layout area
the result lacks may be covered by one of its unmatched areas, such as
the districts a 2023 unitary authority replaced, so calling it withheld
could be wrong. A map that leaves out unplaceable areas therefore draws
no withheld areas, and the function's comment says why. #1448's v3 test
for a breakdown area without a code now expects that: Gower left off,
the other constituencies tiled, and no withheld areas.

The README keeps both sides' text, and the tests take #1448's "not
reported" wording.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anth-volk
anth-volk removed this pull request from stack #1437 October 27, 2026 17:00

This branch was successfully deployed

2 active deployments
Preview – policyengine-calculator-next — 0e6b995a Deployed Oct 27, 2026 by vercel[bot]
Preview – policyengine-website — 0e6b995a Deployed Oct 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show UK areas withheld by disclosure control on the hex maps as not reported

1 participant