[ Launch: Arc Pie ] 5754227 by gelicia
[ Launch: Arc Pie ] 5414630 by joelmatiassilva
-
-
Save gelicia/5754227 to your computer and use it in GitHub Desktop.
pie layout play
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":"pie layout 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}},"fullscreen":false,"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 w = 300, //width | |
h = 270, //height | |
r = 100, //radius | |
ir = 83, | |
pi = Math.PI, | |
color = d3.scale.category20c(); | |
partitions=3; | |
data = d3.range(partitions); | |
//info = d3.range(partitions) | |
var vis = d3.select("svg") | |
.data([data]) | |
.attr("width", w) | |
.attr("height", h) | |
.append("svg:g") | |
.attr("transform", "translate(" + r + "," + r + ")") | |
var arc = d3.svg.arc() | |
.outerRadius(r) | |
.innerRadius(ir); | |
var pie = d3.layout.pie() | |
.value(function(d) { return 1; }) | |
var arcs = vis.selectAll("g.slice") | |
.data(pie) | |
.enter() | |
.append("svg:g") | |
.attr("class", "slice"); | |
arcs.append("svg:path") | |
.attr("fill", function(d, i) { return color(i); } ) | |
.attr("d", arc); | |
data = d3.range(12), | |
angle = d3.scale.ordinal().domain(data).rangeBands([0, 5 * Math.PI]); | |
var g = vis.append("svg:g") | |
.attr("transform", "translate(" + 70 + "," + 27 + ")"); | |
g.selectAll("path") | |
.data(data) | |
.enter().append("svg:path") | |
.attr("d", d3.svg.arc() | |
.innerRadius(h / 2 - 20) | |
.outerRadius(h / 2 - 10) | |
.startAngle(function(d) { return angle(d); }) | |
.endAngle(function(d) { return angle(d) + angle.rangeBand() / 2; })); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment