Code Monkey home page Code Monkey logo

usa-election-map's Introduction

USA Election Map

An interactive USA presidential, senatorial, house, and governor election map. Created with HTML/CSS/JS, map svg outlines from YAPms, and map data from MIT Election Lab & Dave Leip's Atlas.

Features

  • Interactive and detailed map sources
  • Comparisons between different map sources
    • Can be used to show shift between elections
    • Can be used to show margins of error between projections and election results
  • Countdown timer to upcoming elections and important events
  • Keyboard controls for advanced usage

Development

Running a fork locally is simple since this code only uses the base HTML/CSS/JS stack. Just clone the repo and open index.html to run.

Since the site uses separate svg files for the map, Chrome and Safari might prevent them from loading over the file protocol due to CORS restrictions (this is a well known issue: see more info and solution).

  • Fixing this CORS issue on Safari is fairly simple: go to Develop > Disable Cross-Origin Restrictions.
  • Chrome is a little more complicated, as it needs to be opened via command line to disable CORS:
    • Mac:
      "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --allow-file-access-from-files
      
    • Windows:
      "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --allow-file-access-from-files
      
  • Alternatively, Firefox can be used without issue since it does not enforce CORS restrictions over the file protocol in the same way.

Another way to address the CORS issue is to run a local http server. On Mac (via Homebrew):

brew install http-server
cd <local repo path>
http-server

Then open the address provided in the Terminal window (by default, it seems to be http://localhost:8080).

TODO List

This is an outdated list. See the project issue board for upcoming features.

  • Past senate election results & 2022 senate projections
    • More past senate election results (1960-1974)
  • More past election results
    • 1960-1972 presidential elections
    • 1912-1956 presidential elections
    • 1856-1908 presidential elections
    • 1788-1856 presidential elections
  • Past governor elections & 2022 governor projections (1980-2020)
  • Full third-party support in past results and custom maps
    • Display in voteshare
    • Display on pie chart
    • Display in past result maps
    • Add & Edit parties in custom map
    • Shift & compare modes for multiple parties
  • Custom map improvements
    • Directly editable margins
    • Direct electoral vote editing
    • Set map-wide electoral votes from decade
  • National popular vote totals for past elections
  • Past house election results
  • Presidential election results by county

If you have any questions, suggestions, or feature ideas, feel free to open an issue here on GitHub. Alternatively, you can email [email protected].

usa-election-map's People

Contributors

fish1 avatar jacksonjude avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

usa-election-map's Issues

Specific margin shifting

  • Custom shift value w/ similar usage to margin boxes
  • Fix selected party box visual glitch when shifting

1976-1998 House Maps

  • Convert shapefiles to SVGs
  • Size correctly & add metadata
  • Insert Alaska & Hawaii in correct locations

Add the US Senate Map as well.

Hey!
Potential Feature! The US Senate Map can be added and the past US Senate elections also.
The Map can be sourced from YAPMS and if you need the data, just tag me and I'll get it to you.

County editing

  • Edit option for counties in dropdown (always voteshare?)
  • Use county results for total state margins

I am unable to create any working maps past 2030.

Hi, ive been working on something using the custom source feature, and ive been trying to do it for elections in 2032, however it will not show anything. I was just wondering if you were planning on changing it, or will change this?

(suggestion) Add Direct Vote Amounts for Each State

For example, instead of adding in vote share percentages for a state, instead be able to insert the number of votes and have the percentages be calculated based on those direct numbers. As such, there would be information on how many people live in the state and multiply that by the fifteen percent average voting rate for how many voters would be expected.
This would be additional to the "set margin" and "set vote share" editing options.

Shift and compare support for third parties

  • Rework shifting to take votes from other parties proportionally to their voteshare; only enable this functionality when voteshares are enabled for the custom map (see #31)
  • Update NPV and Tipping Point shifts to work the same way
  • Rework compare mode to show all shifts for top parties (with some cutoff, maybe 5%)

Presidential County Maps

Hello, I use this app quite a bit and I love it! However, would it be possible to add a county map? Whether it would on its own map or same map but click on the map. Thanks!

Option to change electoral votes by state

There's a few articles put forward showing an expansion of the house would lead to more proportional representation. It would be an interesting feature to see what California would look like with over 100 electoral votes with proportional representation in every other state as well.

*SUGGESTION* Option for the Territories for Custom maps.

If custom maps are generally considered to be user-defined hypothetical scenarios,
using the YAPMS territories template,

image

users would be able to make hypothetical maps if American Samoa, Guam, Mariana Islands, Virgin Islands and Puerto Rico were able to vote in Presidential elections.

Flip states for projections and past elections

  • Show regions that flipped since last election/last projection (with diagonal stripe pattern?)
  • MapSource function to determine last election (more complicated for senate past, but simple for most others)
  • Add setting to toggle show/hide

House map

A house of representatives map:

  • Will initially show 50 states, probably colored by which party controls the most seats in them (or split in some way to represent the percentage of seats for each party)
  • Hovering over a state in this initial view will show how many seats each party controls (and possibly the popular vote totals for that state?)
  • Clicking on a state will zoom to reveal the individual congressional districts in the state, similar to the NYT presidential map's method of showing counties
  • Hovering over a district will show margin and voteshare like every other map source

Voteshares in custom maps

Main Features

  • Use voteshares in custom maps
  • Add voteshare editing in custom maps
  • Create percentage if a party that does not already exist in the voteshare is selected
  • Remove percentages by setting to zero voteshare
  • Setting for default copy mode, place other mode in Copy/Edit dropdown
  • Use voteshares in compare & shift modes
  • Testing for all types

Possible features

  • Add "flatten" button to convert voteshare custom map to margin custom map
  • Add other method to use original margin editor while preserving voteshare (could replace settings dropdown w/ editing settings while editing)

2022 Predictions

  • Add predictions from Sabato's Crystal Ball for 2022 Senate & Governor races
  • Add preditions from FiveThirtyEight for 2022 Senate, Governor, & House races

Custom map selector

  • Select a map svg from all available svgs, to be saved in json custom map data
  • Have map type auto-switch on json upload

Add the U.S. Gubernatorial Elections

I have an idea about another map, in this case the U.S. Gubernatorial Elections, It would be very interesting to see the margins by state in their respective gubernatorial elections and it would also be a very useful tool for the analysis of gubernatorial elections. Currently a map for it exists in YAPms but it would also be interesting to see from territories that hold gubernatorial elections or similars (like mayoral race in DC), that's an extension to the first but if added would be awesome, just like any other map it would have current and past elections. Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.