├── utils
├── __init__.py
├── plots
│ ├── __init__.py
│ ├── scatter.py
│ ├── bar.py
│ ├── wilkinson.py
│ └── line.py
├── get_data
│ ├── refresh_data.py
│ ├── query_forum.py
│ ├── query_gwwc.py
│ ├── open_phil.py
│ └── data_scraping.py
└── subtitle.py
├── components
├── sections
│ ├── __init__.py
│ ├── gwwc_donation_orgs.py
│ ├── gwwc_donation_growth.py
│ ├── gwwc_pledges.py
│ ├── growth.py
│ ├── demographics.py
│ ├── geography.py
│ ├── donations_sankey.py
│ ├── open_phil.py
│ └── forum.py
├── about.py
├── body.py
├── header.py
└── sidebar.py
├── Procfile
├── eadata.png
├── assets
├── logo.png
├── favicon.ico
├── data
│ ├── rp_survey_2019.xlsx
│ ├── rp_survey_data_2019
│ │ ├── survey_year.csv
│ │ ├── gender.csv
│ │ ├── education2.csv
│ │ ├── age_group.csv
│ │ ├── country.csv
│ │ ├── diet.csv
│ │ ├── moral_view.csv
│ │ ├── political_belief.csv
│ │ ├── religion.csv
│ │ ├── ethnicity.csv
│ │ ├── education.csv
│ │ ├── employment.csv
│ │ ├── career_path.csv
│ │ ├── subject.csv
│ │ ├── lean_towards.csv
│ │ ├── work_experience.csv
│ │ └── country2.csv
│ ├── misc.csv
│ ├── is_ea_growing
│ │ ├── is_ea_growing_commiting.csv
│ │ ├── is_ea_growing_reading.csv
│ │ ├── is_ea_growing_joining.csv
│ │ └── is_ea_growing_doing.csv
│ ├── gwwc
│ │ ├── donations_by_year.json
│ │ └── new_pledges.json
│ └── ea_funds_grants.csv
├── hamburger-menu-2.svg
├── hamburger-menu.svg
├── moon.svg
├── question-mark.svg
├── sun.svg
├── main.js
└── style.css
├── Pipfile
├── app.py
├── .gitignore
├── README.md
├── Pipfile.lock
└── LICENSE
/utils/__init__.py:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/utils/plots/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/components/sections/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Procfile:
--------------------------------------------------------------------------------
1 | web: gunicorn app:server
2 |
--------------------------------------------------------------------------------
/eadata.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hamishhuggard/ea_data_viz/HEAD/eadata.png
--------------------------------------------------------------------------------
/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hamishhuggard/ea_data_viz/HEAD/assets/logo.png
--------------------------------------------------------------------------------
/assets/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hamishhuggard/ea_data_viz/HEAD/assets/favicon.ico
--------------------------------------------------------------------------------
/assets/data/rp_survey_2019.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hamishhuggard/ea_data_viz/HEAD/assets/data/rp_survey_2019.xlsx
--------------------------------------------------------------------------------
/assets/data/rp_survey_data_2019/survey_year.csv:
--------------------------------------------------------------------------------
1 | Survey Year Mean Median
2 | 2015 28 26
3 | 2017 32 29
4 | 2018 32 29
5 | 2019 31 28
6 |
--------------------------------------------------------------------------------
/assets/data/rp_survey_data_2019/gender.csv:
--------------------------------------------------------------------------------
1 | Gender Responses Percent
2 | Male 1343 70.9%
3 | Female 509 26.9%
4 | Other 41 2.2%
5 | Total 1893 100.0%
6 |
--------------------------------------------------------------------------------
/assets/data/misc.csv:
--------------------------------------------------------------------------------
1 | Source,Cause Area,Organization,Amount
2 | Giving What We Can,Unknown,Unknowns,126751939
3 | Founders Pledge,Unknown,Unknowns,435000000
--------------------------------------------------------------------------------
/assets/data/rp_survey_data_2019/education2.csv:
--------------------------------------------------------------------------------
1 | Education Responses Percent
2 | Non-College 13 0.5%
3 | Bachelor's 821 31.9%
4 | Master's 593 23.0%
5 | PhD 306 11.9%
6 | Other College 842 32.7%
7 | Total 2575 100.0%
8 |
--------------------------------------------------------------------------------
/assets/data/rp_survey_data_2019/age_group.csv:
--------------------------------------------------------------------------------
1 | Age Group Responses Percent
2 | 13-17 10 0.5%
3 | 18-24 506 26.8%
4 | 25-34 971 51.5%
5 | 35-44 233 12.4%
6 | 45-54 82 4.3%
7 | 55-64 43 2.3%
8 | 65+ 41 2.2%
9 | Total 1886
10 |
--------------------------------------------------------------------------------
/assets/data/rp_survey_data_2019/country.csv:
--------------------------------------------------------------------------------
1 | Country Responses Percent
2 | USA 754 39.3%
3 | UK 313 16.3%
4 | Germany 140 7.3%
5 | Australia 131 6.8%
6 | Canada 84 4.4%
7 | All other stated countries 496 25.9%
8 | Total respondents 1,920
9 |
--------------------------------------------------------------------------------
/assets/data/rp_survey_data_2019/diet.csv:
--------------------------------------------------------------------------------
1 | Diet Responses Percent
2 | Eat meat, but try to reduce the amount 604 31.1%
3 | Vegan 451 23.2%
4 | Vegetarian 447 23.0%
5 | Eat meat 228 11.7%
6 | Other (please specify) 108 5.6%
7 | Pescetarian 107 5.5%
8 | Total 1945
9 |
--------------------------------------------------------------------------------
/assets/data/rp_survey_data_2019/moral_view.csv:
--------------------------------------------------------------------------------
1 | Moral View Responses Percent
2 | Consequentialism (utilitarian) 947 69.6%
3 | Consequentualism (other than utilitarian) 151 11.1%
4 | Deontology 44 3.2%
5 | Virtue ethics 99 7.3%
6 | Other 119 8.8%
7 | Total 1,360
8 |
--------------------------------------------------------------------------------
/assets/data/rp_survey_data_2019/political_belief.csv:
--------------------------------------------------------------------------------
1 | Political Belief Responses Percent
2 | Left 578 31.8%
3 | Center Left 731 40.3%
4 | Center 160 8.8%
5 | Center Right 46 2.5%
6 | Right 17 0.9%
7 | Libertarian 158 8.7%
8 | Other 126 6.9%
9 | Total 1,816
10 |
--------------------------------------------------------------------------------
/assets/data/rp_survey_data_2019/religion.csv:
--------------------------------------------------------------------------------
1 | Religion Responses Percent
2 | Atheist, agnostic, or non-religious 1,625 85.9%
3 | Christian 198 10.5%
4 | Buddhist 103 5.4%
5 | Other 56 3.0%
6 | Jewish 53 2.8%
7 | Hindu 11 0.6%
8 | Muslim 4 0.2%
9 | Sikh 2 0.1%
10 | Total 1,892
11 |
--------------------------------------------------------------------------------
/assets/data/is_ea_growing/is_ea_growing_commiting.csv:
--------------------------------------------------------------------------------
1 | Type of data,Jan-Dec 2014,2015,2016,2017,2018
2 | EA Survey respondents who identify as EA,1457 respondents,2240,No survey,1801,2576
3 | GWWC pledges,+396 members,642,949,909,606
4 | OFTW pledges,24,48,136,159,652
5 | Founder’s Pledge pledges,Didn’t exist,+$90M,+$120M,+$231M,+$547M
6 |
--------------------------------------------------------------------------------
/assets/data/rp_survey_data_2019/ethnicity.csv:
--------------------------------------------------------------------------------
1 | Race/Ethnicity Responses Percent
2 | White 1,621 86.9%
3 | Asian 185 9.9%
4 | Hispanic, Latino or Spanish Origin 88 4.7%
5 | Other 75 4.0%
6 | Black or African American 26 1.4%
7 | Native Hawaiian or Other Pacific Islander 5 0.3%
8 | American Indian or Alaskan Native 4 0.2%
9 | Total 1,866
10 |
--------------------------------------------------------------------------------
/Pipfile:
--------------------------------------------------------------------------------
1 | [[source]]
2 | url = "https://pypi.org/simple"
3 | verify_ssl = true
4 | name = "pypi"
5 |
6 | [packages]
7 | dash = "*"
8 | pandas = "*"
9 | gunicorn = "*"
10 | countryinfo = "*"
11 | bs4 = "*"
12 | requests = "*"
13 | dash-dangerously-set-inner-html = "*"
14 |
15 | [dev-packages]
16 |
17 | [requires]
18 | python_version = "3.9"
19 |
--------------------------------------------------------------------------------
/assets/hamburger-menu-2.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/hamburger-menu.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/data/rp_survey_data_2019/education.csv:
--------------------------------------------------------------------------------
1 | Education Responses Percent
2 | Some high school 13 0.7%
3 | High school graduate 30 1.5%
4 | Some college, no degree 83 4.2%
5 | Associate's degree 21 1.1%
6 | Bachelor's degree 821 41.9%
7 | Professional degree 94 4.8%
8 | Master's degree 593 30.2%
9 | Doctoral degree 306 15.6%
10 | Total respondents 1,961
11 |
--------------------------------------------------------------------------------
/utils/get_data/refresh_data.py:
--------------------------------------------------------------------------------
1 | import utils.get_data.data_scraping as data_scraping
2 | import os
3 | import time
4 |
5 | most_recent_refresh = None
6 |
7 | def refresh_data():
8 | global most_recent_refresh
9 | if most_recent_refresh and time.time() - most_recent_refresh < 60*60:
10 | return
11 | most_recent_refresh = time.time()
12 |
13 |
14 |
--------------------------------------------------------------------------------
/assets/data/rp_survey_data_2019/employment.csv:
--------------------------------------------------------------------------------
1 | Employment Type Responses Percent
2 | Employed, Full-Time 970 49.7%
3 | Student, Full-Time 525 26.9%
4 | Employed, Part-Time 216 11.1%
5 | Self-Employed 184 9.4%
6 | Not employed, but looking for work 108 5.5%
7 | Student, Part-Time 88 4.5%
8 | Retired 56 2.9%
9 | Not employed, but not looking for work 32 1.6%
10 | Homemaker 11 0.6%
11 | Total 1,953
12 |
--------------------------------------------------------------------------------
/assets/data/rp_survey_data_2019/career_path.csv:
--------------------------------------------------------------------------------
1 | Career path Responses Percent
2 | For-profit (earning to give) 709 37.8%
3 | Work at a non-profit (EA organization) 688 36.6%
4 | Academia 540 28.8%
5 | Think tanks / lobbying / advocacy 423 22.5%
6 | Government 368 19.6%
7 | For-profit (not earning to give) 347 18.5%
8 | Work at a non-profit (not an EA organization) 317 16.9%
9 | Other 185 9.9%
10 | Total 1,878
11 |
--------------------------------------------------------------------------------
/assets/data/rp_survey_data_2019/subject.csv:
--------------------------------------------------------------------------------
1 | Subject Studied Responses Percent
2 | Computer Science 468 24.4%
3 | Math 335 17.5%
4 | Economics 315 16.4%
5 | Social Science 272 14.2%
6 | Philosophy 256 13.4%
7 | Arts & Humanities 251 13.1%
8 | Sciences 201 10.5%
9 | Engineering 200 10.4%
10 | Physics 164 8.6%
11 | Psychology 144 7.5%
12 | Medicine 70 3.7%
13 | Professional or vocational qualification 59 3.1%
14 | Total 1,916
15 |
--------------------------------------------------------------------------------
/assets/data/rp_survey_data_2019/lean_towards.csv:
--------------------------------------------------------------------------------
1 | Lean towards Responses Percent
2 | Strongly lean towards negative utilitarianism (reducing suffering is all that matters morally) 56 4.5%
3 | Lean towards negative utilitarianism (reducing suffering is all that matters morally) 293 23.8%
4 | Lean towards classical utilitarianism (reducing suffering and increasing happiness matter equally) 534 43.3%
5 | Strongly lean towards classical utilitarianism (reducing suffering and increasing happiness matter equally) 261 21.2%
6 | Other 89 7.2%
7 | Total 1233
8 |
--------------------------------------------------------------------------------
/assets/data/is_ea_growing/is_ea_growing_reading.csv:
--------------------------------------------------------------------------------
1 | Type of data,Jan-Dec 2014,2015,2016,2017,2018
2 | Google interest in “effective altruism” (relative scoring),22,65,75,74,62
3 | Pageviews of Wikipedia article for “effective altruism”,33.9K,63.1K,71.5K,76.7K,69.5K
4 | 80K pageviews,136525,475487,889630,1583322,1634192
5 | EA Forum pageviews,No data,336175,311281,No data yet,No data yet
6 | EA Reddit Pageviews,No data,No data,No data,"~65,350",154804
7 | TLYCS web traffic (excluding adwords),154508,292092,396195,367375,279077
8 | GiveWell monthly unique visitors (excluding adwords),642252,766646,701518,698813,No data
9 |
--------------------------------------------------------------------------------
/assets/data/is_ea_growing/is_ea_growing_joining.csv:
--------------------------------------------------------------------------------
1 | Type of data,Jan-Dec 2014,2015,2016,2017,2018
2 | Vox Future Perfect Newsletter sign-ups,Didn’t exist,Didn’t exist,Didn’t exist,Didn’t exist,~10K subscribers
3 | New EA Reddit subscribers,+423 subscribers,236,106,1227,1527
4 | EA Newsletter sign-ups,Didn’t exist,+ ~6522 signups,+ ~3322,"+ ~20,600",+ ~4500
5 | 80K Newsletter signups,+2125 subscribers,20810,58815,104428,62730
6 | 80K podcast listeners,Didn’t exist,Didn’t exist,Didn’t exist,"4600 subscribers",+5900
7 | Total 80K engagement hours,2793 hours,11998,28663,86179,141030
8 | EA FB “Active Users”,No data,No data,No data,No data,475
9 | EA FB membership,No data,No data,No data,+1812 members,1915
10 | EA Forum accounts,No data yet,No data yet,No data yet,No data yet,No data yet
11 |
--------------------------------------------------------------------------------
/assets/data/rp_survey_data_2019/work_experience.csv:
--------------------------------------------------------------------------------
1 | Work experience Responses Percent
2 | Software engineering 328 27.2%
3 | Management 214 17.7%
4 | Maths and statistics 202 16.7%
5 | Web development 152 12.6%
6 | Consulting 135 11.2%
7 | Operations 131 10.9%
8 | Government and policy 118 9.8%
9 | Life sciences 112 9.3%
10 | Machine learning 103 8.5%
11 | Administration and office management 92 7.6%
12 | Marketing and outreach 90 7.5%
13 | Economics 90 7.5%
14 | Movement building, public speaking and campaigning 84 7.0%
15 | Generalist research (e.g. similar to GiveWell) 76 6.3%
16 | Communications (excluding movement building and marketing) 72 6.0%
17 | Philosophy 68 5.6%
18 | International development 66 5.5%
19 | Law 57 4.7%
20 | Asset management inc. quant trading 41 3.4%
21 | Personal assistance 25 2.1%
22 | Accounting 24 2.0%
23 | AI technical safety 13 1.1%
24 | Total 1,206
25 |
--------------------------------------------------------------------------------
/assets/moon.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
--------------------------------------------------------------------------------
/assets/data/is_ea_growing/is_ea_growing_doing.csv:
--------------------------------------------------------------------------------
1 | Type of data,Jan-Dec 2014,2015,2016,2017,2018
2 | Donations recorded in EA Survey,$6.8M,$6.7M,$9.9M,$18M,No data yet
3 | # donors in EA Survey,577,688,704,730,No data yet
4 | Non-OpenPhil GiveWell donations,$13.3M,$40M,$38.2M,$42.4M,No data yet
5 | OpenPhil GiveWell donations,$8M,$70M,$50M,$75.1M,No data yet
6 | Total non-OpenPhil donors to GiveWell,9044,14287,17829,23049,No data yet
7 | Total OpenPhil non-GiveWell donations,$7.84M,$7.66M,$71.94M,$187.48M,$104.84M
8 | Total recorded money actually donated (not pledges) from Giving What We Can members,$4.04M,$7.24M,$8.11M,$9.38M,$7.91M
9 | TLYCS money moved,$830K,$1.63M,$2.7M,$3.75M,$5.4M
10 | ACE money moved[x],$147K,$1.34M,$3.57M,$6.09M,No data
11 | EA Funds payouts[y],Didn’t exist,Didn’t exist,Didn’t exist,$826K,$5.5M
12 | "Number of 80,000 Hours significant plan changes (impact adjusted)",266 IASPC,614,1084,2211,~1676
13 | "Number of 80,000 Hours significant plan changes (not impact adjusted)",69 changes,158,669,685,~487
14 |
--------------------------------------------------------------------------------
/assets/data/rp_survey_data_2019/country2.csv:
--------------------------------------------------------------------------------
1 | Country,Responses
2 | United States of America,754
3 | UK,313
4 | Germany,140
5 | Australia,131
6 | Canada,84
7 | New Zealand,63
8 | Norway,41
9 | Switzerland,39
10 | Netherlands,36
11 | France,33
12 | Sweden,27
13 | Czech Republic,20
14 | Denmark,17
15 | Brazil,16
16 | China,16
17 | Spain,15
18 | Israel,14
19 | Austria,13
20 | Ireland,13
21 | Finland,11
22 | India,10
23 | Poland,10
24 | Singapore,9
25 | Italy,8
26 | Russian Federation,8
27 | Belgium,7
28 | Latvia,5
29 | Colombia,4
30 | Estonia,4
31 | Greece,4
32 | Argentina,3
33 | Hungary,3
34 | Japan,3
35 | Philippines,3
36 | Portugal,3
37 | Republic of Korea,3
38 | South Africa,3
39 | Uganda,3
40 | Egypt,2
41 | Lesotho,2
42 | Lithuania,2
43 | Luxembourg,2
44 | Mexico,2
45 | Slovakia,2
46 | United Arab Emirates,2
47 | Angola,1
48 | Belarus,1
49 | Burkina Faso,1
50 | Chile,1
51 | Ecuador,1
52 | Ethiopia,1
53 | Kazakhstan,1
54 | Malaysia,1
55 | Nigeria,1
56 | Oman,1
57 | Pakistan,1
58 | Papua New Guinea,1
59 | Romania,1
60 | Tanzania,1
61 | Vietnam,1
--------------------------------------------------------------------------------
/assets/data/gwwc/donations_by_year.json:
--------------------------------------------------------------------------------
1 | {"year":{"0":2009.0,"1":2010.0,"2":2011.0,"3":2012.0,"4":2013.0,"5":2014.0,"6":2015.0,"7":2016.0,"8":2017.0,"9":2018.0,"10":2019.0,"11":2020.0,"12":2021.0,"13":2022.0},"amount_normalized":{"0":39747.75,"1":165173.04,"2":808585.15,"3":1188216.7,"4":2145120.8399999999,"5":3404558.9900000002,"6":5545259.75,"7":6354225.1799999997,"8":7680776.4199999999,"9":10900372.9499999993,"10":18555044.6099999994,"11":21729164.1799999997,"12":10706931.3000000007,"13":12000.0},"num_donors":{"0":5,"1":18,"2":106,"3":136,"4":217,"5":480,"6":845,"7":1262,"8":1415,"9":1372,"10":1424,"11":2143,"12":2253,"13":1},"amount_normalized_year_to_current_month":{"0":14077.86,"1":95976.89,"2":203166.12,"3":398242.91,"4":969777.0699999999,"5":1789929.1399999999,"6":2969511.6499999999,"7":3094835.2999999998,"8":4797081.5499999998,"9":4448694.7400000002,"10":6924164.46,"11":11786053.7400000002,"12":10230452.6400000006,"13":12000.0},"donors_year_to_current_month":{"0":2,"1":10,"2":23,"3":53,"4":141,"5":304,"6":645,"7":990,"8":1191,"9":1084,"10":1087,"11":1512,"12":2208,"13":1}}
--------------------------------------------------------------------------------
/assets/question-mark.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
45 |
--------------------------------------------------------------------------------
/utils/get_data/query_forum.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import json
3 |
4 | # Queries can be tested at https://forum.effectivealtruism.org/graphiql
5 |
6 | forum_query = '''
7 | {
8 | posts (
9 | input: {
10 | terms: {
11 | offset:%d
12 | }
13 | }
14 | ) {
15 | results {
16 | title
17 | postedAt
18 | user {
19 | username
20 | displayName
21 | }
22 | coauthors {
23 | username
24 | displayName
25 | }
26 | pageUrl
27 | wordCount
28 | baseScore
29 | commentCount
30 | }
31 | }
32 | }
33 | '''
34 |
35 | def get_forum_data(offset=0):
36 | print(f'Getting forum data from offset={offset}')
37 | graphql_url = 'https://forum.effectivealtruism.org/graphql?'
38 | response = requests.post(graphql_url, json={'query': forum_query % offset})
39 | response_json = response.json()
40 | return response_json
41 |
42 | def refresh_forum_data():
43 |
44 | offset = 0
45 | forum_data = get_forum_data(offset)
46 |
47 | # the graphql only returns 5000 results at a time
48 | # so keep increment offset by 5000 until all data collected
49 | n_results = len(forum_data['data']['posts']['results'])
50 | while n_results == 5000:
51 | offset += 5000
52 | offset_forum_data = get_forum_data(offset)
53 | n_results = len(offset_forum_data['data']['posts']['results'])
54 |
55 | forum_data['data']['posts']['results'].extend(
56 | offset_forum_data['data']['posts']['results']
57 | )
58 |
59 | with open('./assets/data/ea_forum.json', 'w') as f:
60 | f.write(json.dumps(forum_data))
61 |
--------------------------------------------------------------------------------
/utils/get_data/query_gwwc.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import pandas as pd
3 |
4 | NEW_PLEDGES_URL = 'https://dashboard.effectivealtruism.org/api/public/card/a8499095-be16-46fe-af1f-e3e56ee04e88/query?parameters=%5B%5D'
5 | DONATIONS_BY_YEAR_URL = 'https://dashboard.effectivealtruism.org/api/public/card/9906735e-1350-4353-9828-bb3ec16137e3/query?parameters=%5B%5D'
6 | DONATIONS_BY_ORG_URL = 'https://dashboard.effectivealtruism.org/api/public/card/b3887098-686a-491c-9f9c-9a5b0e2b7fd8/query?parameters=%5B%5D'
7 |
8 | def request_data_and_parse(url):
9 | json_response = requests.get(url).json()
10 | col_data = json_response['data']['cols']
11 | col_names = [ col_details['name'] for col_details in col_data ]
12 | data = json_response['data']['rows']
13 | df = pd.DataFrame(columns = col_names, data = data)
14 | return df
15 |
16 | def get_new_pledges():
17 | df = request_data_and_parse(NEW_PLEDGES_URL)
18 | return df
19 |
20 | def get_donations_by_year():
21 | df = request_data_and_parse(DONATIONS_BY_YEAR_URL)
22 | return df
23 |
24 | def get_donations_by_org():
25 | df = request_data_and_parse(DONATIONS_BY_ORG_URL)
26 | return df
27 |
28 | def save_data():
29 | print('requesting new_pledges...')
30 | new_pledges = get_new_pledges()
31 | new_pledges.to_json('./assets/data/gwwc/new_pledges.json')
32 |
33 | print('requesting donations_by_year...')
34 | donations_by_year = get_donations_by_year()
35 | donations_by_year.to_json('./assets/data/gwwc/donations_by_year.json')
36 |
37 | print('requesting donations_by_org...')
38 | donations_by_org = get_donations_by_org()
39 | donations_by_org.to_json('./assets/data/gwwc/donations_by_org.json')
40 |
--------------------------------------------------------------------------------
/utils/plots/scatter.py:
--------------------------------------------------------------------------------
1 | import dash
2 | from dash import dcc
3 | import plotly.express as px
4 |
5 | class Scatter(dcc.Graph):
6 |
7 | def __init__(
8 | self,
9 | df,
10 | x='x',
11 | y='y',
12 | x_title='',
13 | y_title='',
14 | size=None,
15 | color=None,
16 | hover=None,
17 | title=None,
18 | text=None,
19 | log_y=False,
20 | transparent=True,
21 | ):
22 |
23 | fig = px.scatter(
24 | df,
25 | x = x,
26 | y = y,
27 | log_y = log_y,
28 | title = title,
29 | size = size,
30 | color = color,
31 | text = text,
32 | )
33 |
34 | fig.update_traces(
35 | marker_color = 'rgba(12, 134, 155, 0.6)' if transparent else "#0c869b",
36 | )
37 |
38 | if hover:
39 | fig.update_traces(
40 | hovertext = df[hover],
41 | hovertemplate = '%{hovertext}',
42 | )
43 |
44 | fig.update_layout(
45 | margin = dict(l=0, r=0, t=30, b=0),
46 | autosize = True,
47 | xaxis = dict(
48 | title = x_title,
49 | ),
50 | yaxis = dict(
51 | title = y_title,
52 | ),
53 | title_x = 0.5,
54 | font = dict(
55 | family = "Raleway",
56 | size = 12,
57 | )
58 | )
59 |
60 | fig.update_traces(textposition="middle right")
61 |
62 | super().__init__(
63 | figure = fig,
64 | responsive = True,
65 | )
66 |
--------------------------------------------------------------------------------
/assets/sun.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
--------------------------------------------------------------------------------
/utils/plots/bar.py:
--------------------------------------------------------------------------------
1 | import dash
2 | from dash import dcc
3 | from dash import html
4 | import plotly.graph_objects as go
5 | import plotly.express as px
6 |
7 | class Bar(dcc.Graph):
8 |
9 | def __init__(self, df, height=None, title=None):
10 |
11 | if 'text' in df.columns:
12 | text_col = 'text'
13 | else:
14 | text_col = 'y'
15 |
16 | if 'hover' in df.columns:
17 | hover_col = 'hover'
18 | else:
19 | hover_col = 'x'
20 |
21 | self.bar = px.bar(
22 | df,
23 | y='x',
24 | x='y',
25 | text=text_col,
26 | title=title,
27 | height=height,
28 | orientation='h',
29 | )
30 |
31 | self.bar.update_traces(
32 | marker_color="#0c869b",
33 | hovertext = df[hover_col],
34 | hovertemplate = '%{hovertext}',
35 | )
36 |
37 | self.bar.update_xaxes(side='top')
38 |
39 | self.bar.update_layout(
40 | margin=dict(l=0, r=0, t=30, b=0),
41 | xaxis=dict(
42 | title='',
43 | fixedrange=True
44 | ),
45 | yaxis=dict(
46 | title='',
47 | # dtick=1,
48 | fixedrange=True
49 | ),
50 | title_x=0.5,
51 | font=dict(
52 | family="Raleway",
53 | size=12,
54 | )
55 | )
56 |
57 | super().__init__(
58 | id=title,
59 | figure=self.bar,
60 | responsive=True,
61 | config={
62 | 'displayModeBar': False,
63 | },
64 | )
65 |
--------------------------------------------------------------------------------
/components/about.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import dash
4 | from dash import dcc
5 | from dash import html
6 |
7 | def about_box():
8 | return html.Div(
9 | [
10 | html.H4("About"),
11 | html.P(
12 | [
13 | html.A(
14 | "Effective Altruism",
15 | href="https://www.effectivealtruism.org/"
16 | ),
17 | ' (EA) is a movement that uses reason and evidence to do the most good.',
18 | ]
19 | ),
20 | html.P(
21 | 'This website aggregates and visualizes data from EA organisations, including grants, donors, and pledges.',
22 | ),
23 | html.P(
24 | [
25 | 'More information on this website can be found ',
26 | html.A(
27 | "here",
28 | href="https://forum.effectivealtruism.org/posts/CQaNyJfsRFZhseiLZ/effectivealtruismdata-com-a-website-for-aggregating-and"
29 | ),
30 | '.',
31 | ]
32 | ),
33 | html.P(
34 | [
35 | 'Source code is available on ',
36 | html.A(
37 | "GitHub",
38 | href="https://github.com/hamishhuggard/ea_data_viz"
39 | ),
40 | '.',
41 | ]
42 | ),
43 | html.P(
44 | [
45 | 'Please send feedback to ',
46 | html.A(
47 | "hamish.huggard@gmail.com",
48 | href="mailto:hamish.huggard@gmail.com"
49 | ),
50 | '.',
51 | ],
52 | ),
53 | ],
54 | id = 'about-box',
55 | className = 'hidden',
56 | )
57 |
--------------------------------------------------------------------------------
/assets/main.js:
--------------------------------------------------------------------------------
1 | function toggleSidebarVisible() {
2 |
3 | const sidebar = document.getElementById("sidebar");
4 | const buttress = document.getElementById("sidebar-buttress");
5 |
6 | if (sidebar.classList.contains("toggled")) {
7 | sidebar.classList.remove("toggled");
8 | buttress.classList.remove("toggled");
9 | } else {
10 | sidebar.classList.add("toggled");
11 | buttress.classList.add("toggled");
12 | }
13 |
14 | }
15 |
16 | function toggleAboutVisibility() {
17 |
18 | const about = document.getElementById("about-box");
19 |
20 | if (about.classList.contains("hidden")) {
21 | about.classList.remove("hidden");
22 | } else {
23 | about.classList.add("hidden");
24 | }
25 |
26 | }
27 |
28 |
29 | if (window.matchMedia("(max-media: 700px)").matches) {
30 | function mobileSidebar() {
31 |
32 | toggleSidebarVisible();
33 |
34 | }
35 | }
36 |
37 |
38 | // NIGHT MODE AND DAY MODE
39 |
40 | function setDarkMode() {
41 | document.body.classList.add("darkmode");
42 | const button = document.getElementById("darkmode-button");
43 | button.src = "/assets/sun.svg"
44 | button.classList.add("noprefer");
45 | }
46 |
47 | function setLightMode() {
48 | document.body.classList.remove("darkmode");
49 | const button = document.getElementById("darkmode-button");
50 | button.src = "/assets/moon.svg";
51 | button.classList.add("noprefer");
52 | }
53 |
54 | function toggleDarkMode() {
55 | if (document.body.classList.contains("darkmode"))
56 | setLightMode();
57 | else
58 | setDarkMode();
59 | }
60 |
61 | // Initial dark mode preference
62 | window.onload = () => {
63 | if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
64 | setDarkMode();
65 | }
66 | }
67 |
68 | // Detect changes in dark mode preferences
69 | window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
70 | if (e.matches)
71 | setDarkMode();
72 | else
73 | setLightMode();
74 | });
75 |
76 |
--------------------------------------------------------------------------------
/components/body.py:
--------------------------------------------------------------------------------
1 | import dash
2 | from dash import html
3 |
4 | from components.sections.forum import forum_scatter_section
5 | from components.sections.forum import forum_count_section
6 | from components.sections.forum import forum_post_wilkinson_section
7 | from components.sections.forum import forum_user_wilkinson_section
8 |
9 | from components.sections.donations_sankey import donations_sankey_section
10 |
11 | from components.sections.demographics import demographics_section
12 | from components.sections.demographics import beliefs_section
13 | from components.sections.demographics import education_section
14 | from components.sections.demographics import career_section
15 |
16 | from components.sections.gwwc_donation_growth import get_gwwc_donation_growth_section
17 | from components.sections.gwwc_pledges import get_gwwc_pledges_section
18 | from components.sections.gwwc_donation_orgs import get_gwwc_donations_orgs_section
19 |
20 | from components.sections.geography import country_total_section
21 | from components.sections.geography import country_per_capita_section
22 |
23 | from components.sections.open_phil import openphil_grants_scatter_section
24 | from components.sections.open_phil import openphil_grants_categories_section
25 | from components.sections.open_phil import openphil_line_plot_section
26 |
27 | def body():
28 | return html.Div(
29 | [
30 |
31 | donations_sankey_section(),
32 |
33 | openphil_grants_scatter_section(),
34 | openphil_grants_categories_section(),
35 | openphil_line_plot_section(),
36 |
37 | get_gwwc_pledges_section(),
38 | get_gwwc_donation_growth_section(),
39 | get_gwwc_donations_orgs_section(),
40 |
41 | country_total_section(),
42 | country_per_capita_section(),
43 |
44 | demographics_section(),
45 | beliefs_section(),
46 | education_section(),
47 | career_section(),
48 |
49 | forum_scatter_section(),
50 | forum_count_section(),
51 | forum_post_wilkinson_section(),
52 | forum_user_wilkinson_section(),
53 |
54 | ],
55 | className = 'content scroll-snapper',
56 | )
57 |
--------------------------------------------------------------------------------
/utils/plots/wilkinson.py:
--------------------------------------------------------------------------------
1 | from utils.plots.scatter import Scatter
2 | from collections import Counter
3 |
4 | class Wilkinson(Scatter):
5 |
6 | def __init__(
7 | self,
8 | df,
9 | value='value',
10 | bins=20,
11 | text=None,
12 | log_y=False,
13 | **kwargs,
14 | ):
15 |
16 | min_val = df[value].min()
17 | max_val = df[value].max()
18 | delta = (max_val - min_val) / bins
19 |
20 | def bin_value(value):
21 | num_deltas = round( (value - min_val) / delta )
22 | return min_val + delta * (num_deltas + 0.5)
23 |
24 | bin_col = f'{value}_bin'
25 | df[bin_col] = df[value].apply(bin_value)
26 |
27 | bin_counter = Counter()
28 | def get_count(value):
29 | bin_counter[value] += 1
30 | return bin_counter[value]
31 | count_col = f'{value}_count'
32 | df[count_col] = df[bin_col].apply(get_count)
33 |
34 | def trim_text(text, max_len):
35 | if len(text) < max_len:
36 | return text
37 | return text[:max_len-3] + '...'
38 |
39 | def get_text(row):
40 | bin_value = row[bin_col]
41 | row_count = row[count_col]
42 | display_text = row[text]
43 | # if the dot is in a row by itself then show its text
44 | if row_count == 1 and bin_counter[bin_value] == 1:
45 | return trim_text(display_text, 40)
46 | # if there are two dots in a row, show both of their text
47 | elif row_count == 2 and bin_counter[bin_value] == 2:
48 | other_text = df.loc[ (df[bin_col]==bin_value) & (df[count_col]==1), text ].iat[0]
49 | return trim_text(other_text, 20) + ', ' + trim_text(display_text, 20)
50 | # otherwise return an empty string
51 | else:
52 | return ''
53 |
54 | if text:
55 | text_col = f'{value}_text'
56 | df[text_col] = df.apply(get_text, axis=1)
57 | else:
58 | text_col = None
59 |
60 | super().__init__(
61 | df = df,
62 | y = bin_col,
63 | x = count_col,
64 | text = text_col,
65 | transparent = False,
66 | **kwargs,
67 | )
68 |
--------------------------------------------------------------------------------
/app.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # Run this app with `python app.py` and
4 | # visit http://127.0.0.1:8050/ in your web browser.
5 |
6 | import dash
7 | from dash import html
8 |
9 | from components.header import header
10 | from components.sidebar import sidebar
11 | from components.about import about_box
12 | from components.body import body
13 |
14 | from utils.get_data.refresh_data import refresh_data
15 | from dash.dependencies import Input, Output, State
16 | import visdcc
17 |
18 | app = dash.Dash(
19 | __name__,
20 | meta_tags = [
21 | {
22 | 'og:title': 'Effective Altruism Data',
23 | "og:url": "https://effectivealtruismdata.com",
24 | "og:site_name": "Effective Altruism Data",
25 | "og:image": "https://i.ibb.co/mqbpdXW/eadata.png",
26 | "og:image:width": "1440",
27 | "og:image:height": "630",
28 | "twitter:card": "summary_large_image",
29 | 'name': 'viewport',
30 | 'content': 'width=device-width, initial-scale=1.0',
31 | }
32 | ],
33 | )
34 | app.title = 'Effective Altruism Data'
35 | server = app.server
36 |
37 | # refresh_data()
38 |
39 | # def serve_layout():
40 | # return html.Div(
41 | app.layout = html.Div(
42 | [
43 | header(),
44 | html.Div(
45 | [
46 | html.Div(
47 | [
48 | sidebar(),
49 | ],
50 | ),
51 | about_box(),
52 | body(),
53 | visdcc.Run_js(id='javascript-body'),
54 | ],
55 | className = 'body',
56 | id = "sidebar-visdcc",
57 | )
58 | ],
59 | )
60 |
61 | @app.callback(
62 | Output('javascript-body', 'run'),
63 | [Input('sidebar-visdcc', 'n_clicks')])
64 | def sidebar(x):
65 | if x:
66 | return "document.getElementById('sidebar').setAttribute('onclick', 'mobileSidebar()')"
67 | return ""
68 |
69 | @app.callback(
70 | Output('javascript-header', 'run'),
71 | [Input('header-sidebar-visdcc', 'n_clicks')])
72 | def sidebar(x):
73 | if x:
74 | return "document.getElementById('sidebar').setAttribute('onclick', 'mobileSidebar()')"
75 | return ""
76 |
77 | # app.layout = serve_layout
78 |
79 | if __name__ == '__main__':
80 | #app.run_server(debug=True)
81 | app.run_server(debug=False)
82 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | .prettierignore
12 | build/
13 | develop-eggs/
14 | dist/
15 | downloads/
16 | eggs/
17 | .eggs/
18 | lib/
19 | lib64/
20 | parts/
21 | sdist/
22 | var/
23 | wheels/
24 | pip-wheel-metadata/
25 | share/python-wheels/
26 | *.egg-info/
27 | .installed.cfg
28 | *.egg
29 | MANIFEST
30 |
31 | # PyInstaller
32 | # Usually these files are written by a python script from a template
33 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
34 | *.manifest
35 | *.spec
36 |
37 | # Installer logs
38 | pip-log.txt
39 | pip-delete-this-directory.txt
40 |
41 | # Unit test / coverage reports
42 | htmlcov/
43 | .tox/
44 | .nox/
45 | .coverage
46 | .coverage.*
47 | .cache
48 | nosetests.xml
49 | coverage.xml
50 | *.cover
51 | *.py,cover
52 | .hypothesis/
53 | .pytest_cache/
54 |
55 | # Translations
56 | *.mo
57 | *.pot
58 |
59 | # Django stuff:
60 | *.log
61 | local_settings.py
62 | db.sqlite3
63 | db.sqlite3-journal
64 |
65 | # Flask stuff:
66 | instance/
67 | .webassets-cache
68 |
69 | # Scrapy stuff:
70 | .scrapy
71 |
72 | # Sphinx documentation
73 | docs/_build/
74 |
75 | # PyBuilder
76 | target/
77 |
78 | # Jupyter Notebook
79 | .ipynb_checkpoints
80 |
81 | # IPython
82 | profile_default/
83 | ipython_config.py
84 |
85 | # pyenv
86 | .python-version
87 |
88 | # pipenv
89 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
90 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
91 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
92 | # install all needed dependencies.
93 | #Pipfile.lock
94 |
95 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow
96 | __pypackages__/
97 |
98 | # Celery stuff
99 | celerybeat-schedule
100 | celerybeat.pid
101 |
102 | # SageMath parsed files
103 | *.sage.py
104 |
105 | # Environments
106 | .env
107 | .venv
108 | env/
109 | venv/
110 | ENV/
111 | env.bak/
112 | venv.bak/
113 |
114 | # Spyder project settings
115 | .spyderproject
116 | .spyproject
117 |
118 | # Rope project settings
119 | .ropeproject
120 |
121 | # mkdocs documentation
122 | /site
123 |
124 | # mypy
125 | .mypy_cache/
126 | .dmypy.json
127 | dmypy.json
128 |
129 | # Pyre type checker
130 | .pyre/
131 |
--------------------------------------------------------------------------------
/utils/get_data/open_phil.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import os
3 |
4 | def download_grants():
5 | openphil_url = 'https://www.openphilanthropy.org/giving/grants/spreadsheet'
6 | print('Downloading Open Philanthropy grants...')
7 | return requests.get(openphil_url, headers={'User-Agent': ''}).text
8 |
9 | def save_grants():
10 |
11 | data_dir = os.path.abspath('./assets/data/open_philanthropy/')
12 | if not os.path.exists(data_dir):
13 | os.path.makedirs(data_dir)
14 |
15 | grants_raw = download_grants()
16 | print('latest OP grant: ', new_op_data.split('\n')[1])
17 | grants_path = os.path.join(data_dir, 'open_philanthropy_grants.csv')
18 | with open(grants_path, 'w') as f:
19 | f.write(grants_raw)
20 |
21 | def process_grants(grants_df):
22 |
23 | grants_df['Amount'] = grants_df['Amount'].apply(
24 | lambda x: int(x[1:].replace(',','')) if type(x)==str else x
25 | )
26 |
27 | def normalize_orgname(orgname):
28 | if type(orgname) == str:
29 | orgname = orgname.strip()
30 | if orgname == 'Hellen Keller International':
31 | orgname = 'Helen Keller International'
32 | if orgname == 'Alliance for Safety and Justice':
33 | orgname = 'Alliance for Safety and Justice Action Fund'
34 | return orgname
35 | op_grants['Organization Name'] = op_grants['Organization Name'].apply(normalize_orgname)
36 |
37 | op_grants['Date'] = pd.to_datetime(op_grants['Date'], format='%m/%Y')
38 | op_grants = op_grants.sort_values(by='Date', ascending=False)
39 | op_grants['Date_readable'] = op_grants['Date'].dt.strftime('%B %Y')
40 |
41 | def group_by_month(grants_df):
42 |
43 | min_date = grants_df['Date'].min()
44 | max_date = grants_df['Date'].max()
45 | dates = pd.date_range(start=min_date, end=max_date, freq='M')
46 |
47 | grants_by_month = pd.DataFrame(columns=[
48 | 'date',
49 | 'total_amount',
50 | 'n_grants',
51 | ])
52 |
53 | for i, date in enumerate(dates):
54 | grants_by_month_i = grants_df.loc[ grants_df['Date'] == date ]
55 | grants_by_month.loc[i, 'date'] = date
56 | grants_by_month.loc[i, 'total_amount'] = grants_by_month_i['Amount'].sum()
57 | grants_by_month.loc[i, 'n_grants'] = len(grants_by_month_i)
58 |
59 | return grants_by_month
60 |
61 | def group_by_org(grants_df):
62 | orgs_df = op_grants.groupby(by='Organization Name', as_index=False).sum()
63 | orgs_df = orgs_df.sort_values(by='Amount')
64 |
65 | def group_by_focus_area(grants_df):
66 | orgs_df = op_grants.groupby(by='Organization Name', as_index=False).sum()
67 | orgs_df = orgs_df.sort_values(by='Amount')
68 |
--------------------------------------------------------------------------------
/components/sections/gwwc_donation_orgs.py:
--------------------------------------------------------------------------------
1 | import pandas as pd
2 | from dash import html
3 | from utils.subtitle import get_data_source
4 | from utils.subtitle import get_instructions
5 | from utils.plots.bar import Bar
6 | from utils.get_data.query_gwwc import get_donations_by_org
7 |
8 | def get_hover(row):
9 |
10 | amount = row['Amount (USD)']
11 |
12 | result = ''
13 | result += f"{row.Organisation}"
14 | result += f"
${amount:,.2f} donated"
15 | result += f"
{row.Donors} donors"
16 | result += f"
{row.Donations} donations"
17 |
18 | return result
19 |
20 | def get_top_orgs_by_amount(donations_by_org):
21 | donations_by_org = donations_by_org.sort_values(by='Amount (USD)', ascending=False)
22 | donations_by_org = donations_by_org.reset_index()
23 | donations_by_org = donations_by_org.iloc[:20]
24 | donations_by_org = donations_by_org.iloc[::-1]
25 | donations_by_org['y'] = donations_by_org['Amount (USD)']
26 | donations_by_org['x'] = donations_by_org['Organisation']
27 | donations_by_org['hover'] = donations_by_org.apply(get_hover, axis=1)
28 | donations_by_org['text'] = donations_by_org['Amount (USD)'].apply(lambda x: f'${x:,.2f}')
29 | return Bar(donations_by_org, title='Top Organizations by Amount')
30 |
31 | def get_top_orgs_by_num_donors(donations_by_org):
32 | donations_by_org = donations_by_org.sort_values(by='Donors', ascending=False)
33 | donations_by_org = donations_by_org.reset_index()
34 | donations_by_org = donations_by_org.iloc[:20]
35 | donations_by_org = donations_by_org.iloc[::-1]
36 | donations_by_org['y'] = donations_by_org['Donors']
37 | donations_by_org['x'] = donations_by_org['Organisation']
38 | donations_by_org['hover'] = donations_by_org.apply(get_hover, axis=1)
39 | donations_by_org['text'] = donations_by_org['Donors'].apply(lambda x: f'{x:,}')
40 | return Bar(donations_by_org, title='Top Organizations by Number of Donors')
41 |
42 |
43 | def get_gwwc_donations_orgs_section():
44 |
45 | donations_by_org = pd.read_json('./assets/data/gwwc/donations_by_org.json')
46 | #donations_by_org = get_donations_by_org()
47 |
48 | return html.Div(
49 | [
50 | html.Div(
51 | html.H2('Giving What We Can Donations by Organization'),
52 | className='section-heading',
53 | ),
54 | get_instructions(hover='points', zoom=True),
55 | html.Div(
56 | [
57 | get_top_orgs_by_amount(donations_by_org),
58 | get_top_orgs_by_num_donors(donations_by_org),
59 | ],
60 | className='grid tab-cols-2 desk-cols-2 section-body'
61 | ),
62 | get_data_source('gwwc_orgs'),
63 | ],
64 | className = 'section',
65 | id='gwwc-orgs-section',
66 | )
67 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # [Effective Altruism Data](https://effectivealtruismdata.com)
2 |
3 | 
4 |
5 | [Effective Altruism](https://www.effectivealtruism.org/) (EA) is a philosophy and social movement that uses reason and evidence to do the most good.
6 |
7 | There are several EA organisations that collect data on grants, donors, and pledges. This website aggregates and visualises that data.
8 |
9 | The website is coded in Python using [Dash](https://dash.plotly.com/) and [Plotly](https://plotly.com/). It is currently deployed with Heroku at [effectivealtruismdata.com](https://effectivealtruismdata.com).
10 |
11 | There may be some overlap between this project and with the [EA Hub map](https://eahub.org/) and the [EA Funds dashboard](https://app.effectivealtruism.org/funds/about/stats).
12 |
13 | ## How to run
14 |
15 | 1. Make sure that you have Python 3.9 installed in your system.
16 |
17 | - Otherwise, install it, e.g., with `sudo apt install python3.9` on Debian-based Linux sytems.
18 |
19 | 1. Install [pipenv](https://pipenv.pypa.io/en/latest/). If you have `pip` installed, this looks like:
20 |
21 | ```
22 | pip install --user pipenv
23 | ```
24 |
25 | 2. Run the following in the terminal:
26 |
27 | ```
28 | git clone https://github.com/hamishhuggard/ea_data_viz.git
29 | cd ea_data_viz
30 | pipenv run python app.py
31 | ```
32 |
33 | You can also specify a particular path for python on pipenv with:
34 |
35 | ```
36 | pipenv --python /usr/bin/python3.9 run python app.py
37 |
38 | ```
39 |
40 | ## To do
41 |
42 | ### Version 1 (Current Version)
43 |
44 | - Download links
45 | - Data refreshing
46 | - Analytics
47 | - OP Wilkinson Plots
48 | - Grants by size and by time
49 | - Organizations by #grants and by total amount
50 | - EA Funds
51 | - Scatter
52 | - Cumulative grants
53 | - Grants by month/year
54 | - Founders pledge
55 | - Members over time
56 | - Pledged value over time
57 | - Fulfilled commitments over time
58 | - Title page with summary statistics
59 | - X EAs have donated Y amount and pledged a further Z.
60 | - Probabilities of x-risks given by Toby Ord
61 | - Global Poverty
62 | - Cost to save a life with most effective charities
63 | - Value of Future
64 | - People currently alive
65 | - People who have ever lived
66 | - Projected peak population
67 | - Potential future earth people
68 | - Potential future space people
69 | - Potential future virtual people
70 | - Animals
71 | - Most effective animal interventions
72 | - Number of animals in factory farms
73 | - Most effective diet interventions
74 | - [Key EA numbers](https://github.com/benthamite/EA-numbers/blob/main/source.org)
75 | - Spin off data aggregation to own Python library
76 | - [Better bar charts](https://dkane.net/2020/better-horizontal-bar-charts-with-plotly/?utm_source=pocket_mylist)
77 | - Space efficient data source annotations
78 |
79 | ### Version 2
80 |
81 | - Reimplement in chart.js or D3.js
82 | - See data as table or as plot
83 | - Data download buttons
84 |
--------------------------------------------------------------------------------
/assets/data/ea_funds_grants.csv:
--------------------------------------------------------------------------------
1 | fund,amount,date,title
2 | global-development,2000000,2020-07-29 00:00:00,July 2020: Innovations for Poverty Action
3 | global-development,656000,2020-06-30 00:00:00,June 2020: IDinsight
4 | global-development,0,2020-01-29 00:00:00,January 2020: Existing funds rolled forward
5 | global-development,355000,2019-10-25 00:00:00,October 2019: One for the World
6 | global-development,1005716,2019-08-14 00:00:00,August 2019: Fortify Health
7 | global-development,60000,2019-04-30 00:00:00,April 2019: Instiglio
8 | global-development,1705000,2019-03-13 00:00:00,March 2019: Malaria Consortium
9 | global-development,1000000,2019-01-30 00:00:00,January 2019: J-PAL's Innovation in Government Initiative
10 | global-development,1500000,2018-05-01 00:00:00,April 2018: Schistosomiasis Control Initiative
11 | global-development,150000,2017-10-18 00:00:00,September 2017: No Lean Season
12 | global-development,331126,2017-06-28 00:00:00,April 2017: Against Malaria Foundation
13 | animal-welfare,680000,2020-08-07 00:00:00,July 2020: Animal Welfare Fund Grants
14 | animal-welfare,671000,2020-03-27 00:00:00,March 2020: Animal Welfare Fund Grants
15 | animal-welfare,415000,2019-11-22 00:00:00,November 2019: Animal Welfare Fund Grants
16 | animal-welfare,440000,2019-08-24 00:00:00,July 2019: Animal Welfare Fund Grants
17 | animal-welfare,445000,2019-03-07 00:00:00,March 2019: Animal Welfare Fund Grants
18 | animal-welfare,341000,2018-12-31 00:00:00,December 2018: Animal Welfare Fund Grants
19 | animal-welfare,1205000,2018-08-01 00:00:00,June 2018: Animal Welfare Fund Grants
20 | animal-welfare,750000,2018-05-01 00:00:00,March 2018: Animal Welfare Fund Grants
21 | animal-welfare,150000,2018-01-15 00:00:00,November 2017: Animal Welfare Fund Grants
22 | animal-welfare,180000,2017-04-15 00:00:00,April 2017: Animal Welfare Fund Grants
23 | far-future,488350,2020-04-15 00:00:00,April 2020: Long-Term Future Fund Grants and Recommendations
24 | far-future,466000,2019-11-22 00:00:00,November 2019: Long-Term Future Fund Grants
25 | far-future,415697,2019-08-31 00:00:00,August 2019: Long-Term Future Fund Grants and Recommendations
26 | far-future,875150,2019-03-21 00:00:00,April 2019: Long-Term Future Fund Grants and Recommendations
27 | far-future,95500,2018-11-30 00:00:00,November 2018: Long-Term Future Fund Grants
28 | far-future,917000,2018-08-15 00:00:00,July 2018: Long-Term Future Fund Grants
29 | far-future,14838,2017-03-21 00:00:00,March 2017: Berkeley Existential Risk Initiative (BERI)
30 | ea-community,838000,2020-08-07 00:00:00,July 2020: EA Meta Fund Grants
31 | ea-community,522000,2020-03-27 00:00:00,March 2020: EA Meta Fund Grants
32 | ea-community,330000,2019-11-22 00:00:00,November 2019: EA Meta Fund Grants
33 | ea-community,466000,2019-08-24 00:00:00,July 2019: EA Meta Fund Grants
34 | ea-community,512000,2019-03-08 00:00:00,March 2019: EA Meta Fund Grants
35 | ea-community,129000,2018-11-30 00:00:00,November 2018: EA Meta Fund Grants
36 | ea-community,526000,2018-08-15 00:00:00,July 2018: EA Meta Fund Grants
37 | ea-community,83264,2018-01-15 00:00:00,December 2017: EA Sweden Grant
38 |
--------------------------------------------------------------------------------
/utils/plots/line.py:
--------------------------------------------------------------------------------
1 | import plotly.express as px
2 | import plotly.graph_objects as go
3 | from dash import dcc
4 | from dash import html
5 |
6 | class Line(dcc.Graph):
7 |
8 | def __init__(
9 | self,
10 | df,
11 | x='x',
12 | y='y',
13 | label='label',
14 | hover='hover',
15 | title=None,
16 | x_title='',
17 | y_title='',
18 | size=None,
19 | color=None,
20 | log_y=False,
21 | dollars=False,
22 | xanchor='right',
23 | yanchor='bottom',
24 | ):
25 |
26 | fig = go.Figure()
27 |
28 | annotations = []
29 | for val in df[label].unique():
30 |
31 | val_df = df.loc[ df[label]==val ]
32 | val_df = val_df.sort_values(by=[x,y])
33 |
34 | fig.add_trace(
35 | go.Scatter(
36 | x=val_df[x],
37 | y=val_df[y],
38 | name=val,
39 | hovertext = val_df[hover],
40 | hovertemplate = '%{hovertext}',
41 | mode='lines',
42 | line=dict(
43 | color="#0c869b",
44 | ),
45 | )
46 | )
47 |
48 | val_df = val_df.loc[ val_df[y].notnull() ].reset_index()
49 | last_row = val_df.iloc[len(val_df)-1]
50 | last_hover = last_row[hover]
51 |
52 | fig.add_trace(go.Scatter(
53 | x=[ last_row[x] ],
54 | y=[ last_row[y] ],
55 | mode='markers',
56 | marker=dict(
57 | color="#0c869b",
58 | size=10,
59 | ),
60 | hovertext = [last_hover],
61 | hovertemplate = '%{hovertext}',
62 | ))
63 |
64 | annotations.append(dict(
65 | x=last_row[x],
66 | y=last_row[y],
67 | xanchor=xanchor,
68 | yanchor=yanchor,
69 | text=f' {val}',
70 | font={
71 | 'size': 13,
72 | },
73 | showarrow=False,
74 | ))
75 |
76 | if log_y:
77 | fig.update_layout(
78 | yaxis_type="log",
79 | )
80 |
81 | if dollars:
82 | fig.update_layout(
83 | yaxis_tickprefix = '$',
84 | )
85 |
86 | top_margin = 40 if title else 0
87 | fig.update_layout(
88 | title=title,
89 | showlegend=False,
90 | xaxis = dict(
91 | title = x_title,
92 | ),
93 | yaxis = dict(
94 | title = y_title,
95 | ),
96 | annotations=annotations,
97 | margin=dict(l=0, r=0, t=top_margin, b=0),
98 | title_x=0.5,
99 | )
100 |
101 | super().__init__(
102 | figure=fig,
103 | responsive=True
104 | )
105 |
106 |
--------------------------------------------------------------------------------
/components/header.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import dash
4 | from dash import dcc
5 | from dash import html
6 | import dash_dangerously_set_inner_html
7 | import visdcc
8 |
9 | def header():
10 |
11 | lightbulb_img_url = '/assets/logo.png'
12 | hamburger_img_url = '/assets/hamburger-menu.svg'
13 |
14 | return html.Div(
15 | [
16 | #html.Img(
17 | # src = hamburger_img_url,
18 | # className='hamburger',
19 | #),
20 | html.Div(
21 | dash_dangerously_set_inner_html.DangerouslySetInnerHTML('''
22 |
28 | '''),
29 | className='icon',
30 | ),
31 | html.Img(
32 | src = lightbulb_img_url,
33 | className='icon',
34 | ),
35 | html.H1(
36 | [
37 | html.Span(
38 | 'EA Data',
39 | className = 'data',
40 | ),
41 | ],
42 | className='main-title short-title',
43 | ),
44 | html.H1(
45 | [
46 | html.Span(
47 | 'Effective ',
48 | className = 'effective',
49 | ),
50 | html.Span(
51 | 'Altruism ',
52 | className = 'altruism',
53 | ),
54 | html.Span(
55 | 'Data',
56 | className = 'data',
57 | ),
58 | ],
59 | className = 'main-title long-title',
60 | ),
61 | html.Div(
62 | [
63 | html.Div(
64 | dash_dangerously_set_inner_html.DangerouslySetInnerHTML('''
65 |
72 | '''),
73 | className='icon',
74 | ),
75 | visdcc.Run_js(id='javascript-header'),
76 | html.Div(
77 | dash_dangerously_set_inner_html.DangerouslySetInnerHTML('''
78 |
84 | '''),
85 | className='icon',
86 | ),
87 | ],
88 | className = 'right-icons',
89 | )
90 |
91 | ],
92 | className='header center',
93 | id="header-sidebar-visdcc"
94 | )
95 |
--------------------------------------------------------------------------------
/components/sections/gwwc_donation_growth.py:
--------------------------------------------------------------------------------
1 | import pandas as pd
2 | from dash import html
3 | from utils.get_data.query_gwwc import get_donations_by_year
4 | from utils.subtitle import get_data_source
5 | from utils.subtitle import get_instructions
6 | from utils.plots.line import Line
7 | from datetime import datetime
8 |
9 |
10 | def get_num_donors_hover(row):
11 |
12 | year = row['date'].strftime('%Y')
13 |
14 | result = ''
15 | result += f"{year}"
16 | result += f"
${row.amount_normalized:,.2f} donations"
17 | result += f"
${row.amount_normalized_total:,.2f} total donations"
18 | result += f"
{row.num_donors:,} donors"
19 |
20 | return result
21 |
22 |
23 | def get_gwwc_donation_growth_section():
24 |
25 | donations_by_year = pd.read_json('./assets/data/gwwc/donations_by_year.json')
26 | #donations_by_year = get_donations_by_year()
27 |
28 | donations_by_year['date'] = pd.to_datetime(donations_by_year['year'], format='%Y')
29 | donations_by_year = donations_by_year.sort_values(by='date')
30 |
31 | # Filter out future donations
32 | donations_by_year = donations_by_year.loc[ donations_by_year['date'] < datetime.now() ]
33 |
34 | donations_by_year['amount_normalized_total'] = donations_by_year['amount_normalized'].cumsum()
35 |
36 | donations_by_year['hover'] = donations_by_year.apply(get_num_donors_hover, axis=1)
37 |
38 | donations_by_year['label'] = 'Donations'
39 |
40 | label = donations_by_year['amount_normalized'].tolist()[-1]
41 | last_year = int(donations_by_year['year'].tolist()[-1])
42 | label = f'${label/1e6:,.1f} Million
{last_year} Donations'
43 | donations_by_year['label'] = label
44 |
45 | annual_donations_graph = Line(
46 | donations_by_year,
47 | x='date',
48 | y='amount_normalized',
49 | title='Annual Donation Amounts',
50 | x_title='',
51 | y_title='',
52 | hover='hover',
53 | dollars=True,
54 | )
55 |
56 | label = donations_by_year['amount_normalized_total'].tolist()[-1]
57 | label = f'${label/1e6:,.1f} Million
Total Donated'
58 | donations_by_year['label'] = label
59 |
60 | total_donations_graph = Line(
61 | donations_by_year,
62 | x='date',
63 | y='amount_normalized_total',
64 | title='Total Donated',
65 | x_title='',
66 | y_title='',
67 | hover='hover',
68 | dollars=True,
69 | )
70 |
71 | label = donations_by_year['num_donors'].tolist()[-1]
72 | label = f'{label:,} Donors
in {last_year}'
73 | donations_by_year['label'] = label
74 |
75 | num_donors_graph = Line(
76 | donations_by_year,
77 | x='date',
78 | y='num_donors',
79 | title='Annual Number of Donors',
80 | x_title='',
81 | y_title='',
82 | hover='hover',
83 | )
84 |
85 | return html.Div(
86 | [
87 | html.Div(
88 | html.H2('Giving What We Can Donations'),
89 | className='section-heading',
90 | ),
91 | get_instructions(hover='points', zoom=True),
92 | html.Div(
93 | [
94 | annual_donations_graph,
95 | num_donors_graph,
96 | total_donations_graph,
97 | ],
98 | className='grid tab-cols-3 desk-cols-3 section-body'
99 | ),
100 | get_data_source('gwwc_pledges'),
101 | ],
102 | className = 'section',
103 | id='gwwc-donations-section',
104 | )
105 |
--------------------------------------------------------------------------------
/utils/subtitle.py:
--------------------------------------------------------------------------------
1 | from dash import html
2 | from dash import dcc
3 |
4 | data_source_details = {
5 |
6 | 'rethink19': dict(
7 | name='EA Survey 2019',
8 | url='https://www.rethinkpriorities.org/blog/2019/12/5/ea-survey-2019-series-community-demographics-amp-characteristics'
9 | ),
10 |
11 | 'rethink19-geo': dict(
12 | name='EA Survey 2019',
13 | url='https://rethinkpriorities.org/publications/eas2019-geographic-distribution-of-eas',
14 | download_url='/assets/data/rp_survey_data_2019/country2.csv'
15 | ),
16 |
17 | 'ea_forum': dict(
18 | name='forum.effectivealtruism.org',
19 | url='https://forum.effectivealtruism.org/graphiql',
20 | ),
21 |
22 | 'open_phil': dict(
23 | name='openphilanthropy.org',
24 | url='https://www.openphilanthropy.org/giving/grants',
25 | download_url='https://www.openphilanthropy.org/giving/grants/spreadsheet',
26 | ),
27 |
28 | 'funds_payout': dict(
29 | name='funds.effectivealtruism.org',
30 | url='https://funds.effectivealtruism.org/'
31 | ),
32 |
33 | 'founders_pledge': dict(
34 | name='founderspledge.com',
35 | url='https://founderspledge.com/'
36 | ),
37 |
38 | 'gwwc': dict(
39 | name='givingwhatwecan.org',
40 | url='https://www.givingwhatwecan.org/'
41 | ),
42 |
43 | 'growth': dict(
44 | name='EA Growth Metrics for 2018',
45 | url='https://forum.effectivealtruism.org/posts/MBJvDDw2sFGkFCA29/is-ea-growing-ea-growth-metrics-for-2018',
46 | ),
47 |
48 | 'gwwc_pledges': dict(
49 | name='dashboard.effectivealtruism.org',
50 | url='http://dashboard.effectivealtruism.org/public/question/a8499095-be16-46fe-af1f-e3e56ee04e88',
51 | ),
52 |
53 | 'gwwc_donations': dict(
54 | name='dashboard.effectivealtruism.org',
55 | url='http://dashboard.effectivealtruism.org/public/question/9906735e-1350-4353-9828-bb3ec16137e3',
56 | ),
57 |
58 | 'gwwc_orgs': dict(
59 | name='dashboard.effectivealtruism.org',
60 | url='http://dashboard.effectivealtruism.org/public/question/b3887098-686a-491c-9f9c-9a5b0e2b7fd8',
61 | ),
62 |
63 | }
64 |
65 | def get_data_source(data_sources):
66 |
67 | if len(data_sources) == 0:
68 | return html.Div()
69 |
70 | if type(data_sources)==str:
71 | data_sources = [ data_sources ]
72 |
73 |
74 | content = [ 'Data source: ' ]
75 |
76 | list_of_source_links = []
77 | for data_source in data_sources:
78 |
79 | details = data_source_details[data_source]
80 |
81 | content.append(
82 | html.A(
83 | details['name'],
84 | href = details['url']
85 | )
86 | )
87 |
88 | # download link
89 | if 'download_url' in details:
90 | content.append(' (')
91 | content.append(
92 | html.A(
93 | 'download',
94 | href = details['download_url'],
95 | )
96 | )
97 | content.append(')')
98 |
99 | content.append(', ')
100 |
101 | # Change the last comma into a period.
102 | content[-1] = '.'
103 |
104 | return html.P(content)
105 |
106 | def get_instructions(zoom=False, hover='bars', extra_text=[]):
107 |
108 | content = []
109 |
110 | if hover:
111 | content.append( f'Hover for more details.' )
112 |
113 | if zoom:
114 | content.append( 'Click and drag to zoom. Double click to unzoom.' )
115 |
116 | if type(extra_text)==str:
117 | content.append(extra_text)
118 | elif type(extra_text)==list:
119 | content.extend(extra_text)
120 |
121 | return html.P(' '.join(content))
122 |
123 |
124 |
--------------------------------------------------------------------------------
/assets/data/gwwc/new_pledges.json:
--------------------------------------------------------------------------------
1 | {"pledge_month":{"0":"2009-11","1":"2009-12","2":"2010-01","3":"2010-02","4":"2010-03","5":"2010-05","6":"2010-06","7":"2010-07","8":"2010-08","9":"2010-09","10":"2010-10","11":"2010-11","12":"2010-12","13":"2011-01","14":"2011-02","15":"2011-03","16":"2011-04","17":"2011-05","18":"2011-06","19":"2011-07","20":"2011-08","21":"2011-09","22":"2011-10","23":"2011-11","24":"2011-12","25":"2012-01","26":"2012-02","27":"2012-03","28":"2012-04","29":"2012-05","30":"2012-06","31":"2012-07","32":"2012-08","33":"2012-09","34":"2012-10","35":"2012-11","36":"2012-12","37":"2013-01","38":"2013-02","39":"2013-03","40":"2013-04","41":"2013-05","42":"2013-06","43":"2013-07","44":"2013-08","45":"2013-09","46":"2013-10","47":"2013-11","48":"2013-12","49":"2014-01","50":"2014-02","51":"2014-03","52":"2014-04","53":"2014-05","54":"2014-06","55":"2014-07","56":"2014-08","57":"2014-09","58":"2014-10","59":"2014-11","60":"2014-12","61":"2015-01","62":"2015-02","63":"2015-03","64":"2015-04","65":"2015-05","66":"2015-06","67":"2015-07","68":"2015-08","69":"2015-09","70":"2015-10","71":"2015-11","72":"2015-12","73":"2016-01","74":"2016-02","75":"2016-03","76":"2016-04","77":"2016-05","78":"2016-06","79":"2016-07","80":"2016-08","81":"2016-09","82":"2016-10","83":"2016-11","84":"2016-12","85":"2017-01","86":"2017-02","87":"2017-03","88":"2017-04","89":"2017-05","90":"2017-06","91":"2017-07","92":"2017-08","93":"2017-09","94":"2017-10","95":"2017-11","96":"2017-12","97":"2018-01","98":"2018-02","99":"2018-03","100":"2018-04","101":"2018-05","102":"2018-06","103":"2018-07","104":"2018-08","105":"2018-09","106":"2018-10","107":"2018-11","108":"2018-12","109":"2019-01","110":"2019-02","111":"2019-03","112":"2019-04","113":"2019-05","114":"2019-06","115":"2019-07","116":"2019-08","117":"2019-09","118":"2019-10","119":"2019-11","120":"2019-12","121":"2020-01","122":"2020-02","123":"2020-03","124":"2020-04","125":"2020-05","126":"2020-06","127":"2020-07","128":"2020-08","129":"2020-09","130":"2020-10","131":"2020-11","132":"2020-12","133":"2021-01","134":"2021-02","135":"2021-03","136":"2021-04","137":"2021-05","138":"2021-06","139":"2021-07","140":"2021-08","141":"2021-09","142":"2021-10"},"the_pledge":{"0":25,"1":6,"2":1,"3":2,"4":3,"5":4,"6":1,"7":1,"8":3,"9":3,"10":5,"11":4,"12":8,"13":19,"14":17,"15":12,"16":9,"17":7,"18":5,"19":2,"20":5,"21":2,"22":10,"23":4,"24":7,"25":15,"26":8,"27":4,"28":5,"29":8,"30":4,"31":6,"32":11,"33":12,"34":10,"35":9,"36":8,"37":11,"38":4,"39":12,"40":2,"41":5,"42":8,"43":3,"44":5,"45":14,"46":16,"47":16,"48":20,"49":19,"50":21,"51":25,"52":38,"53":13,"54":24,"55":21,"56":32,"57":24,"58":30,"59":27,"60":122,"61":100,"62":40,"63":29,"64":43,"65":60,"66":48,"67":54,"68":38,"69":51,"70":52,"71":54,"72":109,"73":117,"74":57,"75":45,"76":59,"77":49,"78":59,"79":38,"80":76,"81":108,"82":104,"83":89,"84":167,"85":201,"86":62,"87":61,"88":61,"89":58,"90":85,"91":73,"92":70,"93":21,"94":79,"95":60,"96":78,"97":84,"98":40,"99":52,"100":42,"101":45,"102":42,"103":52,"104":33,"105":50,"106":56,"107":49,"108":60,"109":47,"110":35,"111":38,"112":49,"113":39,"114":27,"115":36,"116":43,"117":23,"118":46,"119":52,"120":86,"121":74,"122":35,"123":50,"124":38,"125":61,"126":103,"127":70,"128":77,"129":86,"130":81,"131":74,"132":260,"133":253,"134":112,"135":95,"136":77,"137":89,"138":56,"139":51,"140":72,"141":72,"142":35},"try_giving":{"0":0,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":1,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":1,"24":0,"25":5,"26":2,"27":1,"28":0,"29":2,"30":0,"31":0,"32":1,"33":3,"34":1,"35":1,"36":3,"37":3,"38":1,"39":1,"40":0,"41":1,"42":4,"43":1,"44":2,"45":1,"46":3,"47":1,"48":1,"49":11,"50":4,"51":5,"52":5,"53":8,"54":9,"55":4,"56":18,"57":9,"58":15,"59":12,"60":25,"61":46,"62":11,"63":13,"64":22,"65":21,"66":18,"67":25,"68":30,"69":26,"70":24,"71":23,"72":34,"73":90,"74":26,"75":22,"76":26,"77":21,"78":40,"79":36,"80":46,"81":48,"82":39,"83":55,"84":57,"85":97,"86":36,"87":41,"88":32,"89":28,"90":20,"91":23,"92":13,"93":8,"94":28,"95":15,"96":40,"97":50,"98":24,"99":40,"100":29,"101":21,"102":18,"103":35,"104":31,"105":37,"106":28,"107":34,"108":34,"109":54,"110":24,"111":29,"112":25,"113":15,"114":24,"115":20,"116":18,"117":24,"118":25,"119":28,"120":49,"121":44,"122":16,"123":16,"124":32,"125":35,"126":91,"127":70,"128":60,"129":63,"130":72,"131":73,"132":208,"133":273,"134":89,"135":70,"136":66,"137":54,"138":57,"139":55,"140":59,"141":53,"142":33}}
--------------------------------------------------------------------------------
/components/sidebar.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import dash
4 | from dash import dcc
5 | from dash import html
6 | import plotly.graph_objects as go
7 | from plotly.subplots import make_subplots
8 | import plotly.express as px
9 |
10 | def intro_contents():
11 | return [
12 | html.P(
13 | 'Overview',
14 | ),
15 | html.Ul(
16 | [
17 | html.Li(
18 | html.A(
19 | "All Donations",
20 | href="#donations-sankey"
21 | ),
22 | ),
23 | ]
24 | )
25 | ]
26 |
27 | def open_phil_contents():
28 | return [
29 | html.P(
30 | 'Open Philanthropy Grants',
31 | ),
32 | html.Ul(
33 | [
34 | html.Li(
35 | html.A(
36 | "Individual Grants Plot",
37 | href="#op-grants-scatter-section",
38 | ),
39 | ),
40 | html.Li(
41 | html.A(
42 | "Focus Area and Donee Organization",
43 | href="#op-grants-categories",
44 | ),
45 | ),
46 | html.Li(
47 | html.A(
48 | "Changes over Time",
49 | href="#op-grants-growth",
50 | ),
51 | ),
52 | ]
53 | )
54 | ]
55 |
56 | def survey_contents():
57 | return [
58 | html.P(
59 | 'EA Survey Results',
60 | ),
61 | html.Ul(
62 | [
63 | html.Li(
64 | html.A(
65 | "Countries (total)",
66 | href="#countries"
67 | ),
68 | ),
69 | html.Li(
70 | html.A(
71 | "Countries (per Capita)",
72 | href="#countries-per-capita"
73 | ),
74 | ),
75 | html.Li(
76 | html.A(
77 | "Demographics",
78 | href="#demographics"
79 | ),
80 | ),
81 | html.Li(
82 | html.A(
83 | "Beliefs and Lifestyle",
84 | href="#beliefs-lifestyle"
85 | ),
86 | ),
87 | html.Li(
88 | html.A(
89 | "Education",
90 | href="#education"
91 | ),
92 | ),
93 | html.Li(
94 | html.A(
95 | "Careers",
96 | href="#careers"
97 | ),
98 | ),
99 | ],
100 | ),
101 | ]
102 |
103 | def forum_contents():
104 | return [
105 | html.P(
106 | 'EA Forum',
107 | ),
108 | html.Ul(
109 | [
110 | html.Li(
111 | html.A(
112 | "Posted Date vs Karma",
113 | href="#forum-scatter-section"
114 | ),
115 | ),
116 | html.Li(
117 | html.A(
118 | "Forum Growth",
119 | href="#forum-growth-section"
120 | ),
121 | ),
122 | html.Li(
123 | html.A(
124 | "Post Distributions",
125 | href="#post-wilkinson-section"
126 | ),
127 | ),
128 | html.Li(
129 | html.A(
130 | "Author Distributions",
131 | href="#author-wilkinson-section"
132 | ),
133 | ),
134 | ],
135 | ),
136 | ]
137 |
138 | def gwwc_contents():
139 | return [
140 | html.P(
141 | 'Giving What We Can',
142 | ),
143 | html.Ul(
144 | [
145 | html.Li(
146 | html.A(
147 | "Pledges",
148 | href="#gwwc-pledge-section",
149 | ),
150 | ),
151 | html.Li(
152 | html.A(
153 | "Donations",
154 | href="#gwwc-donations-section",
155 | ),
156 | ),
157 | html.Li(
158 | html.A(
159 | "Donation Organizations",
160 | href="#gwwc-orgs-section",
161 | ),
162 | ),
163 | ],
164 | ),
165 | ]
166 |
167 | def contents():
168 | return html.Div(
169 | [
170 | html.H2('Contents'),
171 | *intro_contents(),
172 | *open_phil_contents(),
173 | *gwwc_contents(),
174 | *survey_contents(),
175 | *forum_contents(),
176 | ],
177 | className = 'section_list',
178 | )
179 |
180 | def sidebar():
181 | return html.Div(
182 | [
183 | html.Div(
184 | contents(),
185 | id='sidebar',
186 | ),
187 | html.Div(
188 | id='sidebar-buttress',
189 | ),
190 | ]
191 | )
192 |
--------------------------------------------------------------------------------
/components/sections/gwwc_pledges.py:
--------------------------------------------------------------------------------
1 | from dash import html
2 | import pandas as pd
3 | from utils.subtitle import get_data_source
4 | from utils.subtitle import get_instructions
5 | from utils.plots.line import Line
6 | from utils.get_data.query_gwwc import get_new_pledges
7 |
8 |
9 | def get_the_pledge_hover(row):
10 |
11 | date = row['date'].strftime('%B %Y')
12 | new_pledges = row['the_pledge']
13 | total_pledges = row['the_pledge_total']
14 |
15 | result = ''
16 | result += f"GWWC Pledges"
17 | result += f"
{date}"
18 | result += f"
{new_pledges:,} new pledges"
19 | result += f"
{total_pledges:,} total pledges"
20 |
21 | return result
22 |
23 |
24 | def get_try_giving_hover(row):
25 |
26 | date = row['date'].strftime('%B %Y')
27 | new_pledges = row['try_giving']
28 | total_pledges = row['try_giving_total']
29 |
30 | result = ''
31 | result += f"Trial Pledges"
32 | result += f"
{date}"
33 | result += f"
{new_pledges:,} new pledges"
34 | result += f"
{total_pledges:,} total pledges"
35 |
36 | return result
37 |
38 |
39 | def get_new_pledges_long(new_pledges):
40 |
41 | new_pledges_long = new_pledges.loc[:, ['date']]
42 | new_pledges_long['value'] = new_pledges['the_pledge']
43 | new_pledges_long['hover'] = new_pledges['the_pledge_hover']
44 |
45 | label = new_pledges_long['value'].tolist()[-1]
46 | last_date = new_pledges_long['date'].tolist()[-1]
47 | last_year = last_date.strftime('%Y')
48 | last_month = last_date.strftime('%B')
49 | new_pledges_long['label'] = f'{label:,} New
{last_month}
{last_year}'
50 |
51 | return new_pledges_long
52 |
53 | def get_new_trial_pledges_long(new_pledges):
54 |
55 | new_try_giving_long = new_pledges.loc[:, ['date']]
56 | new_try_giving_long['value'] = new_pledges['try_giving']
57 | new_try_giving_long['hover'] = new_pledges['try_giving_hover']
58 |
59 | label = new_try_giving_long['value'].tolist()[-1]
60 | last_date = new_try_giving_long['date'].tolist()[-1]
61 | last_year = last_date.strftime('%Y')
62 | last_month = last_date.strftime('%B')
63 | new_try_giving_long['label'] = f'{label:,} New
{last_month}
{last_year}'
64 |
65 | return new_try_giving_long
66 |
67 |
68 |
69 | def get_total_pledges_long(new_pledges):
70 |
71 | total_pledges_long = new_pledges.loc[:, ['date']]
72 | total_pledges_long['value'] = new_pledges['the_pledge_total']
73 | total_pledges_long['hover'] = new_pledges['the_pledge_hover']
74 |
75 | label = total_pledges_long['value'].tolist()[-1]
76 | #last_date = int(total_pledges_long['date'].tolist()[-1])
77 | total_pledges_long['label'] = f'{label:,}
Giving Pledges'
78 |
79 | total_try_giving_long = new_pledges.loc[:, ['date']]
80 | total_try_giving_long['value'] = new_pledges['try_giving_total']
81 | total_try_giving_long['hover'] = new_pledges['try_giving_hover']
82 |
83 | label = total_try_giving_long['value'].tolist()[-1]
84 | #last_date = int(total_try_giving_long['date'].tolist()[-1])
85 | total_try_giving_long['label'] = f'{label:,}
Trial Pledges'
86 |
87 | return pd.concat([total_pledges_long, total_try_giving_long], ignore_index=True)
88 |
89 |
90 | def get_gwwc_pledges_section():
91 |
92 | new_pledges = pd.read_json('./assets/data/gwwc/new_pledges.json')
93 | #new_pledges = get_new_pledges()
94 |
95 | new_pledges['date'] = pd.to_datetime(new_pledges['pledge_month'])
96 |
97 | new_pledges['the_pledge_total'] = new_pledges['the_pledge'].cumsum()
98 | new_pledges['try_giving_total'] = new_pledges['try_giving'].cumsum()
99 |
100 | new_pledges['the_pledge_hover'] = new_pledges.apply(get_the_pledge_hover, axis=1)
101 | new_pledges['try_giving_hover'] = new_pledges.apply(get_try_giving_hover, axis=1)
102 |
103 | new_pledges_long = get_new_pledges_long(new_pledges)
104 | new_trial_pledges_long = get_new_trial_pledges_long(new_pledges)
105 | total_pledges_long = get_total_pledges_long(new_pledges)
106 |
107 | new_pledges_graph = Line(
108 | new_pledges_long,
109 | x='date',
110 | y='value',
111 | title='New Giving Pledges by Month',
112 | x_title='',
113 | y_title='',
114 | xanchor='left',
115 | yanchor='middle',
116 | )
117 |
118 | new_trial_pledges_graph = Line(
119 | new_trial_pledges_long,
120 | x='date',
121 | y='value',
122 | title='New Trial Pledges by Month',
123 | x_title='',
124 | y_title='',
125 | xanchor='left',
126 | yanchor='middle',
127 | )
128 |
129 | total_pledges_graph = Line(
130 | total_pledges_long,
131 | x='date',
132 | y='value',
133 | title='Total Pledges',
134 | x_title='',
135 | y_title='',
136 | xanchor='center',
137 | )
138 |
139 | return html.Div(
140 | [
141 | html.Div(
142 | html.H2('Giving What We Can Pledges'),
143 | className='section-heading',
144 | ),
145 | get_instructions(hover='points', zoom=True),
146 | html.Div(
147 | [
148 | new_pledges_graph,
149 | new_trial_pledges_graph,
150 | total_pledges_graph
151 | ],
152 | className='grid desk-cols-3 section-body'
153 | ),
154 | get_data_source('gwwc_pledges'),
155 | ],
156 | className = 'section',
157 | id='gwwc-pledge-section',
158 | )
159 |
--------------------------------------------------------------------------------
/utils/get_data/data_scraping.py:
--------------------------------------------------------------------------------
1 | from bs4 import BeautifulSoup
2 | import re
3 | import requests
4 | import pandas as pd
5 | from datetime import datetime
6 | import json
7 |
8 | def url_to_soup(url):
9 | page = requests.get(url, headers={'User-Agent': ''})
10 | return BeautifulSoup(page.content, features="html.parser")
11 |
12 |
13 | def download_ea_funds_grants():
14 | # The data can be seen at 'https://app.effectivealtruism.org/funds/{}/payouts'.
15 | # But the above page isn't static so can't be scraped.
16 |
17 | # Found this by poking around in developer tools for 20 minutes:
18 | data_url = 'https://cdn.contentful.com/spaces/afdyh2iav3iy/entries?access_token=630f127009ba9d044dd156ae8a6b9c5b26c66c054508f720e8b0dbbfa165d4e5&content_type=payoutReport&include=2&order=-fields.date&fields.fund.sys.contentType.sys.id=fund&fields.fund.fields.slug={}'
19 |
20 | fund_names = [
21 | 'global-development',
22 | 'animal-welfare',
23 | 'far-future',
24 | 'ea-community',
25 | ]
26 |
27 | # Store all grants in a dataframe
28 | grants = pd.DataFrame(columns=[
29 | 'fund',
30 | 'amount',
31 | 'date',
32 | 'title',
33 | ])
34 |
35 | for fund_name in fund_names:
36 |
37 | # Retrieve json data
38 | fund_url = data_url.format(fund_name)
39 | fund_response = requests.get(fund_url)
40 | fund_data = json.loads(fund_response.content)
41 |
42 | # Parse each grant
43 | for grant in fund_data['items']:
44 |
45 | fields = grant['fields']
46 | title = fields['title']
47 | amount = fields['amount']
48 |
49 | # date format is 2020-03-27
50 | date = datetime.strptime(fields['date'], '%Y-%m-%d')
51 |
52 | # Add to dataframe
53 | grants.loc[len(grants), :] = [
54 | fund_name,
55 | amount,
56 | date,
57 | title,
58 | ]
59 |
60 | # # There's also recipients data which I can't parse
61 | # recipients = fields['recipients']
62 | # for recipient in recipients:
63 | # recipient_id = recipient['sys']['id'] # I don't know what to do with this
64 |
65 | return grants
66 |
67 | def download_ea_funds_balances():
68 |
69 | fund_names = [
70 | 'global-development',
71 | 'animal-welfare',
72 | 'far-future',
73 | 'ea-community',
74 | ]
75 |
76 | body_left = "{\"operationName\":\"getXeroBalanceSheetByOrganization\",\"variables\":{\"reference\":\""
77 | body_right = "\",\"nearestReportDate\":\"2020-07-28T05:59:22.337Z\"},\"query\":\"query getXeroBalanceSheetByOrganization($reference: String!, $nearestReportDate: Date) {\\n XeroBalanceSheet: getXeroBalanceSheetMonthlyTotalByReference(reference: $reference, nearestReportDate: $nearestReportDate) {\\n edges {\\n node {\\n reportDate\\n reference\\n amount\\n __typename\\n }\\n __typename\\n }\\n __typename\\n }\\n}\\n\"}"
78 |
79 | balances = pd.DataFrame(columns=[
80 | 'fund',
81 | 'amount',
82 | 'as of',
83 | ])
84 |
85 | for fund_name in fund_names:
86 |
87 | # send HTTP request
88 | body = body_left + fund_name + body_right
89 | response = requests.post(
90 | "https://parfit.effectivealtruism.org/graphql",
91 | headers = {
92 | "accept": "*/*",
93 | "accept-language": "en-GB,en;q=0.9,de;q=0.8,fr;q=0.7,ru;q=0.6",
94 | "content-type": "application/json",
95 | "sec-fetch-dest": "empty",
96 | "sec-fetch-mode": "cors",
97 | "sec-fetch-site": "same-site"
98 | },
99 | data = body
100 | )
101 |
102 | # parse request
103 | content = json.loads(response.content)
104 | node = content['data']['XeroBalanceSheet']['edges'][0]['node']
105 | balance = node['amount']
106 | as_of = node['reportDate']
107 |
108 | # add to balances dataframe
109 | balances.loc[len(balances), :] = [
110 | fund_name,
111 | balance,
112 | as_of,
113 | ]
114 |
115 | return balances
116 |
117 | def scrape_founders_pledge():
118 | fp_url = 'https://founderspledge.com/'
119 | soup = url_to_soup(fp_url)
120 |
121 | # Scrape total pledged
122 | with open('text', 'w') as f:
123 | f.write(str(soup))
124 | pledge_str = soup.select('div.resource--stat--total-value-pledged')[0].get_text()
125 | pledge_pattern = r'\$(\d.\d\d) billion'
126 | pledge_match = re.findall(pledge_pattern, pledge_str)[0]
127 | total_pledged = round( float(pledge_match) * 10**9 )
128 |
129 | # Scrape total committed
130 | committed_str = soup.select('div.resource--stat--fulfilled-commitments')[0].get_text()
131 | committed_pattern = r'\$(\d+) million'
132 | committed_match = re.findall(committed_pattern, committed_str)[0]
133 | total_committed = round( float(pledge_match) * 10**6 )
134 |
135 | # Scrape number members
136 | members = soup.select('div.resource--stat--in-30-countries')[0].get_text()
137 | members_pattern = r'(\d+) members'
138 | countries_pattern = 'In (\d+) Countries'
139 | members_match = re.findall(members_pattern, members)[0]
140 | countries_match = re.findall(countries_pattern, members)[0]
141 | n_members, n_countries = int(members_match), int(countries_match)
142 |
143 | return {
144 | 'pleged': total_pledged,
145 | 'committed': total_committed,
146 | 'members': n_members,
147 | 'countries': n_countries
148 | }
149 |
150 |
--------------------------------------------------------------------------------
/components/sections/growth.py:
--------------------------------------------------------------------------------
1 | import plotly.express as px
2 | import plotly.graph_objects as go
3 | import pandas as pd
4 | import numpy as np
5 | import string
6 | from dash import dcc
7 | from dash import html
8 | from utils.subtitle import get_subtitle
9 | from utils.plots.line import Line
10 |
11 | commiting = pd.read_csv('assets/data/is_ea_growing/is_ea_growing_commiting.csv')
12 | doing = pd.read_csv('assets/data/is_ea_growing/is_ea_growing_doing.csv')
13 | joining = pd.read_csv('assets/data/is_ea_growing/is_ea_growing_joining.csv')
14 | reading = pd.read_csv('assets/data/is_ea_growing/is_ea_growing_reading.csv')
15 |
16 |
17 | # "Founder's Pledge pledges" makes more sense in "doing" than in "commiting"
18 | doing = doing.append( commiting.loc[ commiting['Type of data']=='Founder’s Pledge pledges' ], ignore_index=True )
19 | commiting = commiting.loc[ ~(commiting['Type of data']=='Founder’s Pledge pledges') ]
20 |
21 |
22 |
23 | # Clean tables
24 | growing_dfs = [commiting, doing, joining, reading]
25 | for df in growing_dfs:
26 |
27 | # Convert column names from 'Jan-Dec 2014' to '2014'
28 | df.columns = [
29 | col.replace('Jan-Dec ', '') for col in df.columns
30 | ]
31 |
32 | # Replace 'Didn’t exist', 'No data', 'No data yet',
33 | df.replace('No data', np.nan, inplace=True)
34 | df.replace('No data yet', np.nan, inplace=True)
35 | df.replace('No survey', np.nan, inplace=True)
36 | df.replace('Didn’t exist', np.nan, inplace=True)
37 |
38 | # Get rid junk in strings
39 | def field_to_numeric(field):
40 | if type(field)!=str:
41 | return field
42 | field = field.replace('K', '*10**3')
43 | field = field.replace('M', '*10**6')
44 | valid_chars = '.*' + string.digits
45 | field = ''.join([
46 | char for char in field if char in valid_chars
47 | ])
48 | return eval(field)
49 | return field
50 | for col in df.columns:
51 | if col == 'Type of data':
52 | continue
53 | df[col] = df[col].apply(field_to_numeric)
54 |
55 |
56 |
57 |
58 | long_dfs = []
59 | for df in [commiting, doing, joining, reading]:
60 | years = df.columns[1:]
61 | row_dfs = []
62 | for row in range(len(df)):
63 | label = df.loc[row, 'Type of data']
64 | values = df.loc[row, years]
65 | if df is reading:
66 | values = values
67 | else:
68 | values = np.nancumsum(values)
69 | row_df = pd.DataFrame({
70 | 'year': years,
71 | 'value': values,
72 | })
73 | row_df['label'] = label#[:30]
74 | row_dfs.append(row_df)
75 | long_df = pd.concat(row_dfs, ignore_index=True)
76 | long_df['year'] = pd.to_datetime(long_df['year'], format='%Y')
77 |
78 | long_dfs.append( long_df )
79 |
80 | commiting, doing, joining, reading = long_dfs
81 |
82 | growing_figs = []
83 | for table, table_name in zip(
84 | [
85 | reading,
86 | joining,
87 | commiting,
88 | doing,
89 | ],
90 | [
91 | '','','',''
92 | #'low engaged',
93 | #'medium engaged',
94 | #'highly engaged',
95 | #'money',
96 | ]
97 | ):
98 |
99 | def hover(row):
100 | label =row['label']
101 | value = row['value']
102 | year = row['year'].year
103 | return f'{label}
{value:,.0f}
{year}'
104 |
105 | table['hover'] = table.apply(hover, axis=1).tolist()
106 |
107 | ignored_labels = [
108 | 'EA FB “Active Users”',
109 | 'Vox Future Perfect Newsletter sign-ups',
110 |
111 | 'New EA Reddit subscribers',
112 | 'EA FB membership',
113 |
114 | 'Number of 80,000 Hours significant plan changes (not impact adjusted)',
115 | 'Number of 80,000 Hours significant plan changes (impact adjusted)',
116 | 'ACE money moved[x]',
117 | 'TLYCS money moved',
118 | 'Total OpenPhil non-GiveWell donations',
119 | 'Total non-OpenPhil donors to GiveWell',
120 | '# donors in EA Survey',
121 | #'OpenPhil GiveWell donations',
122 | #'Non-OpenPhil GiveWell donations',
123 | 'Total recorded money actually donated (not pledges) from Giving What We Can members',
124 | #'# donors in EA Survey',
125 | #'Founder’s Pledge pledges',
126 | 'EA Funds payouts[y]',
127 |
128 | 'Google interest in “effective altruism” (relative scoring)',
129 | ]
130 |
131 | table = table.loc[ ~table['label'].isin(ignored_labels) ]
132 |
133 | growing_figs.append(
134 | html.Div(
135 | Line(
136 | table,
137 | x='year',
138 | y='value',
139 | label='label',
140 | title='',
141 | x_title='',
142 | y_title='',
143 | size=None,
144 | color=None,
145 | hover='hover',
146 | log_y=False,
147 | )
148 | )
149 | )
150 |
151 | def growth1():
152 | return html.Div(
153 | [
154 | html.Div(
155 | html.H2('Growth in EA Reading'),
156 | className='section-heading',
157 | ),
158 | get_subtitle('growth', hover='points', zoom=True),
159 | html.Div(
160 | growing_figs[0],
161 | className = 'section-body',
162 | ),
163 | ],
164 | className = 'section',
165 | id='growth-reading',
166 | )
167 |
168 | def growth2():
169 | return html.Div(
170 | [
171 | html.Div(
172 | html.H2('Growth in EA Joining'),
173 | className='section-heading',
174 | ),
175 | get_subtitle('growth', hover='points', zoom=True),
176 | html.Div(
177 | growing_figs[1],
178 | className = 'section-body',
179 | ),
180 | ],
181 | className = 'section',
182 | id='growth-joining',
183 | )
184 |
185 | def growth3():
186 | return html.Div(
187 | [
188 | html.Div(
189 | html.H2('Growth in EA Committing'),
190 | className='section-heading',
191 | ),
192 | get_subtitle('growth', hover='points', zoom=True),
193 | html.Div(
194 | growing_figs[2],
195 | className = 'section-body',
196 | ),
197 | ],
198 | className = 'section',
199 | id='growth-committing',
200 | )
201 |
202 | def growth4():
203 | return html.Div(
204 | [
205 | html.Div(
206 | html.H2('Growth in EA Donating'),
207 | className='section-heading',
208 | ),
209 | get_subtitle('growth', hover='points', zoom=True),
210 | html.Div(
211 | growing_figs[3],
212 | className = 'section-body',
213 | ),
214 | ],
215 | className = 'section',
216 | id='growth-donating',
217 | )
218 |
219 |
--------------------------------------------------------------------------------
/components/sections/demographics.py:
--------------------------------------------------------------------------------
1 | import dash
2 | from dash import dcc
3 | from dash import html
4 | import plotly.graph_objects as go
5 | import plotly.express as px
6 | import pandas as pd
7 | import re
8 | from glob import glob
9 | from utils.plots.bar import Bar
10 | from utils.subtitle import get_data_source
11 | from utils.subtitle import get_instructions
12 |
13 | def get_demo_table(demo_name):
14 |
15 | path = f"./assets/data/rp_survey_data_2019/{demo_name}.csv"
16 | demo_table = pd.read_csv(path, sep='\t')
17 | title = demo_table.columns[0]
18 |
19 | # remove the 'Total' row
20 | demo_table = demo_table[ ~demo_table[title].isin(['Total', 'Total respondents']) ]
21 | # convert '5%' to 5
22 | demo_table['Percent'] = demo_table['Percent'].apply(lambda x: float(x[:-1]))
23 |
24 |
25 | # Substitute the long labels for something shorter
26 | subs = {
27 | 'Eat meat, but try to reduce the amount ': 'Reducetarian',
28 | 'Other (please specify)': 'Other',
29 |
30 | 'Native Hawaiian or Other Pacific Islander': 'Hawaiian or Pacific Islander',
31 | 'American Indian or Alaskan Native': 'Native American/Alaskan',
32 | 'Hispanic, Latino or Spanish Origin': 'Hispanic or Latino',
33 |
34 | 'Professional or vocational qualification': 'Professional or Vocational',
35 |
36 | 'Not employed, but looking for work': 'Not employed, looking for work',
37 | 'Not employed, but not looking for work': 'Not employed, not looking for work',
38 |
39 | 'Work at a non-profit (not an EA organization)': 'Non-profit (not EA org)',
40 | 'Work at a non-profit (EA organization)': 'Non-profit (EA org)',
41 |
42 |
43 | 'Consequentialism (utilitarian)': 'Utilitarianism',
44 | 'Consequentualism (other than utilitarian)': 'Other Consequentialism',
45 | }
46 | demo_table['label_original'] = demo_table[title]
47 | demo_table['label'] = demo_table[title].map(subs).fillna(demo_table[title])
48 |
49 | demo_table = demo_table.iloc[::-1]
50 | if title == 'Moral View':
51 | demo_table = demo_table.loc[[ 4, 2, 3, 1, 0, ], :]
52 | elif title == 'Race/Ethnicity':
53 | # Move "other" to the bottom
54 | inds = list(range(6, -1, -1))
55 | inds.insert(0, inds.pop(3))
56 | demo_table = demo_table.loc[inds, :]
57 | elif title == 'Education':
58 | # Move "other" to the bottom
59 | inds = list(range(4, -1, -1))
60 | inds.insert(0, inds.pop(4))
61 | demo_table = demo_table.loc[inds, :]
62 | elif title == 'Diet ':
63 | # Move "other" to the bottom
64 | inds = list(range(6))
65 | inds.insert(0, inds.pop(4))
66 | demo_table = demo_table.loc[inds, :]
67 |
68 | demo_table['x'] = demo_table['label']
69 | demo_table['y'] = demo_table['Percent']
70 | demo_table['text'] = demo_table['Percent'].apply(lambda x: f'{x:.1f}%')
71 |
72 | def hover(row):
73 | label = row['label_original']
74 | responses = row['Responses']
75 | percent = row['Percent']
76 | return f'{label}
{responses} responses ({percent}%)'
77 |
78 | demo_table['hover'] = demo_table.apply(hover, axis=1)
79 |
80 | return demo_table
81 |
82 | def get_bar_chart(demo_name):
83 | demo_table = get_demo_table(demo_name)
84 | title = demo_table.columns[0]
85 | return Bar(demo_table, title=title)
86 |
87 |
88 | def demographics_section():
89 | return html.Div(
90 | [
91 | html.Div(
92 | html.H2('EA Demographics'),
93 | className='section-title',
94 | ),
95 | get_instructions(),
96 | html.Div(
97 | [
98 | html.Div(
99 | get_bar_chart('gender'),
100 | className='plot-container'
101 | ),
102 | html.Div(
103 | get_bar_chart('age_group'),
104 | className='plot-container'
105 | ),
106 | html.Div(
107 | get_bar_chart('ethnicity'),
108 | className='plot-container tab-span-2-cols'
109 | ),
110 | ],
111 | className = 'grid tab-cols-2 desk-cols-3 section-body',
112 | ),
113 | get_data_source('rethink19'),
114 | ],
115 | className = 'section',
116 | id='demographics',
117 | )
118 |
119 |
120 | def beliefs_section():
121 | return html.Div(
122 | [
123 | html.Div(
124 | html.H2('EA Beliefs and Lifestyle'),
125 | className='section-title',
126 | ),
127 | get_instructions(),
128 | html.Div(
129 | [
130 | html.Div(
131 | get_bar_chart('political_belief'),
132 | className='plot-container'
133 | ),
134 | html.Div(
135 | get_bar_chart('diet'),
136 | className='plot-container'
137 | ),
138 | html.Div(
139 | get_bar_chart('moral_view'),
140 | className='plot-container tab-span-2-cols'
141 | ),
142 | ],
143 | className = 'grid tab-cols-2 desk-cols-3 section-body',
144 | ),
145 | get_data_source('rethink19'),
146 | ],
147 | className = 'section',
148 | id='beliefs-lifestyle',
149 | )
150 |
151 | def education_section():
152 | return html.Div(
153 | [
154 | html.Div(
155 | html.H2('EA Education'),
156 | className='section-title',
157 | ),
158 | get_instructions(),
159 | html.Div(
160 | [
161 | html.Div(
162 | get_bar_chart('education2'),
163 | className='plot-container'
164 | ),
165 | html.Div(
166 | get_bar_chart('subject'),
167 | className='plot-container'
168 | ),
169 | ],
170 | className = 'grid tab-cols-2 desk-cols-2 section-body',
171 | ),
172 | get_data_source('rethink19'),
173 | ],
174 | className = 'section',
175 | id='education',
176 | )
177 |
178 | def career_section():
179 | return html.Div(
180 | [
181 | html.Div(
182 | html.H2('EA Careers'),
183 | className='section-title',
184 | ),
185 | get_instructions(),
186 | html.Div(
187 | [
188 | html.Div(
189 | get_bar_chart('career_path'),
190 | className='plot-container'
191 | ),
192 | html.Div(
193 | get_bar_chart('employment'),
194 | className='plot-container'
195 | ),
196 | ],
197 | className = 'grid tab-cols-2 desk-cols-2 section-body',
198 | ),
199 | get_data_source('rethink19'),
200 | ],
201 | className = 'section',
202 | id='careers',
203 | )
204 |
--------------------------------------------------------------------------------
/components/sections/geography.py:
--------------------------------------------------------------------------------
1 | from dash import dcc
2 | from dash import html
3 | import plotly.graph_objects as go
4 | import plotly.express as px
5 | import pandas as pd
6 | from utils.plots.bar import Bar
7 | from countryinfo import CountryInfo
8 | from math import log
9 | from utils.subtitle import get_data_source
10 | from utils.subtitle import get_instructions
11 |
12 | ##################################
13 | ### WORLD MAP ###
14 | ##################################
15 |
16 | # source: https://plotly.com/python/bubble-maps/
17 |
18 | country = CountryInfo()
19 | country_list = country.all().keys()
20 |
21 | countries = pd.read_csv('./assets/data/rp_survey_data_2019/country2.csv')
22 |
23 | countries['Responses'] = countries['Responses'].astype('int')
24 |
25 | countries.loc[countries['Country']=='United States of America', 'Country'] = 'United States'
26 |
27 | MINIMUM_CIRCLE_SIZE = 0 # 20
28 | countries['circle size'] = countries['Responses'] + MINIMUM_CIRCLE_SIZE
29 |
30 | countries = countries.sort_values('Responses', ascending=True)
31 |
32 | def get_population(country):
33 | try:
34 | return CountryInfo(country).population()
35 | except:
36 | return 1e9
37 |
38 | countries['population'] = countries['Country'].apply(get_population)
39 | countries['Density (per million)'] = countries['Responses'] / countries['population'] * 1e6
40 | countries['Density (per million)'] = countries['Density (per million)'].apply(lambda x: round(x, 2))
41 | countries['log density'] = countries['Density (per million)'].apply(lambda x: 1 + log(x+1))
42 | MINIMUM_CIRCLE_SIZE = 15
43 | countries['circle size'] = countries['Responses'] + MINIMUM_CIRCLE_SIZE
44 |
45 | def hover(row):
46 | country = row['Country']
47 | responses = row['Responses']
48 | density = row['Density (per million)']
49 | return f'{country}
{responses:,.0f} survey responses
{density:.2f} per million people'
50 | countries['hover'] = countries.apply(hover, axis=1)
51 |
52 | countries_for_map = countries.copy()
53 | countries_for_map.loc[len(countries_for_map), ['Country', 'Responses', 'Density (per million)', 'log density']] = ('Antarctica', 0, 0, 0)
54 |
55 | countries_for_map['hover'] = countries_for_map.apply(hover, axis=1)
56 |
57 | # Population map
58 |
59 | pop_map = px.scatter_geo(
60 | countries,
61 | locations="Country",
62 | hover_name="Country",
63 | locationmode='country names',
64 | size="circle size",
65 | title="Number of EAs by Country",
66 | hover_data = {
67 | 'circle size': False,
68 | 'Responses': True,
69 | 'Country': False,
70 | 'log density': False,
71 | 'Density (per million)': True,
72 | },
73 | projection="equirectangular", # 'orthographic' is fun
74 | )
75 |
76 | pop_map.update_layout(
77 | margin=dict(l=0, r=0, t=80, b=0),
78 | title_x=0.5,
79 | )
80 |
81 | pop_map.update_traces(
82 | marker = dict(
83 | color ="#36859A",
84 | ),
85 | hovertext = countries['hover'],
86 | hovertemplate = '%{hovertext}',
87 | )
88 |
89 | pop_map.update_geos(
90 | showcoastlines=False,
91 | landcolor="#dfe3ee",
92 | )
93 |
94 | # Density map
95 |
96 | density_map = px.choropleth(
97 | countries_for_map,
98 | locations="Country",
99 | hover_name="Country",
100 | locationmode='country names',
101 | color='log density',
102 | title="EAs Per Capita (Darker/Greener is Higher)",
103 | color_continuous_scale=["#dfe3ee", "#007a8f"],
104 | hover_data = {
105 | 'circle size': False,
106 | 'Responses': True,
107 | 'Country': False,
108 | 'log density': False,
109 | 'Density (per million)': True,
110 | },
111 | projection="equirectangular", # 'orthographic' is fun. "natural earth" is quite nice
112 | )
113 |
114 | density_map.update_layout(
115 | margin=dict(l=0, r=0, t=80, b=0),
116 | coloraxis_showscale=False,
117 | title_x=0.5,
118 | )
119 |
120 | density_map.update_traces(
121 | hovertext = countries_for_map['hover'],
122 | hovertemplate = '%{hovertext}',
123 | marker_line_width=0,
124 | )
125 |
126 | density_map.update_geos(
127 | showcoastlines=False,
128 | landcolor="#dfe3ee",
129 | )
130 |
131 | countries['x'] = countries['Country']
132 | countries['text'] = countries['Responses'].apply(lambda x: f'{x:}')
133 | countries['y'] = countries['Responses']
134 | countries_truncated = countries.iloc[len(countries)*2//3:]
135 |
136 | countries_bar = Bar(
137 | countries_truncated,
138 | title = f'Countries with Most EAs',
139 | )
140 |
141 | countries_capita_sort = countries.sort_values(by='Density (per million)')
142 | countries_capita_sort['x'] = countries_capita_sort['Country']
143 | countries_capita_sort['y'] = countries_capita_sort['Density (per million)']
144 | countries_capita_sort['text'] = countries_capita_sort['Density (per million)'].apply(lambda x: f'{x:.1f}')
145 | countries_capita_sort_truncated = countries_capita_sort.iloc[len(countries)*2//3:]
146 |
147 | per_capita_bar = Bar(
148 | countries_capita_sort_truncated,
149 | title = f'Top EAs per Capita (×1M)',
150 | )
151 |
152 | def country_total_section():
153 | return html.Div(
154 | [
155 | html.Div(
156 | html.H2('EAs by Country'),
157 | className='section-heading',
158 | ),
159 | get_instructions(hover='countries or bars', extra_text='Scroll to zoom on map.'),
160 | html.Div(
161 | html.Div(
162 | [
163 | html.Div(
164 | dcc.Graph(
165 | id='pop_map',
166 | figure=pop_map,
167 | responsive=True,
168 | ),
169 | className='plot-container'
170 | ),
171 | html.Div(
172 | countries_bar,
173 | className='plot-container',
174 | ),
175 | ],
176 | className='grid desk-cols-2-1',
177 | ),
178 | className='section-body',
179 | ),
180 | get_data_source('rethink19-geo'),
181 | ],
182 | className = 'section',
183 | id='countries',
184 | )
185 |
186 | def country_per_capita_section():
187 | return html.Div(
188 | [
189 | html.Div(
190 | html.H2('EAs per Capita by Country'),
191 | className='section-heading',
192 | ),
193 | get_instructions(hover='countries or bars', extra_text='Scroll to zoom on map.'),
194 | html.Div(
195 | html.Div(
196 | [
197 | html.Div(
198 | dcc.Graph(
199 | id='density_map',
200 | figure=density_map,
201 | responsive=True,
202 | ),
203 | className='plot-container'
204 | ),
205 | html.Div(
206 | per_capita_bar,
207 | className='plot-container'
208 | ),
209 | ],
210 | className='grid desk-cols-2-1',
211 | ),
212 | className='section-body',
213 | ),
214 | get_data_source('rethink19-geo'),
215 | ],
216 | className = 'section',
217 | id='countries-per-capita',
218 | )
219 |
--------------------------------------------------------------------------------
/components/sections/donations_sankey.py:
--------------------------------------------------------------------------------
1 | import dash
2 | from dash import dcc
3 | from dash import html
4 | import plotly.graph_objects as go
5 | from plotly.subplots import make_subplots
6 | import plotly.express as px
7 | import pandas as pd
8 | import re
9 | from glob import glob
10 | import os
11 | from utils.subtitle import get_data_source
12 | from utils.subtitle import get_instructions
13 |
14 | def get_op_grants():
15 | op_grants = pd.read_csv('./assets/data/openphil_grants.csv')
16 | # op_grants = pd.read_csv('https://www.openphilanthropy.org/giving/grants/spreadsheet')
17 |
18 | # Standardize cause area names
19 | # standard names from https://80000hours.org/topic/causes/
20 | subs = {
21 | 'Potential Risks from Advanced Artificial Intelligence': 'AI',
22 | 'History of Philanthropy': 'Other cause area',
23 | 'Immigration Policy': 'Policy',
24 | 'Macroeconomic Stabilization Policy': 'Policy',
25 | 'Land Use Reform': 'Policy',
26 | 'Criminal Justice Reform': 'Policy',
27 | 'U.S. Policy': 'Policy',
28 | 'Other areas': 'Other cause area',
29 | 'Biosecurity and Pandemic Preparedness': 'Biosecurity',
30 | 'Farm Animal Welfare': 'Animal Welfare',
31 | 'Global Catastrophic Risks': 'Catastrophic Risks',
32 | 'Global Health & Development': 'Global Poverty',
33 | }
34 | op_grants['Cause Area'] = op_grants['Focus Area'].map(subs).fillna(op_grants['Focus Area'])
35 |
36 | subs = {
37 | # 'Johns Hopkins Center for Health Security': 'JHCHS',
38 | # 'Against Malaria Foundation': 'AMF',
39 | # 'Georgetown University': 'GU',
40 | }
41 | op_grants['Organization'] = op_grants['Organization Name'].map(subs).fillna(op_grants['Organization Name'])
42 |
43 | # Standardise Column Names
44 | op_grants = op_grants[['Organization', 'Cause Area', 'Amount']]
45 | op_grants['Source'] = 'Open Philanthropy'
46 |
47 | def parse_funding_amount(amount):
48 | if type(amount)==str:
49 | return int(amount[1:].replace(',', ''))
50 | else:
51 | return 0
52 | op_grants['Amount'] = op_grants['Amount'].apply(parse_funding_amount).astype('int')
53 |
54 | return op_grants
55 |
56 |
57 | def get_gwwc_and_founders_pledge():
58 | return pd.read_csv('assets/data/misc.csv')
59 |
60 |
61 | def get_ea_funds():
62 | ea_funds = pd.read_csv('./assets/data/ea_funds_grants.csv')
63 |
64 | subs = {
65 | 'global-development': 'Global Poverty',
66 | 'far-future': 'Far Future',
67 | 'ea-community': 'EA Community',
68 | 'animal-welfare': 'Animal Welfare'
69 | }
70 | ea_funds['fund'] = ea_funds['fund'].map(subs).fillna(ea_funds['fund'])
71 |
72 | ea_funds['Source'] = 'EA Funds'
73 | ea_funds['Cause Area'] = ea_funds['fund']
74 | ea_funds['Organization'] = 'Unknowns'
75 | ea_funds['Amount'] = ea_funds['amount']
76 | ea_funds = ea_funds[['Source', 'Cause Area', 'Organization', 'Amount']]
77 |
78 | return ea_funds
79 |
80 |
81 | def get_funding_long():
82 |
83 | funding = pd.concat(
84 | [
85 | get_op_grants(),
86 | get_gwwc_and_founders_pledge(),
87 | get_ea_funds(),
88 | ]
89 | )
90 |
91 | '''
92 | Transform table from
93 | 'OpenPhil', 'Global Poverty', 'AMF', 100
94 | 'OpenPhil', 'Global Poverty', 'SCI', 80
95 | to
96 | 'OpenPhil', 'Global Poverty', 180, 'OpenPhil'
97 | 'Global Poverty', 'AMF', 100, 'OpenPhil'
98 | 'Global Poverty', 'SCI', 80, 'OpenPhil'
99 | That is, sum the contributions of each entity to each other entity.
100 | Each row represents a connection between two entities.
101 | The last column will be used for coloring the connections.
102 | '''
103 |
104 | funding['Amount'] = funding['Amount'] / 1e6
105 |
106 | funding_long = pd.DataFrame(columns=['From', 'To', 'Amount', 'Source'])
107 |
108 | for source, cause in set(
109 | zip(
110 | funding['Source'],
111 | funding['Cause Area']
112 | )
113 | ):
114 |
115 | source_cause_df = funding[
116 | (funding['Source']==source) & (funding['Cause Area']==cause)
117 | ]
118 |
119 | total_funding = source_cause_df['Amount'].sum()
120 | funding_long.loc[len(funding_long)] = [
121 | source,
122 | cause,
123 | total_funding,
124 | source
125 | ]
126 |
127 | other_total = 0
128 | for org in source_cause_df['Organization'].unique():
129 | org_df = source_cause_df[source_cause_df['Organization']==org]
130 | total_funding = org_df['Amount'].sum()
131 |
132 | if total_funding < 2*10**1:
133 | # if total_funding < 2*10**7:
134 | other_total += total_funding
135 | continue
136 |
137 | funding_long.loc[len(funding_long)] = [
138 | cause,
139 | org,
140 | total_funding,
141 | source
142 | ]
143 |
144 | if other_total > 0:
145 | funding_long.loc[len(funding_long)] = [
146 | cause,
147 | 'Other orgs',
148 | other_total,
149 | source
150 | ]
151 |
152 | funding_long = funding_long[funding_long['To']!='Unknowns']
153 |
154 | return funding_long
155 |
156 | def funding_fig():
157 |
158 | funding_long = get_funding_long()
159 |
160 | # Get a list of all funding-related entities
161 | entities = set()
162 | for col in ['From', 'To']:
163 | entities.update(funding_long[col])
164 | entities = list(entities)
165 |
166 | # Convert financial inputs and outputs into indices
167 | entity2idx = {x: i for i,x in enumerate(entities)}
168 | froms = list(funding_long['From'].map(entity2idx))
169 | tos = list(funding_long['To'].map(entity2idx))
170 |
171 | entities += ["$100M (for scale)"]
172 | froms += [ len(entity2idx) ]
173 | tos += [ len(entity2idx) ]
174 |
175 | # values = funding_long['Amount'].to_list() + [1e8]
176 | values = funding_long['Amount'].to_list() + [1e2]
177 |
178 | # Create Sankey diagram
179 | fig = go.Figure(
180 | data=[go.Sankey(
181 | valueformat = ",.1f",
182 | valuesuffix = "M USD",
183 | node = dict(
184 | pad = 15,
185 | thickness = 20,
186 | line = dict(color = "#4196AA", width = 1),
187 | label = entities,
188 | color = "#4196AA"
189 | ),
190 | link = dict(
191 | source = froms,
192 | target = tos,
193 | color = "#C1E3EA",
194 | value = values
195 | )
196 | )],
197 | # config={
198 | # 'displayModeBar': False,
199 | # }
200 | )
201 | fig.update_layout(
202 | margin=dict(l=10, r=10, t=30, b=10),
203 | )
204 |
205 | return fig
206 |
207 | def donations_sankey_section():
208 |
209 | return html.Div(
210 | [
211 | html.Div(
212 | html.H2('Donations Overview'),
213 | className='section-title',
214 | ),
215 | get_instructions(
216 | hover='rectangles or lines',
217 | extra_text = 'Rectangles can be rearranged by dragging.',
218 | ),
219 | html.Div(
220 | html.Div(
221 | dcc.Graph(
222 | id='Donations',
223 | figure=funding_fig(),
224 | responsive=True,
225 | ),
226 | className = 'plot-container',
227 | ),
228 | className = 'section-body',
229 | ),
230 | get_data_source(
231 | [
232 | 'open_phil',
233 | 'funds_payout',
234 | 'founders_pledge',
235 | 'gwwc',
236 | ],
237 | ),
238 | ],
239 | className = 'section',
240 | id='donations-sankey',
241 | )
242 |
--------------------------------------------------------------------------------
/assets/style.css:
--------------------------------------------------------------------------------
1 | @import url("https://fonts.googleapis.com/css2?family=Roboto+Slab:wght@400;700;900&display=swap");
2 | @import url("https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;700;900&display=swap");
3 | @import url("https://fonts.googleapis.com/css2?family=Raleway:wght@400&display=swap");
4 |
5 | /*------------------
6 | GLOBAL
7 | ------------------*/
8 |
9 | :root {
10 | --ea-color: #0e7a8e;
11 | --alt-ea-color: #46b6ca;
12 | --header-content-height: 2.5rem;
13 | --header-padding: 20px;
14 | --header-height: calc(var(--header-content-height) + 2*var(--header-padding));
15 | --body-height: calc(100vh - var(--header-height));
16 | --sidebar-width: 250px;
17 | }
18 |
19 | * {
20 | scroll-behavior: smooth;
21 | box-sizing: border-box;
22 | }
23 |
24 | body {
25 | font-family: "Raleway", Helvetica, sans-serif;
26 | margin: 0px;
27 | padding: 0px;
28 | overflow-x: hidden;
29 | }
30 |
31 | a {
32 | color: var(--ea-color);
33 | }
34 |
35 | a:hover {
36 | color: var(--alt-ea-color);
37 | }
38 |
39 | .center {
40 | display: grid;
41 | place-items: center;
42 | }
43 |
44 | div {
45 | background-color: white;
46 | }
47 |
48 | .modebar {
49 | background-color: rgba(0, 0, 0, 0);
50 | }
51 |
52 | p, h1, h2, h3, h4 {
53 | color: black;
54 | }
55 |
56 |
57 | .darkmode {
58 | background-color: black;
59 | filter: invert() hue-rotate(180deg) brightness(100%) contrast(105%);
60 | }
61 |
62 | ._dash-loading {
63 | text-align: center;
64 | font-weight: 700;
65 | font-size: 2em;
66 | font-family: "Roboto Slab", "Times New Roman", serif;
67 | display: table-cell;
68 | width: 100vw;
69 | height: 100vh;
70 | padding: 10px;
71 | vertical-align: middle;
72 | }
73 |
74 | @media only screen and (max-width: 700px) {
75 | ._dash-loading {
76 | height: 85vh;
77 | }
78 | }
79 |
80 | .darkmodeloading {
81 | display: none;
82 | }
83 |
84 | /*------------------
85 | HEADER
86 | ------------------*/
87 |
88 | .header {
89 | height: var(--header-height);
90 | display: flex;
91 | padding: var(--header-padding);
92 | }
93 |
94 | .clickable-icon {
95 | padding: 8px 8px;
96 | border-radius: 50%;
97 | }
98 |
99 | .clickable-icon:hover {
100 | background-color: rgba(0, 0, 0, 0.08);
101 | cursor: pointer;
102 | }
103 |
104 | /* the hover-y circle is too faint in night mode */
105 | .nightmode .clickable-icon:hover {
106 | background-color: rgba(0, 0, 0, 0.2);
107 | }
108 |
109 | .right-icons {
110 | margin-left: auto;
111 | display: flex;
112 | }
113 |
114 | .header .icon {
115 | height: var(--header-content-height);
116 | width: var(--header-content-height);
117 | }
118 |
119 | .effective {
120 | font-family: "Roboto Slab", "Times New Roman", serif;
121 | font-weight: 700;
122 | }
123 |
124 | .altruism {
125 | font-family: "Roboto Slab", "Times New Roman", serif;
126 | font-weight: 400;
127 | }
128 |
129 | .header h1 {
130 | font-size: var(--header-content-height);
131 | margin: 0;
132 | padding-left: 10px;
133 | }
134 |
135 |
136 | .short-title {
137 | display: none;
138 | padding-left: 10px;
139 | }
140 |
141 | .long-title {
142 | display: block;
143 | }
144 |
145 | @media only screen and (max-width: 700px) {
146 |
147 | .short-title {
148 | display: block;
149 | }
150 |
151 | .long-title {
152 | display: none;
153 | }
154 |
155 | }
156 |
157 | @media only screen and (max-width: 363px) {
158 |
159 | .short-title {
160 | display: none;
161 | }
162 |
163 | .long-title {
164 | display: none;
165 | }
166 |
167 | }
168 |
169 | @media (prefers-color-scheme: dark) {
170 | #darkmode-button {
171 | content: url("/assets/sun.svg");
172 | }
173 | }
174 |
175 | @media (prefers-color-scheme: light) {
176 | #darkmode-button {
177 | content: url("/assets/moon.svg");
178 | }
179 | }
180 |
181 | .noprefer {
182 | content: unset !important;
183 | }
184 |
185 | /*------------------
186 | BODY
187 | ------------------*/
188 |
189 | .body {
190 | height: var(--body-height);
191 | display: flex;
192 | overflow-x: hidden;
193 | position: relative;
194 | }
195 |
196 |
197 | /*------------------
198 | SIDEBAR
199 | ------------------*/
200 |
201 | #sidebar {
202 | width: var(--sidebar-width);
203 | height: var(--body-height);
204 | overflow: scroll;
205 | padding: 30px;
206 | padding-right: 10px;
207 | z-index:100;
208 | position: absolute;
209 | background-color: white;
210 | -webkit-transition-duration: 600ms;
211 | transition-duration: 600ms;
212 | line-height: 1.7rem
213 | }
214 |
215 | #sidebar-buttress {
216 | width: var(--sidebar-width);
217 | height: var(--body-height);
218 | display: block;
219 | }
220 |
221 | #sidebar p {
222 | margin-block-start: 0;
223 | margin-block-end: 0;
224 | }
225 |
226 | #sidebar ul {
227 | margin-block-start: 0;
228 | margin-block-end: 0;
229 | }
230 |
231 | /* The sidebar is visible by default on desktop but hidden by default on mobile. */
232 |
233 | @media only screen and (min-width: 800px) {
234 |
235 | #sidebar.toggled {
236 | transform: translate(-100%);
237 | }
238 |
239 | #sidebar-buttress.toggled {
240 | display: none;
241 | }
242 |
243 | }
244 |
245 | @media only screen and (max-width: 800px) {
246 |
247 | #sidebar {
248 | transform: translate(-100%);
249 | }
250 |
251 | #sidebar-buttress {
252 | display: none;
253 | }
254 |
255 | #sidebar.toggled {
256 | transform: translate(0%);
257 | }
258 |
259 | #sidebar-buttress.toggled {
260 | display: block;
261 | }
262 |
263 | }
264 | /*------------------
265 | ABOUT BOX
266 | ------------------*/
267 |
268 | /* reduce padding around "contents" */
269 | #about-box h4 {
270 | margin-top: 0;
271 | margin-bottom: 10px;
272 | }
273 |
274 | #about-box {
275 | width: var(--sidebar-width);
276 | height: var(--body-height);
277 | right: 0px;
278 | overflow: scroll;
279 | padding: 30px;
280 | z-index: 99;
281 | background-color: white;
282 | position: absolute;
283 | -webkit-transition-duration: 600ms;
284 | transition-duration: 600ms;
285 | }
286 |
287 | #about-box.hidden {
288 | transform: translate(100%);
289 | }
290 |
291 | /*------------------
292 | CONTENT
293 | ------------------*/
294 |
295 | .content {
296 | height: var(--body-height);
297 | width: 100%;
298 | overflow: scroll;
299 | padding: 30px;
300 | }
301 |
302 | @media only screen and (max-width: 700px) {
303 | .content {
304 | position: absolute;
305 | left: 0;
306 | }
307 | }
308 |
309 | .section {
310 | height: var(--body-height);
311 | scroll-snap-align: start;
312 | margin: 0 auto;
313 | display: flex;
314 | flex-flow: column;
315 | }
316 |
317 | @media only screen and (max-width: 1000px) {
318 | .section {
319 | height: auto;
320 | }
321 | }
322 |
323 | @media screen and (min-width: 1000px) {
324 | .scroll-snapper {
325 | overflow-y: scroll;
326 | scroll-snap-type: y mandatory;
327 | height: var(--body-height);
328 | }
329 | }
330 |
331 | .section-body {
332 | flex: 1;
333 | padding: 20px;
334 | }
335 |
336 | .plot-container {
337 | height: 100%;
338 | width: 100%;
339 | max-height: 100vh;
340 | }
341 |
342 | @media only screen and (max-width: 1000px) {
343 | #gwwc-pledge-section, #gwwc-donations-section, #gwwc-orgs-section {
344 | min-height: 100%;
345 | margin-bottom: 12.5em;
346 | }
347 | }
348 |
349 | /*------------------
350 | GRIDS
351 | ------------------*/
352 |
353 | /*
354 |
355 | Notation:
356 |
357 | cols-x means "x equal size columns"
358 |
359 | mob-cols-x means "x equal size columns on mobile"
360 |
361 | tab-cols-x means "x equal size columns on tablet"
362 |
363 | desk-cols-x means "x equal size columns on desktop"
364 |
365 | cols-a-b means "two columns with a:b ratio"
366 |
367 | etc
368 |
369 | */
370 |
371 | .grid {
372 | display: grid;
373 | grid-gap: 10px;
374 | height: 100%;
375 | width: 100%;
376 | /*
377 | min-height: 0;
378 | min-width: 0;
379 | */
380 | }
381 |
382 | .cols-2-1 { grid-template-columns: 2fr 1fr; }
383 | .rows-2-1 { grid-template-rows: 2fr 1fr; }
384 |
385 | .cols-1 { grid-template-columns: repeat(1, 1fr); }
386 | .cols-2 { grid-template-columns: repeat(2, 1fr); }
387 | .cols-3 { grid-template-columns: repeat(3, 1fr); }
388 |
389 | .rows-1 { grid-template-rows: repeat(1, 1fr); }
390 | .rows-2 { grid-template-rows: repeat(2, 1fr); }
391 | .rows-3 { grid-template-rows: repeat(3, 1fr); }
392 |
393 | @media only screen and (max-width: 700px) {
394 | .mob-cols-1 { grid-template-columns: repeat(1, 1fr); }
395 | .mob-cols-2 { grid-template-columns: repeat(2, 1fr); }
396 | .mob-cols-3 { grid-template-columns: repeat(3, 1fr); }
397 | }
398 |
399 | @media only screen and (min-width: 700px) and (max-width: 1000px) {
400 | .tab-cols-1 { grid-template-columns: repeat(1, 1fr); }
401 | .tab-cols-2 { grid-template-columns: repeat(2, 1fr); }
402 | .tab-cols-3 { grid-template-columns: repeat(3, 1fr); }
403 | .tab-cols-2-1 { grid-template-columns: 2fr 1fr; }
404 | .tab-span-2-cols { grid-column: span 2; }
405 | }
406 |
407 | @media only screen and (min-width: 1000px) {
408 | .desk-rows-2-1 { grid-template-rows: 2fr 1fr; }
409 | .desk-rows-2 { grid-template-rows: repeat(2, 1fr); }
410 | .desk-cols-2-1 { grid-template-columns: 2fr 1fr; }
411 | .desk-cols-1 { grid-template-columns: repeat(1, 1fr); }
412 | .desk-cols-2 { grid-template-columns: repeat(2, 1fr); }
413 | .desk-cols-3 { grid-template-columns: repeat(3, 1fr); }
414 | .desk-span-2-cols { grid-column: span 2; }
415 | }
416 |
417 |
418 |
--------------------------------------------------------------------------------
/components/sections/open_phil.py:
--------------------------------------------------------------------------------
1 | import plotly.express as px
2 | import pandas as pd
3 | from pandas.tseries.offsets import MonthEnd
4 | import numpy as np
5 | from dash import dcc
6 | from dash import html
7 | from dash import dash_table
8 | from utils.plots.bar import Bar
9 | from utils.subtitle import get_instructions
10 | from utils.subtitle import get_data_source
11 | from utils.plots.scatter import Scatter
12 | from utils.plots.line import Line
13 |
14 | op_grants = None
15 | def get_op_grants():
16 | global op_grants
17 | if type(op_grants) != type(None):
18 | return op_grants
19 |
20 | op_grants = pd.read_csv('./assets/data/openphil_grants.csv')
21 | op_grants['Amount'] = op_grants['Amount'].apply(
22 | lambda x: int(x[1:].replace(',','')) if type(x)==str else x
23 | )
24 | op_grants = op_grants.dropna()
25 | op_grants['Focus Area'] = op_grants['Focus Area'].apply(lambda x: x.replace('Artificial Intelligence', 'AI'))
26 | op_grants = op_grants[::-1]
27 |
28 | def normalize_orgname(orgname):
29 | if type(orgname) == str:
30 | orgname = orgname.strip()
31 | if orgname == 'Hellen Keller International':
32 | orgname = 'Helen Keller International'
33 | if orgname == 'Alliance for Safety and Justice':
34 | orgname = 'Alliance for Safety and Justice Action Fund'
35 | return orgname
36 | op_grants['Organization Name'] = op_grants['Organization Name'].apply(normalize_orgname)
37 |
38 | # for finding number of grants
39 | op_grants['grants'] = 1
40 |
41 | op_grants['Date'] = pd.to_datetime(op_grants['Date'], format='%m/%Y')
42 | op_grants = op_grants.sort_values(by='Date', ascending=False)
43 | op_grants['Date_readable'] = op_grants['Date'].dt.strftime('%B %Y')
44 |
45 | # hovertext
46 | def hover(row):
47 | grant = row['Grant']
48 | org = row['Organization Name']
49 | area = row['Focus Area']
50 | date = row['Date_readable']
51 | amount = row['Amount']
52 | return f'{grant}
Date: {date}
Organization: {org}
Amount: ${amount:,.0f}'
53 | op_grants['hover'] = op_grants.apply(hover, axis=1)
54 |
55 | return op_grants
56 |
57 |
58 | def org_bar_chart(op_grants):
59 |
60 | op_orgs = op_grants.groupby(by='Organization Name', as_index=False).sum()
61 | op_orgs = op_orgs.sort_values(by='Amount')
62 | op_orgs['x'] = op_orgs['Organization Name']
63 | # op_orgs['x'] = op_orgs['x'].apply(lambda x: x if len(x) < 30 else x[:27]+'...')
64 | op_orgs['y'] = op_orgs['Amount']
65 | op_orgs['text'] = op_orgs['Amount'].apply(lambda x: f'${x:,.0f}')
66 |
67 | # Some organization names get truncated to the same value.
68 | # This prevents that:
69 | for val in op_orgs['x'].unique():
70 | val_df = op_orgs[ op_orgs['x']==val ]
71 | for i in range(1, len(val_df)):
72 | index = val_df.iloc[i].name
73 | op_orgs.loc[index, 'x'] = op_orgs.loc[index, 'x'][:-3-i] + '...'
74 |
75 | def hover(row):
76 | org = row['Organization Name']
77 | amount = row['text']
78 | grants = row['grants']
79 | return f'{org}
{grants} grants
{amount} total'
80 | op_orgs['hover'] = op_orgs.apply(hover, axis=1)
81 |
82 | op_orgs_truncated = op_orgs.reset_index().iloc[:20]
83 |
84 | return Bar(op_orgs_truncated, title='Top 20 Donee Organizations')
85 |
86 |
87 | def cause_bar_chart(op_grants):
88 |
89 | op_causes = op_grants.groupby(by='Focus Area', as_index=False).sum()
90 | op_causes = op_causes.sort_values(by='Amount')
91 | op_causes['x'] = op_causes['Focus Area']
92 | op_causes['y'] = op_causes['Amount']
93 | op_causes['text'] = op_causes['Amount'].apply(lambda x: f'${x:,.0f}')
94 |
95 | def hover(row):
96 | area = row['Focus Area']
97 | amount = row['text']
98 | grants = row['grants']
99 | return f'{area}
{grants} grants
{amount} total'
100 | op_causes['hover'] = op_causes.apply(hover, axis=1)
101 |
102 | height_per_bar = 25 if len(op_causes) > 10 else 28
103 | height = height_per_bar * len(op_causes) + 20
104 | return Bar(op_causes, height=height, title='Focus Areas')
105 |
106 |
107 | def grants_scatter(op_grants):
108 | return Scatter(
109 | op_grants,
110 | x = "Date",
111 | y = "Amount",
112 | # color="Focus Area",
113 | # size='Amount',
114 | hover = 'hover',
115 | log_y = True,
116 | title = 'Individual Grants (log)',
117 | y_title = 'Amount (USD)',
118 | x_title = '',
119 | )
120 |
121 | def openphil_grants_scatter_section():
122 |
123 | op_grants = get_op_grants()
124 |
125 | return html.Div(
126 | [
127 | html.Div(
128 | html.H2('Open Philanthropy Grants'),
129 | className='section-title',
130 | ),
131 | get_instructions('open_phil'),
132 | html.Div(
133 | [
134 | html.Div(
135 | grants_scatter(op_grants),
136 | className='plot-container',
137 | ),
138 | ],
139 | className='section-body'
140 | ),
141 | get_data_source('open_phil'),
142 | ],
143 | className = 'section',
144 | id='op-grants-scatter-section',
145 | )
146 |
147 | def openphil_grants_categories_section():
148 |
149 | op_grants = get_op_grants()
150 |
151 | return html.Div(
152 | [
153 | html.Div(
154 | html.H2('Open Philanthropy Grants by Focus Area and Donee Organization'),
155 | className='section-title',
156 | ),
157 | get_instructions(),
158 | html.Div(
159 | html.Div(
160 | [
161 | html.Div(
162 | cause_bar_chart(op_grants),
163 | className='plot-container',
164 | ),
165 | html.Div(
166 | org_bar_chart(op_grants),
167 | className='plot-container',
168 | ),
169 | ],
170 | className='grid desk-cols-2 tab-cols-2',
171 | ),
172 | className='section-body'
173 | ),
174 | get_data_source('open_phil'),
175 | ],
176 | className = 'section',
177 | id='op-grants-categories',
178 | )
179 |
180 | def group_by_month(op_grants):
181 |
182 | # Round the dates to the end of the month
183 | op_grants['Date'] += MonthEnd(1)
184 |
185 | # Generate a date range up to the present
186 | min_date = op_grants['Date'].min()
187 | max_date = op_grants['Date'].max()
188 | dates = pd.date_range(start=min_date, end=max_date, freq='M')
189 |
190 | grants_by_month = pd.DataFrame(columns=[
191 | 'date',
192 | 'grants',
193 | 'focus_areas',
194 | 'organizations',
195 | 'total_amount',
196 | 'n_grants',
197 | ])
198 |
199 | for i, date in enumerate(dates):
200 | grants_by_month_i = op_grants.loc[ op_grants['Date'] == date ]
201 | grants_by_month.loc[i, 'date'] = date
202 | grants_by_month.loc[i, 'grants'] = grants_by_month_i['Grant'].tolist()
203 | grants_by_month.loc[i, 'focus_areas'] = grants_by_month_i['Focus Area'].tolist()
204 | grants_by_month.loc[i, 'organizations'] = grants_by_month_i['Focus Area'].tolist()
205 | grants_by_month.loc[i, 'total_amount'] = grants_by_month_i['Amount'].sum()
206 | grants_by_month.loc[i, 'n_grants'] = len(grants_by_month_i)
207 |
208 | return grants_by_month
209 |
210 |
211 | def openphil_line_plot_section():
212 |
213 | op_grants = get_op_grants()
214 | op_grants = op_grants.sort_values(by='Date').reset_index()
215 |
216 | def monthly_hover(row):
217 | month = row['date'].strftime('%B %Y')
218 | result = ''
219 | result += f"{month}"
220 | result += f"
{row.n_grants} grants"
221 | result += f"
${row.total_amount:,.2f} total value"
222 | return result
223 |
224 | grants_by_month = group_by_month(op_grants)
225 |
226 | grants_by_month['hover'] = grants_by_month.apply(monthly_hover, axis=1)
227 | last_row = grants_by_month.iloc[len(grants_by_month)-1]
228 | last_month = last_row['date'].strftime('%B %Y')
229 | label = ''
230 | label += f"${last_row.total_amount/1e6:,.1f} Million"
231 | label += f"
{last_month}"
232 | grants_by_month['label'] = label
233 |
234 | month_grants_graph = Line(
235 | grants_by_month,
236 | x = 'date',
237 | y = 'total_amount',
238 | x_title = '',
239 | y_title = '',
240 | hover = 'hover',
241 | title = 'Granted Amount by Month',
242 | label = 'label',
243 | xanchor='left',
244 | dollars=True,
245 | )
246 |
247 |
248 | op_grants['cumulative_amount'] = op_grants['Amount'].cumsum()
249 |
250 | def cumulative_hover(row):
251 | result = row['hover']
252 | result += f"
${row.cumulative_amount:,.2f} total"
253 | return result
254 |
255 | op_grants['hover'] = op_grants.apply(cumulative_hover, axis=1)
256 | grants_total = op_grants['cumulative_amount'].tolist()[-1]
257 | op_grants['label'] = f"${grants_total/1e9:,.2f} Billion
Total Grants"
258 |
259 | total_grants_graph = Line(
260 | op_grants,
261 | x = 'Date',
262 | y = 'cumulative_amount',
263 | x_title = '',
264 | y_title = '',
265 | hover = 'hover',
266 | title = 'Total Granted Amount',
267 | label = 'label',
268 | dollars=True,
269 | )
270 |
271 | return html.Div(
272 | [
273 | html.Div(
274 | html.H2('Open Philanthropy Grants Over Time'),
275 | className='section-title',
276 | ),
277 | get_instructions(),
278 | html.Div(
279 | html.Div(
280 | [
281 | html.Div(
282 | month_grants_graph,
283 | className='plot-container',
284 | ),
285 | html.Div(
286 | total_grants_graph,
287 | className='plot-container',
288 | ),
289 | ],
290 | className='grid desk-cols-2 tab-cols-2',
291 | ),
292 | className='section-body'
293 | ),
294 | get_data_source('open_phil'),
295 | ],
296 | className = 'section',
297 | id='op-grants-growth',
298 | )
299 |
--------------------------------------------------------------------------------
/components/sections/forum.py:
--------------------------------------------------------------------------------
1 | from dash import dcc
2 | from dash import html
3 | from dash import dash_table
4 |
5 | import pandas as pd
6 | import numpy as np
7 |
8 | from math import log
9 | from utils.subtitle import get_data_source
10 | from utils.subtitle import get_instructions
11 | import json
12 |
13 | from utils.plots.bar import Bar
14 | from utils.plots.line import Line
15 | from utils.plots.scatter import Scatter
16 | from utils.plots.wilkinson import Wilkinson
17 |
18 | posts_df = None
19 | def get_forum_data():
20 | global posts_df
21 | if type(posts_df) != type(None):
22 | return posts_df
23 |
24 | with open('./assets/data/ea_forum.json', 'r') as forum_file:
25 | forum_json = json.loads(forum_file.read())
26 |
27 | posts = forum_json['data']['posts']['results']
28 |
29 | posts_df = pd.DataFrame(
30 | columns=['title', 'posted_at', 'authors', 'url', 'wordcount', 'karma', 'comments']
31 | )
32 |
33 | for post in posts:
34 |
35 | author_list = []
36 | try:
37 | author_list.append( post['user']['displayName'] )
38 | except:
39 | author_list.append('anonymous')
40 | for coauthor in post['coauthors']:
41 | author_list.append( coauthor['displayName'] )
42 | author_string = ', '.join(author_list)
43 |
44 | comment_count = post['commentCount']
45 | # resolve nulls to zero
46 | comment_count = comment_count if comment_count else 0
47 |
48 | wordcount = post['wordCount']
49 | # resolve nulls to zero
50 | wordcount = wordcount if wordcount else 0
51 |
52 | posts_df.loc[len(posts_df), :] = [
53 | post['title'],
54 | post['postedAt'],
55 | author_string,
56 | post['pageUrl'],
57 | wordcount,
58 | post['baseScore'],
59 | comment_count,
60 | ]
61 |
62 | # remove very low karma posts
63 | posts_df = posts_df.loc[ posts_df['karma'] > -20 ]
64 |
65 | posts_df['posted_at'] = pd.to_datetime(posts_df['posted_at'])#, format='%m/%Y')
66 | posts_df = posts_df.sort_values(by='posted_at', ascending=False)
67 | posts_df['posted_at_readable'] = posts_df['posted_at'].dt.strftime('%d %b %Y')
68 | posts_df['size'] = posts_df['wordcount'] + 1
69 |
70 | # hovertext
71 | def hover(row):
72 |
73 | title = row['title']
74 | posted_at = row['posted_at_readable']
75 | authors = row['authors']
76 | wordcount = row['wordcount']
77 | karma = row['karma']
78 | comments = row['comments']
79 |
80 | result = ''
81 | result += f"{title}"
82 | result += f"
{authors}"
83 | result += f"
Posted {posted_at}"
84 | result += f"
{karma} karma, {comments} comments"
85 |
86 | return result
87 |
88 | posts_df['hover'] = posts_df.apply(hover, axis=1)
89 |
90 | return posts_df
91 |
92 |
93 | def forum_scatter(forum_df):
94 |
95 | return Scatter(
96 | forum_df,
97 | x = "posted_at",
98 | y = "karma",
99 | x_title = "Date Posted",
100 | y_title = "Karma",
101 | title = "All EA Forum Posts",
102 | hover = 'hover',
103 | )
104 |
105 | def forum_scatter_section():
106 |
107 | forum_df = get_forum_data()
108 |
109 | return html.Div(
110 | [
111 | html.Div(
112 | html.H2('EA Forum Posts by Date Posted and Karma'),
113 | className='section-title',
114 | ),
115 | get_instructions(hover='points', zoom=True),
116 | html.Div(
117 | [
118 | html.Div(
119 | forum_scatter(forum_df),
120 | className='plot-container',
121 | ),
122 | ],
123 | className='section-body'
124 | ),
125 | get_data_source('ea_forum'),
126 | ],
127 | className = 'section',
128 | id='forum-scatter-section',
129 | )
130 |
131 | def post_counts(forum_df):
132 |
133 |
134 | forum_df = forum_df.sort_values(by='posted_at')
135 |
136 | forum_df['Unit'] = 1
137 | forum_df['Count'] = forum_df['Unit'].cumsum()
138 | forum_df['posted_at'] = forum_df['posted_at'].dt.date
139 | forum_df['cumulative_word_count'] = forum_df['wordcount'].cumsum()
140 |
141 | authors = set()
142 | def new_authors(author_string):
143 | author_list = author_string.split(',')
144 | author_list = [ author.strip() for author in author_list ]
145 | new_authors = []
146 | for author in author_list:
147 | if author not in authors:
148 | new_authors.append(author)
149 | authors.add(author)
150 | return new_authors
151 |
152 | forum_df['new_authors'] = forum_df['authors'].apply(new_authors)
153 | forum_df['new_author_count'] = forum_df['new_authors'].apply(len)
154 | forum_df['author_count'] = forum_df['new_author_count'].cumsum()
155 |
156 | posted_at_groups = forum_df.groupby('posted_at')
157 | forum_by_day_df = pd.DataFrame({
158 | 'posted_at': forum_df['posted_at'].unique(),
159 | 'posted_at_readable': forum_df['posted_at_readable'].unique(),
160 | })
161 |
162 | # new posts
163 |
164 | forum_by_day_df['titles'] = posted_at_groups['title'].apply(list).tolist()
165 | forum_by_day_df['new_posts'] = posted_at_groups['Unit'].sum().tolist()
166 | forum_by_day_df['total_posts'] = posted_at_groups['Count'].last().tolist()
167 |
168 | label = forum_df['Count'].tolist()[-1]
169 | label = f'{label:,} Posts'
170 | forum_by_day_df['new_posts_label'] = label
171 |
172 | def new_posts_hover(row):
173 |
174 | new_posts = row['new_posts']
175 | total_posts = row['total_posts']
176 | posted_at = row['posted_at_readable']
177 | titles = row['titles']
178 |
179 | max_displayed_titles = 10
180 | if len(titles) > max_displayed_titles:
181 | titles = titles[:max_displayed_titles] + ['...']
182 |
183 | result = ''
184 | result += f"{posted_at}"
185 | result += f"
{new_posts} new posts ({total_posts:,} total):"
186 | for title in titles:
187 |
188 | max_title_length = 50
189 | if len(title) > max_title_length:
190 | title = title[:max_title_length] + '...'
191 | result += f"
{title}"
192 |
193 | return result
194 |
195 | forum_by_day_df['new_posts_hover'] = forum_by_day_df.apply(new_posts_hover, axis=1)
196 |
197 |
198 | # new authors
199 |
200 | forum_by_day_df['new_authors'] = posted_at_groups['new_authors'].sum().tolist()
201 | forum_by_day_df['new_author_count'] = posted_at_groups['new_author_count'].sum().tolist()
202 | forum_by_day_df['author_count'] = posted_at_groups['author_count'].last().tolist()
203 |
204 | label = forum_df['author_count'].tolist()[-1]
205 | label = f'{label:,} Unique Authors'
206 | forum_by_day_df['new_authors_label'] = label
207 |
208 | def new_authors_hover(row):
209 |
210 | new_authors = row['new_authors']
211 | new_authors_count = row['new_author_count']
212 | total_authors = row['author_count']
213 | posted_at = row['posted_at_readable']
214 |
215 | max_displayed_authors = 10
216 | if len(new_authors) > max_displayed_authors:
217 | new_authors = new_authors[:max_displayed_authors] + ['...']
218 |
219 | result = ''
220 | result += f"{posted_at}"
221 | result += f"
{new_authors_count} new authors ({total_authors:,} total):"
222 | for author in new_authors:
223 |
224 | max_author_length = 50
225 | if len(author) > max_author_length:
226 | author = author[:max_author_length] + '...'
227 | result += f"
{author}"
228 |
229 | return result
230 |
231 | forum_by_day_df['new_authors_hover'] = forum_by_day_df.apply(new_authors_hover, axis=1)
232 |
233 |
234 | # word count
235 |
236 |
237 | forum_by_day_df['new_words'] = posted_at_groups['wordcount'].sum().tolist()
238 | forum_by_day_df['total_words'] = posted_at_groups['cumulative_word_count'].last().tolist()
239 |
240 | label = forum_by_day_df['total_words'].tolist()[-1]
241 | label = f'{label:,} Words'
242 | forum_by_day_df['word_count_label'] = label
243 |
244 | def word_count_hover(row):
245 |
246 | new_words = row['new_words']
247 | total_words = row['total_words']
248 | posted_at = row['posted_at_readable']
249 |
250 | result = ''
251 | result += f"{posted_at}"
252 | result += f"
{total_words:,} total words"
253 | result += f"
{new_words:,} new words"
254 |
255 | return result
256 |
257 | forum_by_day_df['word_count_hover'] = forum_by_day_df.apply(word_count_hover, axis=1)
258 |
259 |
260 |
261 | # New posts line plot
262 |
263 | post_count_graph = Line(
264 | forum_by_day_df,
265 | x='posted_at',
266 | y='total_posts',
267 | x_title = '',
268 | y_title = '',
269 | hover = 'new_posts_hover',
270 | title = 'Number of Posts',
271 | label = 'new_posts_label',
272 | )
273 |
274 | # New authors line plot
275 |
276 | unique_authors_df = forum_by_day_df.loc[ forum_by_day_df['new_author_count'] > 0 ]
277 |
278 | author_count_graph = Line(
279 | unique_authors_df,
280 | x='posted_at',
281 | y='author_count',
282 | x_title = '',
283 | y_title = '',
284 | hover = 'new_authors_hover',
285 | title = 'Number of Unique Author',
286 | label = 'new_authors_label',
287 | )
288 |
289 |
290 |
291 | # New words line plot
292 |
293 | new_words_df = forum_by_day_df.loc[ forum_by_day_df['new_words'] > 0 ]
294 |
295 | word_count_graph = Line(
296 | new_words_df,
297 | x = 'posted_at',
298 | y = 'total_words',
299 | x_title = '',
300 | y_title = '',
301 | hover = 'word_count_hover',
302 | title = 'Total Word Count',
303 | label = 'word_count_label',
304 | )
305 |
306 | return [
307 | post_count_graph,
308 | author_count_graph,
309 | word_count_graph,
310 | ]
311 |
312 | def forum_count_section():
313 |
314 | forum_df = get_forum_data()
315 |
316 | post_count_graph, author_count_graph, word_count_graph = post_counts(forum_df)
317 |
318 | return html.Div(
319 | [
320 | html.Div(
321 | html.H2('Growth in EA Forum Activity'),
322 | className='section-title',
323 | ),
324 | get_instructions(hover='points', zoom=True),
325 | html.Div(
326 | [
327 | html.Div(
328 | post_count_graph,
329 | className='plot-container',
330 | ),
331 | html.Div(
332 | author_count_graph,
333 | className='plot-container',
334 | ),
335 | html.Div(
336 | word_count_graph,
337 | className='plot-container',
338 | ),
339 | ],
340 | className='grid desk-cols-3 section-body'
341 | ),
342 | get_data_source('ea_forum'),
343 | ],
344 | className = 'section',
345 | id='forum-growth-section',
346 | )
347 |
348 | def forum_post_wilkinson_section():
349 |
350 | forum_df = get_forum_data()
351 |
352 | karma_graph = Wilkinson(
353 | forum_df.sort_values('karma'),
354 | value='karma',
355 | text='title',
356 | title='Posts by Karma',
357 | y_title='Karma',
358 | hover='hover',
359 | )
360 | length_graph = Wilkinson(
361 | forum_df.sort_values('wordcount'),
362 | value='wordcount',
363 | text='title',
364 | title='Posts by Wordcount',
365 | y_title='Words',
366 | hover='hover',
367 | )
368 | date_graph = Wilkinson(
369 | forum_df.sort_values('posted_at'),
370 | value='posted_at',
371 | text='title',
372 | title='Posts by Date Posted',
373 | y_title='Date Posted',
374 | hover='hover',
375 | )
376 |
377 | return html.Div(
378 | [
379 | html.Div(
380 | html.H2('EA Forum Posts: Karma, Wordcount, and Date Posted'),
381 | className='section-title',
382 | ),
383 | get_instructions(hover='points', zoom=True),
384 | html.Div(
385 | [
386 | html.Div(
387 | karma_graph,
388 | className='plot-container',
389 | ),
390 | html.Div(
391 | length_graph,
392 | className='plot-container',
393 | ),
394 | html.Div(
395 | date_graph,
396 | className='plot-container',
397 | ),
398 | ],
399 | className='grid desk-cols-3 section-body'
400 | ),
401 | get_data_source('ea_forum'),
402 | ],
403 | className = 'section',
404 | id='post-wilkinson-section',
405 | )
406 |
407 | def forum_user_wilkinson_section():
408 |
409 | forum_df = get_forum_data()
410 |
411 | # Only consider first author
412 | forum_df['first_author'] = forum_df['authors'].apply(lambda x: x.split(',')[0].strip())
413 | forum_df = forum_df.sort_values(['first_author', 'posted_at'])
414 |
415 | author_groups = forum_df.groupby('first_author')
416 | author_df = pd.DataFrame({
417 | 'author': forum_df['first_author'].unique(),
418 | })
419 | author_df['karma'] = author_groups['karma'].sum().tolist()
420 | author_df['wordcount'] = author_groups['wordcount'].sum().tolist()
421 | author_df['posted_at'] = author_groups['posted_at'].first().tolist()
422 | author_df['posted_at_readable'] = author_groups['posted_at_readable'].first().tolist()
423 |
424 | def hover(row):
425 |
426 | author = row['author']
427 | posted_at = row['posted_at_readable']
428 | wordcount = row['wordcount']
429 | karma = row['karma']
430 |
431 | result = ''
432 | result += f"{author}"
433 | result += f"
First posted: {posted_at}"
434 | result += f"
Total karma: {karma:,}"
435 | result += f"
Total wordcount: {wordcount:,}"
436 |
437 | return result
438 |
439 | author_df['hover'] = author_df.apply(hover, axis=1)
440 |
441 | karma_graph = Wilkinson(
442 | author_df.sort_values('karma'),
443 | value='karma',
444 | text='author',
445 | title='Authors by Total Karma',
446 | y_title='Karma',
447 | hover='hover',
448 | bins=30,
449 | )
450 | length_graph = Wilkinson(
451 | author_df.sort_values('wordcount'),
452 | value='wordcount',
453 | text='author',
454 | title='Authors by Total Wordcount',
455 | y_title='Words',
456 | hover='hover',
457 | bins=30,
458 | )
459 | date_graph = Wilkinson(
460 | author_df.sort_values('posted_at'),
461 | value='posted_at',
462 | text='author',
463 | title='Authors by Date of First Post',
464 | y_title='Date Posted',
465 | hover='hover',
466 | )
467 |
468 | return html.Div(
469 | [
470 | html.Div(
471 | html.H2("EA Forum Authors: Total Karma, Total Wordcount, and Date of First Post"),
472 | className='section-title',
473 | ),
474 | get_instructions(hover='points', zoom=True),
475 | html.Div(
476 | [
477 | html.Div(
478 | karma_graph,
479 | className='plot-container',
480 | ),
481 | html.Div(
482 | length_graph,
483 | className='plot-container',
484 | ),
485 | html.Div(
486 | date_graph,
487 | className='plot-container',
488 | ),
489 | ],
490 | className='grid desk-cols-3 section-body'
491 | ),
492 | get_data_source('ea_forum'),
493 | ],
494 | className = 'section',
495 | id='author-wilkinson-section',
496 | )
497 |
--------------------------------------------------------------------------------
/Pipfile.lock:
--------------------------------------------------------------------------------
1 | {
2 | "_meta": {
3 | "hash": {
4 | "sha256": "92201af28e38e7b203ea635747c69bf47e51e7177d4848bb419f6bb4f49babd7"
5 | },
6 | "pipfile-spec": 6,
7 | "requires": {
8 | "python_version": "3.9"
9 | },
10 | "sources": [
11 | {
12 | "name": "pypi",
13 | "url": "https://pypi.org/simple",
14 | "verify_ssl": true
15 | }
16 | ]
17 | },
18 | "default": {
19 | "beautifulsoup4": {
20 | "hashes": [
21 | "sha256:58d5c3d29f5a36ffeb94f02f0d786cd53014cf9b3b3951d42e0080d8a9498d30",
22 | "sha256:ad9aa55b65ef2808eb405f46cf74df7fcb7044d5cbc26487f96eb2ef2e436693"
23 | ],
24 | "markers": "python_full_version >= '3.6.0'",
25 | "version": "==4.11.1"
26 | },
27 | "brotli": {
28 | "hashes": [
29 | "sha256:12effe280b8ebfd389022aa65114e30407540ccb89b177d3fbc9a4f177c4bd5d",
30 | "sha256:160c78292e98d21e73a4cc7f76a234390e516afcd982fa17e1422f7c6a9ce9c8",
31 | "sha256:16d528a45c2e1909c2798f27f7bf0a3feec1dc9e50948e738b961618e38b6a7b",
32 | "sha256:19598ecddd8a212aedb1ffa15763dd52a388518c4550e615aed88dc3753c0f0c",
33 | "sha256:1c48472a6ba3b113452355b9af0a60da5c2ae60477f8feda8346f8fd48e3e87c",
34 | "sha256:268fe94547ba25b58ebc724680609c8ee3e5a843202e9a381f6f9c5e8bdb5c70",
35 | "sha256:269a5743a393c65db46a7bb982644c67ecba4b8d91b392403ad8a861ba6f495f",
36 | "sha256:26d168aac4aaec9a4394221240e8a5436b5634adc3cd1cdf637f6645cecbf181",
37 | "sha256:29d1d350178e5225397e28ea1b7aca3648fcbab546d20e7475805437bfb0a130",
38 | "sha256:2aad0e0baa04517741c9bb5b07586c642302e5fb3e75319cb62087bd0995ab19",
39 | "sha256:3496fc835370da351d37cada4cf744039616a6db7d13c430035e901443a34daa",
40 | "sha256:35a3edbe18e876e596553c4007a087f8bcfd538f19bc116917b3c7522fca0429",
41 | "sha256:3b78a24b5fd13c03ee2b7b86290ed20efdc95da75a3557cc06811764d5ad1126",
42 | "sha256:40d15c79f42e0a2c72892bf407979febd9cf91f36f495ffb333d1d04cebb34e4",
43 | "sha256:44bb8ff420c1d19d91d79d8c3574b8954288bdff0273bf788954064d260d7ab0",
44 | "sha256:4688c1e42968ba52e57d8670ad2306fe92e0169c6f3af0089be75bbac0c64a3b",
45 | "sha256:495ba7e49c2db22b046a53b469bbecea802efce200dffb69b93dd47397edc9b6",
46 | "sha256:4d1b810aa0ed773f81dceda2cc7b403d01057458730e309856356d4ef4188438",
47 | "sha256:503fa6af7da9f4b5780bb7e4cbe0c639b010f12be85d02c99452825dd0feef3f",
48 | "sha256:56d027eace784738457437df7331965473f2c0da2c70e1a1f6fdbae5402e0389",
49 | "sha256:5913a1177fc36e30fcf6dc868ce23b0453952c78c04c266d3149b3d39e1410d6",
50 | "sha256:5b6ef7d9f9c38292df3690fe3e302b5b530999fa90014853dcd0d6902fb59f26",
51 | "sha256:5cb1e18167792d7d21e21365d7650b72d5081ed476123ff7b8cac7f45189c0c7",
52 | "sha256:61a7ee1f13ab913897dac7da44a73c6d44d48a4adff42a5701e3239791c96e14",
53 | "sha256:622a231b08899c864eb87e85f81c75e7b9ce05b001e59bbfbf43d4a71f5f32b2",
54 | "sha256:68715970f16b6e92c574c30747c95cf8cf62804569647386ff032195dc89a430",
55 | "sha256:6b2ae9f5f67f89aade1fab0f7fd8f2832501311c363a21579d02defa844d9296",
56 | "sha256:6c772d6c0a79ac0f414a9f8947cc407e119b8598de7621f39cacadae3cf57d12",
57 | "sha256:6d847b14f7ea89f6ad3c9e3901d1bc4835f6b390a9c71df999b0162d9bb1e20f",
58 | "sha256:76ffebb907bec09ff511bb3acc077695e2c32bc2142819491579a695f77ffd4d",
59 | "sha256:7bbff90b63328013e1e8cb50650ae0b9bac54ffb4be6104378490193cd60f85a",
60 | "sha256:7cb81373984cc0e4682f31bc3d6be9026006d96eecd07ea49aafb06897746452",
61 | "sha256:7ee83d3e3a024a9618e5be64648d6d11c37047ac48adff25f12fa4226cf23d1c",
62 | "sha256:854c33dad5ba0fbd6ab69185fec8dab89e13cda6b7d191ba111987df74f38761",
63 | "sha256:85f7912459c67eaab2fb854ed2bc1cc25772b300545fe7ed2dc03954da638649",
64 | "sha256:87fdccbb6bb589095f413b1e05734ba492c962b4a45a13ff3408fa44ffe6479b",
65 | "sha256:88c63a1b55f352b02c6ffd24b15ead9fc0e8bf781dbe070213039324922a2eea",
66 | "sha256:8a674ac10e0a87b683f4fa2b6fa41090edfd686a6524bd8dedbd6138b309175c",
67 | "sha256:93130612b837103e15ac3f9cbacb4613f9e348b58b3aad53721d92e57f96d46a",
68 | "sha256:9744a863b489c79a73aba014df554b0e7a0fc44ef3f8a0ef2a52919c7d155031",
69 | "sha256:9749a124280a0ada4187a6cfd1ffd35c350fb3af79c706589d98e088c5044267",
70 | "sha256:97f715cf371b16ac88b8c19da00029804e20e25f30d80203417255d239f228b5",
71 | "sha256:9bf919756d25e4114ace16a8ce91eb340eb57a08e2c6950c3cebcbe3dff2a5e7",
72 | "sha256:9d12cf2851759b8de8ca5fde36a59c08210a97ffca0eb94c532ce7b17c6a3d1d",
73 | "sha256:9ed4c92a0665002ff8ea852353aeb60d9141eb04109e88928026d3c8a9e5433c",
74 | "sha256:a72661af47119a80d82fa583b554095308d6a4c356b2a554fdc2799bc19f2a43",
75 | "sha256:afde17ae04d90fbe53afb628f7f2d4ca022797aa093e809de5c3cf276f61bbfa",
76 | "sha256:b336c5e9cf03c7be40c47b5fd694c43c9f1358a80ba384a21969e0b4e66a9b17",
77 | "sha256:b663f1e02de5d0573610756398e44c130add0eb9a3fc912a09665332942a2efb",
78 | "sha256:b83bb06a0192cccf1eb8d0a28672a1b79c74c3a8a5f2619625aeb6f28b3a82bb",
79 | "sha256:c2415d9d082152460f2bd4e382a1e85aed233abc92db5a3880da2257dc7daf7b",
80 | "sha256:c83aa123d56f2e060644427a882a36b3c12db93727ad7a7b9efd7d7f3e9cc2c4",
81 | "sha256:cfc391f4429ee0a9370aa93d812a52e1fee0f37a81861f4fdd1f4fb28e8547c3",
82 | "sha256:db844eb158a87ccab83e868a762ea8024ae27337fc7ddcbfcddd157f841fdfe7",
83 | "sha256:defed7ea5f218a9f2336301e6fd379f55c655bea65ba2476346340a0ce6f74a1",
84 | "sha256:e16eb9541f3dd1a3e92b89005e37b1257b157b7256df0e36bd7b33b50be73bcb",
85 | "sha256:e23281b9a08ec338469268f98f194658abfb13658ee98e2b7f85ee9dd06caa91",
86 | "sha256:e2d9e1cbc1b25e22000328702b014227737756f4b5bf5c485ac1d8091ada078b",
87 | "sha256:e48f4234f2469ed012a98f4b7874e7f7e173c167bed4934912a29e03167cf6b1",
88 | "sha256:e4c4e92c14a57c9bd4cb4be678c25369bf7a092d55fd0866f759e425b9660806",
89 | "sha256:ec1947eabbaf8e0531e8e899fc1d9876c179fc518989461f5d24e2223395a9e3",
90 | "sha256:f909bbbc433048b499cb9db9e713b5d8d949e8c109a2a548502fb9aa8630f0b1"
91 | ],
92 | "version": "==1.0.9"
93 | },
94 | "bs4": {
95 | "hashes": [
96 | "sha256:36ecea1fd7cc5c0c6e4a1ff075df26d50da647b75376626cc186e2212886dd3a"
97 | ],
98 | "index": "pypi",
99 | "version": "==0.0.1"
100 | },
101 | "certifi": {
102 | "hashes": [
103 | "sha256:0d9c601124e5a6ba9712dbc60d9c53c21e34f5f641fe83002317394311bdce14",
104 | "sha256:90c1a32f1d68f940488354e36370f6cca89f0f106db09518524c88d6ed83f382"
105 | ],
106 | "markers": "python_full_version >= '3.6.0'",
107 | "version": "==2022.9.24"
108 | },
109 | "charset-normalizer": {
110 | "hashes": [
111 | "sha256:2857e29ff0d34db842cd7ca3230549d1a697f96ee6d3fb071cfa6c7393832597",
112 | "sha256:6881edbebdb17b39b4eaaa821b438bf6eddffb4468cf344f09f89def34a8b1df"
113 | ],
114 | "markers": "python_version >= '3'",
115 | "version": "==2.0.12"
116 | },
117 | "click": {
118 | "hashes": [
119 | "sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e",
120 | "sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48"
121 | ],
122 | "markers": "python_version >= '3.7'",
123 | "version": "==8.1.3"
124 | },
125 | "countryinfo": {
126 | "hashes": [
127 | "sha256:fd518b3fd8899f6520518320ac17b67bf410c7db5044c61cb191f802bb85c34d"
128 | ],
129 | "index": "pypi",
130 | "version": "==0.1.2"
131 | },
132 | "dash": {
133 | "hashes": [
134 | "sha256:23f331533663641a5c70a15c46da26d29ef5335f9aeb8bc03d09de865fc7cd62",
135 | "sha256:29277c24e2f795b069cb102ce1ab0cd3ad5cf9d3b4fd16c03da9671a5eea28a4"
136 | ],
137 | "index": "pypi",
138 | "version": "==2.0.0"
139 | },
140 | "dash-core-components": {
141 | "hashes": [
142 | "sha256:52b8e8cce13b18d0802ee3acbc5e888cb1248a04968f962d63d070400af2e346",
143 | "sha256:c6733874af975e552f95a1398a16c2ee7df14ce43fa60bb3718a3c6e0b63ffee"
144 | ],
145 | "version": "==2.0.0"
146 | },
147 | "dash-dangerously-set-inner-html": {
148 | "hashes": [
149 | "sha256:d7fe990755851fc4d2e22c8f10b7aea055cabf380bbceefba589779b269fea64"
150 | ],
151 | "index": "pypi",
152 | "version": "==0.0.2"
153 | },
154 | "dash-html-components": {
155 | "hashes": [
156 | "sha256:8703a601080f02619a6390998e0b3da4a5daabe97a1fd7a9cebc09d015f26e50",
157 | "sha256:b42cc903713c9706af03b3f2548bda4be7307a7cf89b7d6eae3da872717d1b63"
158 | ],
159 | "version": "==2.0.0"
160 | },
161 | "dash-table": {
162 | "hashes": [
163 | "sha256:18624d693d4c8ef2ddec99a6f167593437a7ea0bf153aa20f318c170c5bc7308",
164 | "sha256:19036fa352bb1c11baf38068ec62d172f0515f73ca3276c79dee49b95ddc16c9"
165 | ],
166 | "version": "==5.0.0"
167 | },
168 | "flask": {
169 | "hashes": [
170 | "sha256:642c450d19c4ad482f96729bd2a8f6d32554aa1e231f4f6b4e7e5264b16cca2b",
171 | "sha256:b9c46cc36662a7949f34b52d8ec7bb59c0d74ba08ba6cb9ce9adc1d8676d9526"
172 | ],
173 | "markers": "python_version >= '3.7'",
174 | "version": "==2.2.2"
175 | },
176 | "flask-compress": {
177 | "hashes": [
178 | "sha256:1128f71fbd788393ce26830c51f8b5a1a7a4d085e79a21a5cddf4c057dcd559b",
179 | "sha256:ee96f18bf9b00f2deb4e3406ca4a05093aa80e2ef0578525a3b4d32ecdff129d"
180 | ],
181 | "version": "==1.13"
182 | },
183 | "gunicorn": {
184 | "hashes": [
185 | "sha256:9dcc4547dbb1cb284accfb15ab5667a0e5d1881cc443e0677b4882a4067a807e",
186 | "sha256:e0a968b5ba15f8a328fdfd7ab1fcb5af4470c28aaf7e55df02a99bc13138e6e8"
187 | ],
188 | "index": "pypi",
189 | "version": "==20.1.0"
190 | },
191 | "idna": {
192 | "hashes": [
193 | "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4",
194 | "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"
195 | ],
196 | "markers": "python_version >= '3'",
197 | "version": "==3.4"
198 | },
199 | "importlib-metadata": {
200 | "hashes": [
201 | "sha256:da31db32b304314d044d3c12c79bd59e307889b287ad12ff387b3500835fc2ab",
202 | "sha256:ddb0e35065e8938f867ed4928d0ae5bf2a53b7773871bfe6bcc7e4fcdc7dea43"
203 | ],
204 | "markers": "python_version < '3.10'",
205 | "version": "==5.0.0"
206 | },
207 | "itsdangerous": {
208 | "hashes": [
209 | "sha256:2c2349112351b88699d8d4b6b075022c0808887cb7ad10069318a8b0bc88db44",
210 | "sha256:5dbbc68b317e5e42f327f9021763545dc3fc3bfe22e6deb96aaf1fc38874156a"
211 | ],
212 | "markers": "python_version >= '3.7'",
213 | "version": "==2.1.2"
214 | },
215 | "jinja2": {
216 | "hashes": [
217 | "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852",
218 | "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61"
219 | ],
220 | "markers": "python_version >= '3.7'",
221 | "version": "==3.1.2"
222 | },
223 | "markupsafe": {
224 | "hashes": [
225 | "sha256:0212a68688482dc52b2d45013df70d169f542b7394fc744c02a57374a4207003",
226 | "sha256:089cf3dbf0cd6c100f02945abeb18484bd1ee57a079aefd52cffd17fba910b88",
227 | "sha256:10c1bfff05d95783da83491be968e8fe789263689c02724e0c691933c52994f5",
228 | "sha256:33b74d289bd2f5e527beadcaa3f401e0df0a89927c1559c8566c066fa4248ab7",
229 | "sha256:3799351e2336dc91ea70b034983ee71cf2f9533cdff7c14c90ea126bfd95d65a",
230 | "sha256:3ce11ee3f23f79dbd06fb3d63e2f6af7b12db1d46932fe7bd8afa259a5996603",
231 | "sha256:421be9fbf0ffe9ffd7a378aafebbf6f4602d564d34be190fc19a193232fd12b1",
232 | "sha256:43093fb83d8343aac0b1baa75516da6092f58f41200907ef92448ecab8825135",
233 | "sha256:46d00d6cfecdde84d40e572d63735ef81423ad31184100411e6e3388d405e247",
234 | "sha256:4a33dea2b688b3190ee12bd7cfa29d39c9ed176bda40bfa11099a3ce5d3a7ac6",
235 | "sha256:4b9fe39a2ccc108a4accc2676e77da025ce383c108593d65cc909add5c3bd601",
236 | "sha256:56442863ed2b06d19c37f94d999035e15ee982988920e12a5b4ba29b62ad1f77",
237 | "sha256:671cd1187ed5e62818414afe79ed29da836dde67166a9fac6d435873c44fdd02",
238 | "sha256:694deca8d702d5db21ec83983ce0bb4b26a578e71fbdbd4fdcd387daa90e4d5e",
239 | "sha256:6a074d34ee7a5ce3effbc526b7083ec9731bb3cbf921bbe1d3005d4d2bdb3a63",
240 | "sha256:6d0072fea50feec76a4c418096652f2c3238eaa014b2f94aeb1d56a66b41403f",
241 | "sha256:6fbf47b5d3728c6aea2abb0589b5d30459e369baa772e0f37a0320185e87c980",
242 | "sha256:7f91197cc9e48f989d12e4e6fbc46495c446636dfc81b9ccf50bb0ec74b91d4b",
243 | "sha256:86b1f75c4e7c2ac2ccdaec2b9022845dbb81880ca318bb7a0a01fbf7813e3812",
244 | "sha256:8dc1c72a69aa7e082593c4a203dcf94ddb74bb5c8a731e4e1eb68d031e8498ff",
245 | "sha256:8e3dcf21f367459434c18e71b2a9532d96547aef8a871872a5bd69a715c15f96",
246 | "sha256:8e576a51ad59e4bfaac456023a78f6b5e6e7651dcd383bcc3e18d06f9b55d6d1",
247 | "sha256:96e37a3dc86e80bf81758c152fe66dbf60ed5eca3d26305edf01892257049925",
248 | "sha256:97a68e6ada378df82bc9f16b800ab77cbf4b2fada0081794318520138c088e4a",
249 | "sha256:99a2a507ed3ac881b975a2976d59f38c19386d128e7a9a18b7df6fff1fd4c1d6",
250 | "sha256:a49907dd8420c5685cfa064a1335b6754b74541bbb3706c259c02ed65b644b3e",
251 | "sha256:b09bf97215625a311f669476f44b8b318b075847b49316d3e28c08e41a7a573f",
252 | "sha256:b7bd98b796e2b6553da7225aeb61f447f80a1ca64f41d83612e6139ca5213aa4",
253 | "sha256:b87db4360013327109564f0e591bd2a3b318547bcef31b468a92ee504d07ae4f",
254 | "sha256:bcb3ed405ed3222f9904899563d6fc492ff75cce56cba05e32eff40e6acbeaa3",
255 | "sha256:d4306c36ca495956b6d568d276ac11fdd9c30a36f1b6eb928070dc5360b22e1c",
256 | "sha256:d5ee4f386140395a2c818d149221149c54849dfcfcb9f1debfe07a8b8bd63f9a",
257 | "sha256:dda30ba7e87fbbb7eab1ec9f58678558fd9a6b8b853530e176eabd064da81417",
258 | "sha256:e04e26803c9c3851c931eac40c695602c6295b8d432cbe78609649ad9bd2da8a",
259 | "sha256:e1c0b87e09fa55a220f058d1d49d3fb8df88fbfab58558f1198e08c1e1de842a",
260 | "sha256:e72591e9ecd94d7feb70c1cbd7be7b3ebea3f548870aa91e2732960fa4d57a37",
261 | "sha256:e8c843bbcda3a2f1e3c2ab25913c80a3c5376cd00c6e8c4a86a89a28c8dc5452",
262 | "sha256:efc1913fd2ca4f334418481c7e595c00aad186563bbc1ec76067848c7ca0a933",
263 | "sha256:f121a1420d4e173a5d96e47e9a0c0dcff965afdf1626d28de1460815f7c4ee7a",
264 | "sha256:fc7b548b17d238737688817ab67deebb30e8073c95749d55538ed473130ec0c7"
265 | ],
266 | "markers": "python_version >= '3.7'",
267 | "version": "==2.1.1"
268 | },
269 | "numpy": {
270 | "hashes": [
271 | "sha256:0cfe07133fd00b27edee5e6385e333e9eeb010607e8a46e1cd673f05f8596595",
272 | "sha256:11a1f3816ea82eed4178102c56281782690ab5993251fdfd75039aad4d20385f",
273 | "sha256:2762331de395739c91f1abb88041f94a080cb1143aeec791b3b223976228af3f",
274 | "sha256:283d9de87c0133ef98f93dfc09fad3fb382f2a15580de75c02b5bb36a5a159a5",
275 | "sha256:3d22662b4b10112c545c91a0741f2436f8ca979ab3d69d03d19322aa970f9695",
276 | "sha256:41388e32e40b41dd56eb37fcaa7488b2b47b0adf77c66154d6b89622c110dfe9",
277 | "sha256:42c16cec1c8cf2728f1d539bd55aaa9d6bb48a7de2f41eb944697293ef65a559",
278 | "sha256:47ee7a839f5885bc0c63a74aabb91f6f40d7d7b639253768c4199b37aede7982",
279 | "sha256:5a311ee4d983c487a0ab546708edbdd759393a3dc9cd30305170149fedd23c88",
280 | "sha256:5dc65644f75a4c2970f21394ad8bea1a844104f0fe01f278631be1c7eae27226",
281 | "sha256:6ed0d073a9c54ac40c41a9c2d53fcc3d4d4ed607670b9e7b0de1ba13b4cbfe6f",
282 | "sha256:76ba7c40e80f9dc815c5e896330700fd6e20814e69da9c1267d65a4d051080f1",
283 | "sha256:818b9be7900e8dc23e013a92779135623476f44a0de58b40c32a15368c01d471",
284 | "sha256:a024181d7aef0004d76fb3bce2a4c9f2e67a609a9e2a6ff2571d30e9976aa383",
285 | "sha256:a955e4128ac36797aaffd49ab44ec74a71c11d6938df83b1285492d277db5397",
286 | "sha256:a97a954a8c2f046d3817c2bce16e3c7e9a9c2afffaf0400f5c16df5172a67c9c",
287 | "sha256:a97e82c39d9856fe7d4f9b86d8a1e66eff99cf3a8b7ba48202f659703d27c46f",
288 | "sha256:b55b953a1bdb465f4dc181758570d321db4ac23005f90ffd2b434cc6609a63dd",
289 | "sha256:bb02929b0d6bfab4c48a79bd805bd7419114606947ec8284476167415171f55b",
290 | "sha256:bece0a4a49e60e472a6d1f70ac6cdea00f9ab80ff01132f96bd970cdd8a9e5a9",
291 | "sha256:e41e8951749c4b5c9a2dc5fdbc1a4eec6ab2a140fdae9b460b0f557eed870f4d",
292 | "sha256:f71d57cc8645f14816ae249407d309be250ad8de93ef61d9709b45a0ddf4050c"
293 | ],
294 | "index": "pypi",
295 | "version": "==1.22.0"
296 | },
297 | "pandas": {
298 | "hashes": [
299 | "sha256:272c8cb14aa9793eada6b1ebe81994616e647b5892a370c7135efb2924b701df",
300 | "sha256:3334a5a9eeaca953b9db1b2b165dcdc5180b5011f3bec3a57a3580c9c22eae68",
301 | "sha256:37d63e78e87eb3791da7be4100a65da0383670c2b59e493d9e73098d7a879226",
302 | "sha256:3f5020613c1d8e304840c34aeb171377dc755521bf5e69804991030c2a48aec3",
303 | "sha256:45649503e167d45360aa7c52f18d1591a6d5c70d2f3a26bc90a3297a30ce9a66",
304 | "sha256:49fd2889d8116d7acef0709e4c82b8560a8b22b0f77471391d12c27596e90267",
305 | "sha256:4def2ef2fb7fcd62f2aa51bacb817ee9029e5c8efe42fe527ba21f6a3ddf1a9f",
306 | "sha256:53e2fb11f86f6253bb1df26e3aeab3bf2e000aaa32a953ec394571bec5dc6fd6",
307 | "sha256:629138b7cf81a2e55aa29ce7b04c1cece20485271d1f6c469c6a0c03857db6a4",
308 | "sha256:68408a39a54ebadb9014ee5a4fae27b2fe524317bc80adf56c9ac59e8f8ea431",
309 | "sha256:7326b37de08d42dd3fff5b7ef7691d0fd0bf2428f4ba5a2bdc3b3247e9a52e4c",
310 | "sha256:7557b39c8e86eb0543a17a002ac1ea0f38911c3c17095bc9350d0a65b32d801c",
311 | "sha256:86b16b1b920c4cb27fdd65a2c20258bcd9c794be491290660722bb0ea765054d",
312 | "sha256:a800df4e101b721e94d04c355e611863cc31887f24c0b019572e26518cbbcab6",
313 | "sha256:a9f1b54d7efc9df05320b14a48fb18686f781aa66cc7b47bb62fabfc67a0985c",
314 | "sha256:c399200631db9bd9335d013ec7fce4edb98651035c249d532945c78ad453f23a",
315 | "sha256:e574c2637c9d27f322e911650b36e858c885702c5996eda8a5a60e35e6648cf2",
316 | "sha256:e9bc59855598cb57f68fdabd4897d3ed2bc3a3b3bef7b868a0153c4cd03f3207",
317 | "sha256:ebbed7312547a924df0cbe133ff1250eeb94cdff3c09a794dc991c5621c8c735",
318 | "sha256:ed2f29b4da6f6ae7c68f4b3708d9d9e59fa89b2f9e87c2b64ce055cbd39f729e",
319 | "sha256:f7d84f321674c2f0f31887ee6d5755c54ca1ea5e144d6d54b3bbf566dd9ea0cc"
320 | ],
321 | "index": "pypi",
322 | "version": "==1.3.3"
323 | },
324 | "plotly": {
325 | "hashes": [
326 | "sha256:4d36d9859b7a153b273562deeed8c292587a472eb1fd57cd4158ec89d9defadb",
327 | "sha256:989b13825cc974390aa0169479485d9257d37848a47bc63957251f8e1a7046ba"
328 | ],
329 | "markers": "python_full_version >= '3.6.0'",
330 | "version": "==5.10.0"
331 | },
332 | "python-dateutil": {
333 | "hashes": [
334 | "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86",
335 | "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"
336 | ],
337 | "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
338 | "version": "==2.8.2"
339 | },
340 | "pytz": {
341 | "hashes": [
342 | "sha256:2c0784747071402c6e99f0bafdb7da0fa22645f06554c7ae06bf6358897e9c91",
343 | "sha256:48ce799d83b6f8aab2020e369b627446696619e79645419610b9facd909b3174"
344 | ],
345 | "version": "==2022.4"
346 | },
347 | "requests": {
348 | "hashes": [
349 | "sha256:6c1246513ecd5ecd4528a0906f910e8f0f9c6b8ec72030dc9fd154dc1a6efd24",
350 | "sha256:b8aa58f8cf793ffd8782d3d8cb19e66ef36f7aba4353eec859e74678b01b07a7"
351 | ],
352 | "index": "pypi",
353 | "version": "==2.26.0"
354 | },
355 | "setuptools": {
356 | "hashes": [
357 | "sha256:512e5536220e38146176efb833d4a62aa726b7bbff82cfbc8ba9eaa3996e0b17",
358 | "sha256:f62ea9da9ed6289bfe868cd6845968a2c854d1427f8548d52cae02a42b4f0356"
359 | ],
360 | "markers": "python_version >= '3.7'",
361 | "version": "==65.5.0"
362 | },
363 | "six": {
364 | "hashes": [
365 | "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926",
366 | "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"
367 | ],
368 | "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
369 | "version": "==1.16.0"
370 | },
371 | "soupsieve": {
372 | "hashes": [
373 | "sha256:3b2503d3c7084a42b1ebd08116e5f81aadfaea95863628c80a3b774a11b7c759",
374 | "sha256:fc53893b3da2c33de295667a0e19f078c14bf86544af307354de5fcf12a3f30d"
375 | ],
376 | "markers": "python_full_version >= '3.6.0'",
377 | "version": "==2.3.2.post1"
378 | },
379 | "tenacity": {
380 | "hashes": [
381 | "sha256:35525cd47f82830069f0d6b73f7eb83bc5b73ee2fff0437952cedf98b27653ac",
382 | "sha256:e48c437fdf9340f5666b92cd7990e96bc5fc955e1298baf4a907e3972067a445"
383 | ],
384 | "markers": "python_full_version >= '3.6.0'",
385 | "version": "==8.1.0"
386 | },
387 | "urllib3": {
388 | "hashes": [
389 | "sha256:3fa96cf423e6987997fc326ae8df396db2a8b7c667747d47ddd8ecba91f4a74e",
390 | "sha256:b930dd878d5a8afb066a637fbb35144fe7901e3b209d1cd4f524bd0e9deee997"
391 | ],
392 | "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5' and python_version < '4'",
393 | "version": "==1.26.12"
394 | },
395 | "werkzeug": {
396 | "hashes": [
397 | "sha256:7ea2d48322cc7c0f8b3a215ed73eabd7b5d75d0b50e31ab006286ccff9e00b8f",
398 | "sha256:f979ab81f58d7318e064e99c4506445d60135ac5cd2e177a2de0089bfd4c9bd5"
399 | ],
400 | "markers": "python_version >= '3.7'",
401 | "version": "==2.2.2"
402 | },
403 | "zipp": {
404 | "hashes": [
405 | "sha256:3a7af91c3db40ec72dd9d154ae18e008c69efe8ca88dde4f9a731bb82fe2f9eb",
406 | "sha256:972cfa31bc2fedd3fa838a51e9bc7e64b7fb725a8c00e7431554311f180e9980"
407 | ],
408 | "markers": "python_version >= '3.7'",
409 | "version": "==3.9.0"
410 | }
411 | },
412 | "develop": {}
413 | }
414 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------