Skip to content

Instantly share code, notes, and snippets.

@gelicia gelicia/_.md

Created Jun 11, 2013
Embed
What would you like to do?
pie layout play
{"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}
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
You can’t perform that action at this time.