Skip to content

Instantly share code, notes, and snippets.

@roundrobin
Created January 20, 2013 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roundrobin/4576388 to your computer and use it in GitHub Desktop.
Save roundrobin/4576388 to your computer and use it in GitHub Desktop.
Circle play
{"description":"Circle play","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"tab":"edit","display_percent":0.5352306547619047,"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,"fullscreen":false,"thumbnail":"http://i.imgur.com/Q7VAEfo.png"}
var svg = d3.select("svg");
var g = svg.append("svg:g")
.attr("transform","translate("+[349,272]+")")
.attr("class","group");
var radius = 224;
var radius2 = -193;
var text = ["China",
"India",
"United States",
"Indonesia",
"Brazil",
"Pakistan",
"Nigeria",
"Bangladesh",
"Russia",
"Japan",
"Mexico",
"Philippines",
"Vietnam",
"Ethiopia",
"Egypt",
"Germany",
"Iran",
"Turkey",
"Democratic Republic of the Congo",
"Thailand",
"France",
"United Kingdom",
"Italy",
"South Africa",
"South Korea",
"Myanmar",
"Colombia",
"Spain",
"Ukraine",
"Tanzania",
"Argentina",
"Kenya",
"Poland",
"Algeria",
"Canada",
"Uganda",
"Iraq",
"Morocco",
"Sudan",
"Peru",
"Malaysia",
"Uzbekistan",
"Venezuela",
"Saudi Arabia",
"Nepal",
"Afghanistan",
"Ghana",
"North Korea",
"Yemen",
"Mozambique",
"Taiwan",
"Australia",
"Syria",
"Ivory Coast",
"Madagascar",
"Angola",
"Sri Lanka",
"Cameroon",
"Romania",
"Kazakhstan",
"Netherlands",
"Chile",
"Niger",
"Malawi",
"Burkina Faso",
"Ecuador",
"Guatemala",
"Mali",
"Cambodia",
"Zambia",
"Zimbabwe",
"Senegal",
"Chad",
"Cuba",
"Belgium",
"Guinea",
"Greece",
"Tunisia",
"Portugal",
"Rwanda",
"Czech Republic",
"Bolivia",
"Haiti",
"Hungary",
"Somalia",
"Sweden",
"Belarus",
"Dominican Republic",
"Benin",
"Azerbaijan",
"Burundi",
"Austria",
"Honduras",
"United Arab Emirates",
"South Sudan",
"Switzerland",
"Israel",
"Tajikistan",
"Bulgaria",
"Serbia",
"Hong Kong (China)",
"Papua New Guinea",
"Libya",
"Laos",
"Paraguay",
"Jordan",
"Togo",
"El Salvador",
"Sierra Leone",
"Nicaragua",
"Denmark",
"Eritrea",
"Kyrgyzstan",
"Slovakia",
"Finland",
"Singapore",
"Turkmenistan",
"Norway",
"Ireland",
"Central African Republic",
"Georgia",
"New Zealand",
"Costa Rica",
"Palestinian territories",
"Lebanon",
"Croatia",
"Liberia",
"Republic of the Congo",
"Bosnia and Herzegovina",
"Puerto Rico",
"Kuwait",
"Moldova",
"Panama",
"Mauritania",
"Uruguay",
"Armenia",
"Lithuania",
"Albania",
"Oman",
"Mongolia",
"Jamaica",
"Lesotho",
"Namibia",
"Latvia",
"Macedonia",
"Slovenia",
"Botswana",
"Gambia",
"Qatar",
"Gabon",
"Guinea-Bissau",
"Trinidad and Tobago",
"Estonia",
"Mauritius",
"Bahrain",
"Swaziland",
"Timor-Leste",
"Fiji",
"Cyprus",
"Réunion (France)",
"Djibouti",
"Guyana",
"Equatorial Guinea",
"Comoros",
"Bhutan",
"Montenegro",
"Macau (China)",
"Western Sahara",
"Solomon Islands",
"Suriname",
"Luxembourg",
"Cape Verde",
"Malta",
"Guadeloupe (France)",
"Martinique (France)",
"Brunei",
"Bahamas",
"Iceland",
"Maldives",
"Belize",
"Barbados",
"French Polynesia",
"Vanuatu",
"New Caledonia (France)",
"French Guiana (France)",
"Mayotte (France)",
"Samoa",
"São Tomé and Príncipe",
"Saint Lucia",
"Guam (USA)",
"Curaçao (Netherlands)",
"United States Virgin Islands",
"Kiribati",
"Tonga",
"Grenada",
"Federated States of Micronesia",
"Aruba (Netherlands)",
"Saint Vincent and the Grenadines",
"Jersey (UK)",
"Seychelles",
"Antigua and Barbuda",
"Isle of Man (UK)",
"Andorra",
"Dominica",
"Bermuda (UK)",
"Guernsey (UK)",
"Greenland (Denmark)",
"Marshall Islands",
"American Samoa (USA)",
"Cayman Islands (UK)",
"Northern Mariana Islands (USA)",
"Saint Kitts and Nevis",
"Faroe Islands (Denmark)",
"Sint Maarten (Netherlands)",
"Saint Martin (France)",
"Liechtenstein",
"Monaco",
"San Marino",
"Turks and Caicos Islands (UK)",
"Gibraltar (UK)",
"British Virgin Islands (UK)",
"Åland Islands (Finland)",
"Caribbean Netherlands (Netherlands)",
"Palau",
"Cook Islands (NZ)",
"Anguilla (UK)",
"Wallis and Futuna (France)",
"Tuvalu",
"Nauru",
"Saint Barthélemy (France)",
"Saint Pierre and Miquelon (France)",
"Montserrat (UK)",
"Saint Helena, Ascension and Tristan da Cunha (UK)",
"Falkland Islands (UK)",
"Svalbard and Jan Mayen (Norway)",
"Norfolk Island (Australia)",
"Christmas Island (Australia)",
"Niue (NZ)",
"Tokelau (NZ)",
"Vatican City",
"Cocos (Keeling) Islands (Australia)",
"Pitcairn Islands (UK)" ];
var iterations = text.length;
var n = iterations;
for(var i = 0; i < n; i++) {
var x = radius * Math.cos(2 * Math.PI * i / n);
var y = radius * Math.sin(2 * Math.PI * i / n);
var x1 = radius * Math.sin(2 * Math.PI * i / n);
var y1 = radius * Math.cos(2 * Math.PI * i / n);
var x2 = radius2 * Math.cos(2 * Math.PI * i / n);
var y2 = radius2 * Math.sin(2 * Math.PI * i / n);
var angle = (i/iterations * 360 ) * 1;
g.append('svg:text')
.text(text[i])
.attr("fill", "#000000")
.attr("x", x)
.attr("y", y)
.attr("font-size", 6)
.attr("font-family", "Arial")
.attr("text-anchor", "start")
.attr("transform","translate(0,0)rotate("+[(angle) ]+","+(x)+","+(y)+")")
g.append('svg:text')
.text(text[i])
.attr("fill", "#000000")
.attr("x", x2)
.attr("y", y2)
.attr("font-size", 6)
.attr("font-family", "Arial")
.attr("text-anchor", "start")
.attr("transform","translate(0,0)rotate("+[(angle) ]+","+(x2)+","+(y2)+")")
g.append("svg:circle")
.attr("r",1.88)
.attr("cx",x*0.99)
.attr("cy",y*0.99)
.attr("fill","#001FFF");
g.append("svg:circle")
.attr("r",1.88)
.attr("cx",x1*0.91)
.attr("cy",y1*0.91)
.attr("fill","#001FFF");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment