[ Launch Inlet ]
Gist #4217875 [ Launch Inlet ]
Gist #4216593 [ Launch Inlet ]
Gist #4215452 [ Launch Inlet ]
Gist #4215265 [ Launch Inlet ]
Gist #3200444
- 
      
 - 
        
Save zeffii/4219920 to your computer and use it in GitHub Desktop.  
    olympic names_state
  
        
  
    
      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_state","endpoint":"","display":"svg","public":true,"require":[],"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} | 
  
    
      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 svg = d3.select("svg"); | |
| var data = tributary.olympics; | |
| // console.log(data); | |
| // realativise = (heighest/lookup) | |
| var rects = svg.selectAll("rect") | |
| .data(data) | |
| var offset_x = 20; | |
| var bar_width = 20; | |
| var half_bar_width = bar_width / 2.0; | |
| var separation = 3.92; | |
| // log (gdp / population) | |
| rects.enter().append("rect") | |
| .attr("width", bar_width) | |
| .attr("height", function(d,i){ | |
| console.log(d); | |
| var pop = d['2010_population']; | |
| var gdp = d['2011_GDP']; | |
| return Math.log(gdp/pop)*31; | |
| }) | |
| .attr("x", function(d,i){ | |
| return offset_x + (bar_width + separation) * i; | |
| }) | |
| .attr("y", 316) | |
| .attr("transform", "scale("+[1, -1]+") translate("+[24, -662]+")") | |
| .style("fill", "#726E8D") | |
| .style("fill-opacity", 0.3344) | |
| .style("stroke", "#858585") | |
| .style("stroke-width", 1); | |
| /* | |
| Country_name: "India" | |
| Gold_medals: 0 | |
| ISO_country_code: "IND" | |
| Silver_medals: 2 | |
| */ | |
| // Female_count | |
| var person_lambda = 47 | |
| rects.enter().append("rect") | |
| .attr("width", half_bar_width) | |
| .attr("height", function(d,i){ | |
| return Math.log(d['Female_count'])*person_lambda; | |
| }) | |
| .attr("x", function(d,i){ | |
| return offset_x + (bar_width + separation) * i; | |
| }) | |
| .attr("y", 316) | |
| .attr("transform", function(d,i){ | |
| return "scale(" + [1, -1] + ") translate(" + [24, -662] + ")"}) | |
| .style("fill", "#FA0DD4") | |
| .style("fill-opacity", 0.29568) | |
| .style("stroke", "#858585") | |
| .style("stroke-width", 1); | |
| // Male_count | |
| rects.enter().append("rect") | |
| .attr("width", half_bar_width) | |
| .attr("height", function(d,i){ | |
| return Math.log(d['Male_count'])*person_lambda; | |
| }) | |
| .attr("x", function(d,i){ | |
| return offset_x + half_bar_width + (bar_width + separation) * i; | |
| }) | |
| .attr("y", 316) | |
| .attr("transform", "scale("+[1, -1]+") translate("+[24, -662]+")") | |
| .style("fill", "#0027F7") | |
| .style("fill-opacity", 0.7216) | |
| .style("stroke", "#858585") | |
| .style("stroke-width", 1); | |
| // gold, silver, bronze | |
| rects.enter().append("rect") | |
| .attr("width", bar_width) | |
| .attr("height", function(d,i){ | |
| return d['Gold_medals']*2; | |
| }) | |
| .attr("x", function(d,i){ | |
| return offset_x + (bar_width + separation) * i; | |
| }) | |
| .attr("y", 316) | |
| .attr("transform", "translate("+[24,30]+")") | |
| .style("fill", "#F3CC00") | |
| .style("fill-opacity", 0.6072) | |
| .style("stroke", "#858585") | |
| .style("stroke-width", 1); | |
| rects.enter().append("rect") | |
| .attr("width", bar_width) | |
| .attr("height", function(d,i){ | |
| return d['Silver_medals']*2 | |
| }) | |
| .attr("x", function(d,i){ | |
| return offset_x + (bar_width+separation) *i | |
| }) | |
| .attr("y", function(d,i){ | |
| var num_medals = d['Gold_medals'] * 2 | |
| return 316 + num_medals | |
| }) | |
| .attr("transform", "translate(" + [24,30] + ")") | |
| .style("fill", "#CAD6DA") | |
| .style("fill-opacity", 0.4928) | |
| .style("stroke", "#858585") | |
| .style("stroke-width", 1); | |
| rects.enter().append("rect") | |
| .attr("width", bar_width) | |
| .attr("height", function(d,i){ | |
| return d['Bronze_medals']*2; | |
| }) | |
| .attr("x", function(d,i){ | |
| return offset_x + (bar_width+separation) *i; | |
| }) | |
| .attr("y", function(d,i){ | |
| var num_medals = (d['Gold_medals']+d['Silver_medals'])*2 | |
| return 316 + num_medals | |
| }) | |
| .attr("transform", "translate("+[24,30]+")") | |
| .style("fill", "#C28144") | |
| .style("fill-opacity", 0.5984) | |
| .style("stroke", "#858585") | |
| .style("stroke-width", 1); | |
| var ellipses = svg.selectAll("ellipse") | |
| .data(data) | |
| ellipses.enter().append("ellipse") | |
| .attr("transform", "translate(" + [24,30] + ")") | |
| .attr("cx", function(d,i){ | |
| var constant_offset = offset_x + half_bar_width; | |
| return constant_offset + (bar_width + separation) * i | |
| }) | |
| .attr("cy", 299) | |
| .attr("rx", half_bar_width) | |
| .attr("ry", half_bar_width) | |
| .style("fill", "#504B4B"); | |
| //.style("stroke", "#FF0047") | |
| //.style("stroke-width", 1) | |
| var text_boxes = svg.selectAll("text") | |
| .data(data) | |
| var col = "#35C584" | |
| text_boxes.enter().append("text") | |
| .text(function(d,i){ | |
| return d['ISO_country_code'] | |
| }) | |
| .attr("x", function(d,i){ | |
| var constant_offset = offset_x + bar_width + 6; | |
| return constant_offset + (bar_width + separation) * i | |
| }) | |
| .attr("y", 332) | |
| .style("font-family", "sans") | |
| .style("font-size", 8) | |
| .style("fill", col) | |
  
    
      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