台湾選挙マップ
DoneTaiwan Election Map

County magistrates, presidents, legislators, councillors, village chiefs and national referendums on one clickable map of Taiwan: start with the party map or turnout by county, click into a township, and every place has a timeline across elections. All data comes from the Central Election Commission's open data.
Problem
Election results sites show one race in one county at a time. To see how many times a county has changed parties, how long one party has held it, or how the same township voted across different elections, you have to compile it yourself. I wanted a clickable map — and the data had to be right.
My rolePersonal project: data collection, cleaning, verification, the map and the interface (including mobile) are all my own work.
Key decisions
- 01
Read the static JSON behind the pages instead of scraping HTML
The Central Election Commission's election database is a single-page app backed by JSON files with fixed paths: one file at county level and one per county at township level. That's more stable than parsing tables and easier to verify. 2026 isn't in the database yet, so it reads the vote-counting site's 368 township pages and 7,781 village pages instead.
- 02
Check every dataset against another number before drawing it
622 county-magistrate vote totals across all elections must equal the township sums; the 2024 presidential vote, the 2008 and 2024 party-list shares, the 910 council seats of 2022 and the county totals of 22 referendums were all checked against official figures. Stopping whenever a check failed is how I caught double-counted 2008 party votes and missing 2004 township data for Yunlin and Taitung.
- 03
Draw the map as SVG and simplify the borders myself
g0v's raw township borders are 20 MB; Douglas–Peucker simplification brings them to 469 KB (about 100 KB compressed). Outlying islands sit in an inset on the left, and clicking a county zooms into its townships — no external map service, no map library.
- 04
Split the data into 6 files, loaded on demand
The first screen needs only about 20 KB; legislators, councillors, village chiefs and referendums each download when selected (36–155 KB compressed).
- 05
State the counting rules on the page
A party change is based on the winner's registered party; independents don't count as a party; magistrates and councillors from before county mergers aren't compared; 2026 is a snapshot from the vote-counting site — the same numbers counted differently lead to different conclusions.
Trade-offs
- 2026 is a post-count snapshot, not the commission's final announcement; Yunlin's magistrate race was decided by 173 votes and Hualien's by 357, so recounts are possible
- Township borders are the 2010 version, simplified, so later boundary tweaks aren't reflected; the positions and sizes of outlying islands are schematic
- The map started as a standalone static front-end app and was rewritten on 2026-11-30 as React components on this site (dark mode, keyboard support, mobile drawer); the cost is about 60 KB of component code, loaded only on this page
Results
- Six kinds of elections, every county and all 368 townships are clickable; every county and township has a timeline across elections (consecutive terms, number of party changes)
- Found and fixed five data and interface bugs: old county codes double-counting party votes (11.7M votes became 9.78M), missing 2004 data, map objects merging two places into one, New Taipei covering Taipei, and a huge focus ring covering the whole map after clicking a county
- A purpose-built mobile layout (map on the first screen, bottom drawer, quick picker for small areas); 7 E2E tests, including two regression tests
Data & checks
- Sources: the Central Election Commission's election database (1994–2022; the open datasets are licensed under the Open Government Data License, version 1.0) and the 2026 (ROC 115) vote-counting site. The bottom of the page carries the required attribution notice and states that it is unofficial and that the commission's announcements are authoritative
- Coverage: county magistrates (1997/98–2026), presidents (1996–2024), legislators (districts 1995–2024, party list 2008–2024), councillors (1998–2026), village chiefs (the 2010 special municipalities, 2014–2026) and 22 referendums (2004–2025)
- Verification: county-level figures are checked against township sums and key numbers against official figures; where the gap is large (Yunlin and Taitung in 2004) nothing is forced onto the map, and the page notes that only county-level data exists
- In 2026, 11 villages were still undecided (9 ties awaiting a drawing of lots, 2 polling stations not yet reported); they are excluded from the stats with a note
Map & UI
- All native SVG: county borders and each county's township borders are simplified into paths; polygon holes must be stored too and drawn with fill-rule: evenodd, or New Taipei covers Taipei when it is selected and brought to the top
- Colours: party map (darker means a bigger lead), turnout, and referendum approval rates; places that changed party since the previous election can be highlighted
- Timelines: each county and township shows consecutive terms, the number of party changes, and every winner with their margin
- Accessibility: map elements work with the keyboard and have accessible names; clicked elements don't use the browser's default focus ring (on SVG it is drawn as a huge circle covering the whole map) — a custom outline appears only for keyboard focus
Mobile
- The map must be on the first screen: a smaller title and the controls squeezed into four rows (election type, what to show, a horizontally scrolling year picker, options)
- Details live in a bottom drawer: collapsed it shows only the name and one line (about 90 px), and tapping the header opens it to 80% of the height
- Taipei, Keelung, Hsinchu City, Chiayi City and the outlying islands are too small to tap accurately on a phone, so they get a quick-pick row above the map
The Python code that compiles the data and the numbers used for verification live in a private GitHub repository; the map on this site is the static data it produces plus a front-end app.