us-state-map – a React component for a US map of states!

After releasing State Election Map, my first step was to publish a React component with just the map stuff in it. And after messing around for a while with npm and TypeScript and React, I got it working! The us-state-map component is now available on GitHub and npm, and State Election Map uses it. (it includes the map itself and the date slider)

As with whenever I mess around with React I’m pretty sure I’m doing some parts idiomatically “wrong”. (the build step in particular is pretty hacked-together) I like to work on stuff like this to learn how to do things, but it makes me wonder how much I actually learn if I’m just hacking things together and not doing it 100% the correct way. At least it does give me something to copy if I want to do something similar in the future, and I do feel a sense of accomplishment 🙂

State Election Map now available!

My latest project, State Election Map, is now available! It’s a neat way to visualize US presidential election results from 1972 to 2016.

The coolest part is that you can look at each state’s result relative to the national popular vote, so you can see states becoming more Democratic/Republican over time. (check out California and Alabama going on opposite trajectories…)

Other interesting observations: Nixon won by a ton in 1972 (which means that whole Watergate stuff was really unnecessary!), Reagan won by a ton in 1984, and check out the 1976 bizarro-world map! I guess that’s what you get when you have a Southern Democrat running before the Southern Strategy had entirely taken hold…

From a technical perspective, the map is built in React, which I’ve used before, and TypeScript, which was new to me. And I’m a big fan! Using Visual Studio + TypeScript meant I got helpful syntax errors at edit-time, which I’m really not used to in a JavaScript-y language.

I did my best to separate the map/timeline parts into separate components, so I’m hoping to publish them separately and eventutally rewrite my same-sex marriage map to use them too. But that’s a ways down the line!