Skip to content

feat: add hex map toggle for US congressional districts#631

Merged
anth-volk merged 3 commits intomainfrom
feat/us-hex-map
Feb 17, 2026
Merged

feat: add hex map toggle for US congressional districts#631
anth-volk merged 3 commits intomainfrom
feat/us-hex-map

Conversation

@SakshiKekre
Copy link
Copy Markdown
Collaborator

Summary

  • Add toggle to switch between geographic (natural boundaries) and hex grid views for congressional district maps
  • Hex map shows each district as an equal-area shape, eliminating visual distortion where large rural districts dominate

Changes

New files

  • congressional_districts_hex.geojson - Hex layout GeoJSON (based on Daily Kos/Downballot v3.1)
  • MapTypeToggle.tsx - Toggle component for Geographic/Hex grid
  • MapTypeToggle.test.tsx - Unit tests for toggle

Modified files

  • USDistrictChoroplethMap.tsx - Support both visualization types
  • utils.ts - Fix Plotly geo config for hex maps (no projection, fitbounds only)
  • types.ts - Add MapVisualizationType and optional geo config properties
  • AbsoluteChangeByDistrict.tsx / RelativeChangeByDistrict.tsx - Add toggle to pages
  • README.md - Document 119th Congress compatibility and design decisions

Technical notes

Why irregular "blob" shapes instead of uniform hexagons?

The hex map uses irregular polygon shapes by design:

  1. The artistic arrangement packs 436 districts into a recognizable US shape
  2. In dense areas (NY, CA urban districts), some districts are only 0.5 units apart
  3. Uniform hexagons (requiring ~1.0 unit spacing) would overlap
  4. The blobs tessellate like puzzle pieces to avoid overlap

119th Congress compatibility

  • All 436 district IDs match between hex map and 119th Congress natural boundaries
  • The 5 states that redistricted (AL, GA, LA, NY, NC) kept the same number of districts
  • Only PR-98 (Puerto Rico) is missing from hex map (non-voting delegate)

Test plan

  • Toggle appears on congressional district pages
  • Geographic view works as before
  • Hex view renders correctly with proper colors
  • Hover tooltips work on both views
  • Toggle state persists while viewing the page

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 3, 2026

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

Project Deployment Actions Updated (UTC)
policyengine-app-v2 Ready Ready Preview, Comment Feb 17, 2026 11:24pm
policyengine-calculator Ready Ready Preview, Comment Feb 17, 2026 11:24pm
policyengine-website Ready Ready Preview, Comment Feb 17, 2026 11:24pm

Request Review

SakshiKekre and others added 2 commits February 17, 2026 23:42
Hex maps use synthetic coordinates that geoAlbersUsa distorts and clips.
Switch to geoEquirectangular with auto-fitted center/scale for hex mode.
Also replace [0,0] default center (crashes geoAlbersUsa) with [-96,38.5].

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@anth-volk anth-volk merged commit 3b6b9d8 into main Feb 17, 2026
8 checks passed
@anth-volk anth-volk deleted the feat/us-hex-map branch February 17, 2026 23:28
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 0.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@policyengine
Copy link
Copy Markdown

policyengine Bot commented Feb 17, 2026

Sorry @github-actions[bot], only members of the PolicyEngine/core-developers team can invoke Claude Code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants