Git Product home page Git Product logo

parliament-visualization's Introduction

UK Parliament Votes Visualization

This is an interactive visualization of UK Parliament (House of Commons) votes since 1997; it can be viewed online here.

How it works

  • A series of scripts in the bin/ directory handle retrieving various public data on UK MPs and how they voted, made available by TheyWorkForYou, and extracting the relevant parts of this data into a Postgres database. The bin/setup script demonstrates the order in which these should typically be run.

  • A tiny Sinatra server, server/server.rb, serves up the needed data from this database.

  • An Elm web app, with entry point client/src/Main.elm, handles most of the UI, including making requests as needed for the above data.

  • This communicates with JavaScript, with entry point client/src/index.js, via ports to render the visualization itself; in particular client/src/BubbleChart.js renders a bubble chart using the D3 force layout, and appropriately updates this with any new data sent from the Elm app.

Development

The web app itself can be developed without needing to run a local server by using the live version of the server, like this:

cd client
yarn install

export ELM_APP_API_URL=https://api.parliament.bobwhitelock.co.uk
yarn run start

To develop the server or data retrieval scripts, a new empty Postgres database must be created and a TheyWorkForYou API key created, and then:

export DATABASE_URL=# URL to access the database created above.
export TWFY_API_KEY=# API key created above.
bin/setup

ruby server/server.rb

To use a local server with a local client, the value of ELM_APP_API_URL used when starting the client will need to be changed to point to this local server, usually like this:

export ELM_APP_API_URL=http://localhost:4567

parliament-visualization's People

Contributors

bobwhitelock avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jgarte

parliament-visualization's Issues

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.