Successfully implemented a dropdown menu in the STV visualizer to allow users to select and view previous Icenian senate elections, replacing the demo data button.
public/stv-data/senate-elections.json- Registry of available elections with metadatapublic/stv-data/README.md- Instructions for managing election data filespublic/stv-data/2026-01-january-senate.json- Sample election data filedocs/STV_ELECTIONS_FEATURE.md- Complete feature documentation
src/pages/stv/visualize.astro- Removed "Load Demo Data" button
- Added dropdown selector for elections
- Added "Load Selected Election" button
- Separated custom file upload section
- Updated instructions
- Implemented async election data loading
- Removed demo data constant
- On page load, the elections list is fetched from
/public/stv-data/senate-elections.json - The dropdown is populated with election names and term numbers
- When a user selects an election and clicks "Load Selected Election":
- The corresponding JSON file is fetched from
/stv-data/ - The data is parsed and validated
- The visualizer displays the election results
- The corresponding JSON file is fetched from
- Custom file upload remains available as a separate option
- Visit
/stv/visualize - Select an election from the dropdown menu
- Click "Load Selected Election"
- View the animated visualization
To add a new election:
- Export the RCVis JSON from the STV calculator
- Save it to
/public/stv-data/YYYY-MM-month-senate.json - Add an entry to
/public/stv-data/senate-elections.json:{ "id": "2026-02-february", "name": "February 2026", "date": "2026-02-04", "term": 44, "dataUrl": "/stv-data/2026-02-february-senate.json", "type": "local" } - Rebuild:
bun run build
Currently includes metadata for 10 elections (Jan 2026 - Jun 2024). Only the January 2026 sample data file is included. Actual election data files need to be added by:
- Re-running historical elections through the STV calculator
- Obtaining exports from election officials
- Manually constructing from available data
- Easy access to historical election results
- No need to find and download election files
- Consistent user experience
- Centralized data management
- Future-proof for adding more elections
To fully populate the feature:
- Obtain or recreate RCVis exports for past elections
- Add them to
/public/stv-data/ - Verify each election displays correctly
- Consider adding more metadata (winners, vote counts, etc.)