[ Launch: test ] cd94a19e1e3373f02665 by jeffcatania
[ Launch: test ] 4653053 by enjalot
[ Launch: test ] 4652017 by enjalot
[ Launch: test ] 4582399 by enjalot
-
-
Save jeffcatania/cd94a19e1e3373f02665 to your computer and use it in GitHub Desktop.
test
This file contains 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":"test","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},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"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,"tab":"edit","display_percent":0.7,"thumbnail":"http://i.imgur.com/Z4ghHZY.png","fullscreen":false,"ajax-caching":true} |
This file contains 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 radius = 74, | |
padding = 10; | |
var color = d3.scale.ordinal() | |
.range(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]); | |
var arc = d3.svg.arc() | |
.outerRadius(radius) | |
.innerRadius(radius - 30); | |
var pie = d3.layout.pie() | |
.sort(null) | |
.value(function(d) { return d.population; }); | |
color.domain(d3.keys(data[0]).filter(function(key) { return key !== "State"; })); | |
data.forEach(function(d) { | |
d.ages = color.domain().map(function(name) { | |
return {name: name, population: +d[name]}; | |
}); | |
}); | |
var render = function(data) { | |
var legend = d3.select("svg") | |
.attr("class", "legend") | |
.attr("width", radius * 2) | |
.attr("height", radius * 2) | |
.selectAll("g") | |
.data(color.domain().slice().reverse()) | |
.enter().append("g") | |
.attr("transform", function(d, i) { return "translate(0," + i * 20 + ")"; }); | |
legend.append("rect") | |
.attr("width", 18) | |
.attr("height", 18) | |
.style("fill", color); | |
legend.append("text") | |
.attr("x", 24) | |
.attr("y", 9) | |
.attr("dy", ".35em") | |
.text(function(d) { return d; }); | |
var svg = d3.select("body").selectAll(".pie") | |
.data(data) | |
.enter().append("svg") | |
.attr("class", "pie") | |
.attr("width", radius * 2) | |
.attr("height", radius * 2) | |
.append("g") | |
.attr("transform", "translate(" + radius + "," + radius + ")"); | |
svg.selectAll(".arc") | |
.data(function(d) { return pie(d.ages); }) | |
.enter().append("path") | |
.attr("class", "arc") | |
.attr("d", arc) | |
.style("fill", function(d) { return color(d.data.name); }); | |
svg.append("text") | |
.attr("dy", ".35em") | |
.style("text-anchor", "middle") | |
.text(function(d) { return d.State; }); | |
}; | |
render(tributary.data); | |
This file contains 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
body { | |
font: 10px sans-serif; | |
} | |
svg { | |
padding: 10px 0 0 10px; | |
} | |
.arc { | |
stroke: #fff; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment