How can I dynamically generate charts showing party seating in Congress?
January 11, 2013 3:51 PM   Subscribe

How can I use PHP (ideally with jQuery) to generate charts like these that Wikipedia uses to show part shares in Congress?
posted by kirkaracha to Computers & Internet (3 answers total) 1 user marked this as a favorite
 
You might have success with the d3.js library. Here are some examples.
posted by heliostatic at 3:57 PM on January 11, 2013 [1 favorite]


That's an SVG file so you don't even need to do anything with javascript. (I mean, you could re-create it in javascript if you wanted to with somthing like d3 as heliostatic suggests but that seems silly when all of the work is already done for you and it's public domain.)

In your first link click on the "full resolution" link and then view the source code. You can change the colors of the dots by altering the "style" properties of the path objects that draw them. (Dynamically, even, with PHP code or javascript in most browsers if you wish.) Or you can download Inkscape which was used to create this illustration and use the drawing tools in it to make more sophisticated changes.
posted by XMLicious at 4:12 PM on January 11, 2013


d3 is what you're looking for, and will make this dead simple. You could assign an incremental id to every circle, and generate a simple array or even a .tsv containing the values. The code required to assess the values fill the circles accordingly would be miniscule. It's just the sort of thing that d3 makes simple.
posted by Mayor Curley at 6:09 PM on January 11, 2013


« Older Woman escapes interrogation room using a quarter   |   Am I using my CO2 Regulator wrong? Newer »
This thread is closed to new comments.