Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.
/ 2012-politicians Public archive

Automatic infographic generation using d3.js and data from hartapoliticii.ro

License

Notifications You must be signed in to change notification settings

cimi/2012-politicians

Repository files navigation

This project is unmaintained and uses outdated technology.

Attendance for Romanian Members of Parliament (2008-2012)

Overview

This is an interactive graph of the Romanian members of parliament for the 2008-2012 mandate. It uses data pulled from Harta Politicii, which has their attendance percentage, the percentage in which they voted against their party and if they're running for another term.

See a demo here.

It was done as an excercise for learning d3.js and currently uses Circle Packing as the representation model for politicians. The bigger a politician's circle is, the more he went to work. :)

The JavaScript is organized with require.js, jQuery is also used accross the board. The box with politician information is rendered with a handlebars template.

Bootstrap was used for styling; the typeahead is also used from the bootstrap toolkit.

The project was generated with Yeoman and has no server-side component. The data is stored statically as JSON files - it can be deployed anywhere.

Installing on your machine

If you don't already have yeoman installed, do it:

$ curl -L get.yeoman.io | bash

It will check all of its dependencies and give you step by step instructions to get it working. Now do the following:

$ git clone git://github.com/cimi/infographic-politicians.git
$ cd infographic-politicians
$ yeoman install d3
$ yeoman install handlebars
$ yeoman server

This should open a web server on port 3501 with the project. You'll be able to see changes you make to the files without a page reload.

How the data was obtained

The data for the 2008-2012 term was extracted by scraping this senate list and this chamber of deputies list. It was parsed using node.js - code here. To update the data, just run the script again. If the page structure of the source changes, the script will need to be updated.

The data for the 2012 candidates was pulled from here and was processed using this code, to make it more compatible with the current one.

The matching between new candidates and current members of parliament is not entirely accurate. It's done by name and their names do not entirely match - e.g. Victor Ponta vs Victor-Viorel Ponta. A naive algorithm is used to extract the first names (everything before the 1st space) and check that all the letters from the one are present in the other. The code is in the checkSimilarNames method of the Politicians module.