openva / richmondsunlight.com

The Richmond Sunlight website.
https://www.richmondsunlight.com/
MIT License
12 stars 3 forks source link

Graph relationships between legislators #248

Open waldoj opened 6 years ago

waldoj commented 6 years ago

Create a force-directed graph (aka a "node diagram") illustrating the strength of relationships between legislators, using their co-patroning relationships. This is both a useful page for the site, but also a good start toward a related method: the legislators with whom a legislator most often co-patrons bills. That would be useful to include on each legislator's page.

waldoj commented 6 years ago

Here's SQL that gets us 95% of the way there

SELECT CONCAT_WS(',', t1.legislator_id, t2.legislator_id) AS pair,
    COUNT(*) AS number
FROM bills_copatrons AS t1
LEFT JOIN bills_copatrons AS t2
    ON t1.bill_id=t2.bill_id
WHERE t1.legislator_id != t2.legislator_id
GROUP BY pair
waldoj commented 6 years ago

d3-force seems good for this.

waldoj commented 6 years ago

Here's some helpful sample code.

jalbertbowden commented 5 years ago

can that query return csv? is that in the repo where i can run it and get the results?

jalbertbowden commented 5 years ago

i think i see this happening in video/clip.php

waldoj commented 5 years ago

Unfortunately, the data provided in the repo doesn't include bills, just because that's a lot of data. I'm working on this in #209 — trying to figure out what minimum subset could be included to permit local testing.

Right now, there's no relevant code for this anywhere on the site — this is a notion of an entirely new page.