UPDATE: I’ve made the source code available for download here.
Yeah, yeah… I know it’s long past the time when anyone want to revisit the wonders of the 2008 presidential campaign, but the stars aligned for me to build this thing.
Star #1: I’m been meaning to learn JSON forever because everyone is talking about it.
Star #2: I’ve been meaning to get into pulling data from a publicly available API using a Silverlight application.
Star #3: I’ve been meaning to do something with information visualization in Silverlight ever since I got Ben Fry’s terrific book on Visualizing Data.
Star #4: Tim Heuer challenged his readers to create a Silverlight infoviz application with a time constraint of six days.
And so, due to several late nights and the infinite patience of my wonderful wife, I’ve finished my first data driven Silverlight information visualization. An explanation follows below the app.
The application visually displays how many stories in the New York Times in a given week mentioned one of the presidential candidates. If your favorite candidate does not appear, I apologize. I chose the seven most frequently mentioned candidates in each party.
My journey of exploration began at the New York Times developer site where I got my developer key and started exploring the data from their brand new Article Search API, with which you can search articles in the New York Times as far back as 1981.
Because the NYT API returns a JSON result, that meant I had to learn JSON. I highly recommend it. Super easy. I ended up scraping the data I needed and parsing it into a custom JSON file of my own so I wasn’t making a couple hundred calls to their servers every time I wanted to run my application.
From there, it was actually a simple matter to pull the idealized data into my application and start visualizing it. In case you’re wondering, the placement on the map doesn’t represent anything at all… I was just looking for a good way to show the data and I liked this one.
A special thanks to my wife, the math genius, for reminding me to take the square root my data so that my circles ended up with proportional areas (instead of exponential ones).
There are, of course, several things I would change about this if I had the time. The slider can be flaky, the fonts could use some more work and the code in general is a bit of a disaster. But this is all the time I had and I think it works pretty well.