[ Launch Inlet ]
Gist #4241886 [ Launch Inlet ]
Gist #4220989 [ Launch Inlet ]
Gist #4220610 [ Launch Inlet ]
Gist #4219920 [ Launch Inlet ]
Gist #4217875 [ Launch Inlet ]
Gist #4216593 [ Launch Inlet ]
Gist #4215452 [ Launch Inlet ]
Gist #4215265 [ Launch Inlet ]
Gist #3200444
-
-
Save zeffii/4246045 to your computer and use it in GitHub Desktop.
olympic names_into_function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {"description":"olympic names_into_function","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"olympics.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"tab":"edit","display_percent":0.48792006318759124,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"hidepanel":false} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var bg = d3.select("body"); | |
| bg.style("background-color", "#1F1F1F") | |
| var svg = d3.select("svg"); | |
| var data = tributary.olympics; | |
| //console.log(data); | |
| var relativise = []; | |
| for (idx in data){ | |
| var pop = data[idx]['2010_population']; | |
| var gdp = data[idx]['2011_GDP']; | |
| relativise.push(gdp / pop) | |
| } | |
| // used to equalize the dataset, make all countries 'equal' | |
| // compared to the most wealthy. | |
| var highest = d3.max(relativise); | |
| var normalizer = []; | |
| for (idx in relativise){ | |
| normalizer.push(highest / relativise[idx]); | |
| } | |
| var offset_x = 0; | |
| var bar_width = 23; | |
| var half_bar_width = bar_width / 2.0; | |
| var separation = 5.24; | |
| // groups setup | |
| var gr_males_females = svg.append("group") | |
| .data(data) | |
| .attr("class", "males_females") | |
| .attr("y", 316) | |
| .attr("transform", "scale("+[1, -1]+") translate("+[24, -662]+")") | |
| var males = gr_males_females.append("group") | |
| .attr("class", "males") | |
| var females = gr_males_females.append("group") | |
| .attr("class", "females") | |
| var gr_medals = svg.append("group") | |
| .data(data) | |
| .attr("class", "medals") | |
| .attr("transform", "translate("+[24,30]+")") | |
| var gr_gold = gr_medals.append("group") | |
| .attr("class", "gold") | |
| var gr_silver = gr_medals.append("group") | |
| .attr("class", "silver") | |
| var gr_gold = gr_medals.append("group") | |
| .attr("class", "gold") | |
| var gr_country_names = svg.append("group") | |
| .data(data) | |
| .attr("class", "country_names") | |
| .attr("transform", "translate(" + [24,30] + ")") | |
| var gr_ellipses = gr_country_names.append("group") | |
| .attr("class", "text_bg") | |
| var gr_text = gr_country_names.append("group") | |
| .attr("class", "country_name") | |
| // adding bars to groups | |
| gr_males_females.enter().selectAll("rect") | |
| .append("rect") | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [{"ISO_country_code": "USA","Country_name": "US","2011_GDP": 15094000000000.00,"2010_population": 309349000,"Female_count": 271,"Male_count": 260,"Gold_medals": 46,"Silver_medals": 29,"Bronze_medals": 29}, | |
| {"ISO_country_code": "CHN","Country_name": "China","2011_GDP": 7298100000000.00,"2010_population": 1338300000,"Female_count": 208,"Male_count": 163,"Gold_medals": 38,"Silver_medals": 27,"Bronze_medals": 23}, | |
| {"ISO_country_code": "JPN","Country_name": "Japan","2011_GDP": 5867150000000.00,"2010_population": 127451000,"Female_count": 162,"Male_count": 141,"Gold_medals": 7,"Silver_medals": 14,"Bronze_medals": 17}, | |
| {"ISO_country_code": "DEU","Country_name": "Germany","2011_GDP": 3570560000000.00,"2010_population": 81777000,"Female_count": 176,"Male_count": 219,"Gold_medals": 11,"Silver_medals": 19,"Bronze_medals": 14}, | |
| {"ISO_country_code": "FRA","Country_name": "France","2011_GDP": 2773030000000.00,"2010_population": 64895000,"Female_count": 148,"Male_count": 187,"Gold_medals": 11,"Silver_medals": 11,"Bronze_medals": 12}, | |
| {"ISO_country_code": "BRA","Country_name": "Brazil","2011_GDP": 2476650000000.00,"2010_population": 194946000,"Female_count": 128,"Male_count": 138,"Gold_medals": 3,"Silver_medals": 5,"Bronze_medals": 9}, | |
| {"ISO_country_code": "GBR","Country_name": "UK","2011_GDP": 2431590000000.00,"2010_population": 62232000,"Female_count": 269,"Male_count": 287,"Gold_medals": 29,"Silver_medals": 17,"Bronze_medals": 19}, | |
| {"ISO_country_code": "ITA","Country_name": "Italy","2011_GDP": 2194750000000.00,"2010_population": 60483000,"Female_count": 122,"Male_count": 159,"Gold_medals": 8,"Silver_medals": 9,"Bronze_medals": 11}, | |
| {"ISO_country_code": "RUS","Country_name": "Russia","2011_GDP": 1857770000000.00,"2010_population": 141750000,"Female_count": 227,"Male_count": 208,"Gold_medals": 24,"Silver_medals": 26,"Bronze_medals": 32}, | |
| {"ISO_country_code": "IND","Country_name": "India","2011_GDP": 1847980000000.00,"2010_population": 1224615000,"Female_count": 23,"Male_count": 60,"Gold_medals": 0,"Silver_medals": 2,"Bronze_medals": 4}, | |
| {"ISO_country_code": "JAM","Country_name": "Jamaica","2011_GDP": 15069767442.00,"2010_population": 2702000,"Female_count": 25,"Male_count": 25,"Gold_medals": 4,"Silver_medals": 4,"Bronze_medals": 4}, | |
| {"ISO_country_code": "GEO","Country_name": "Georgia","2011_GDP": 14366566609.00,"2010_population": 4452000,"Female_count": 6,"Male_count": 29,"Gold_medals": 1,"Silver_medals": 3,"Bronze_medals": 3}, | |
| {"ISO_country_code": "PRK","Country_name": "North Korea","2011_GDP": 12280000000.00,"2010_population": 24589122,"Female_count": 40,"Male_count": 15,"Gold_medals": 4,"Silver_medals": 0,"Bronze_medals": 2}, | |
| {"ISO_country_code": "ARM","Country_name": "Armenia","2011_GDP": 10247788877.00,"2010_population": 3092000,"Female_count": 4,"Male_count": 21,"Gold_medals": 0,"Silver_medals": 1,"Bronze_medals": 2}, | |
| {"ISO_country_code": "MNG","Country_name": "Mongolia","2011_GDP": 8557529910.00,"2010_population": 2756000,"Female_count": 13,"Male_count": 16,"Gold_medals": 0,"Silver_medals": 2,"Bronze_medals": 3}, | |
| {"ISO_country_code": "BHS","Country_name": "Bahamas","2011_GDP": 7787514000.00,"2010_population": 343000,"Female_count": 11,"Male_count": 15,"Gold_medals": 1,"Silver_medals": 0,"Bronze_medals": 0}, | |
| {"ISO_country_code": "MDA","Country_name": "Moldova","2011_GDP": 7000318677.00,"2010_population": 3562000,"Female_count": 10,"Male_count": 12,"Gold_medals": 0,"Silver_medals": 0,"Bronze_medals": 2}, | |
| {"ISO_country_code": "TJK","Country_name": "Tajikistan","2011_GDP": 6522200291.00,"2010_population": 6879000,"Female_count": 3,"Male_count": 13,"Gold_medals": 0,"Silver_medals": 0,"Bronze_medals": 1}, | |
| {"ISO_country_code": "MNE","Country_name": "Montenegro","2011_GDP": 4550463278.00,"2010_population": 632000,"Female_count": 16,"Male_count": 18,"Gold_medals": 0,"Silver_medals": 1,"Bronze_medals": 0}, | |
| {"ISO_country_code": "GRD","Country_name": "Grenada","2011_GDP": 816054092.20,"2010_population": 104000,"Female_count": 4,"Male_count": 6,"Gold_medals": 1,"Silver_medals": 0,"Bronze_medals": 0}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment