[ Launch: Donuts ] a32fb2cdb223e659d6ef by cacharbe
[ Launch: Tributary inlet ] ad5267fb88cbd484cdd1 by cacharbe
-
-
Save cacharbe/a32fb2cdb223e659d6ef to your computer and use it in GitHub Desktop.
Donuts for StackOverflow
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":"Donuts for StackOverflow","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},"QualityData.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"data,json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true,"thumbnail":"http://i.imgur.com/AIXnih7.png"} |
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 data = { | |
"project":"Desktop Program Team", | |
"stateCounts": | |
[ | |
{"stateName":"Committed", "count":10}, | |
{"stateName":"To Do", "count":27}, | |
{"stateName":"In Progress", "count":5}, | |
{"stateName":"Removed", "count":1}, | |
{"stateName":"Done", "count":7}, | |
{"stateName":"New", "count":2}, | |
{"stateName":"Design", "count":1} | |
] | |
} ; | |
var color = d3.scale.ordinal() | |
.range(["#AA3939", "#AA6C39", "#226696", "#2D882D", "#550000", "#552600", "#003333", "#004400"]); | |
var arc = d3.svg.arc() | |
.outerRadius(radius) | |
.innerRadius(radius - 30); | |
var pie = d3.layout.pie() | |
.sort(null) | |
.value(function (d) { return d.count; }); | |
var legend = d3.select("svg").append("svg") | |
.attr("class", "legend") | |
.attr("width", radius * 2) | |
.attr("height", radius * 2) | |
.selectAll("g") | |
.data(data.stateCounts) | |
.enter().append("g") | |
.attr("transform", function (d, i) { return "translate(0," + i * 20 + ")"; }); | |
legend.append("rect") | |
.attr("width", 18) | |
.attr("height", 18) | |
.style("fill", function (d) {return color(d.stateName);}); | |
legend.append("text") | |
.attr("x", 24) | |
.attr("y", 9) | |
.attr("dy", ".35em") | |
.text(function (d) { return d.stateName; }); | |
var pieSvg = d3.select("svg").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 + ")"); | |
pieSvg.selectAll(".arc") | |
.data(function (d) {return pie(d.stateCounts);}) | |
.enter().append("path") | |
.attr("class", "arc") | |
.attr("d", arc) | |
.style("fill", function (d) {return color(d.stateName); }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment