Skip to content

Instantly share code, notes, and snippets.

@caged
Created April 22, 2011 23:59
Show Gist options
  • Save caged/937986 to your computer and use it in GitHub Desktop.
Save caged/937986 to your computer and use it in GitHub Desktop.
w = 800
h = 800
r = Math.min(w, h) / 2
donut = d3.layout.pie()
arc = d3.svg.arc()
.innerRadius(r * 0.95)
.outerRadius(r)
vis = d3.select('#chart')
.append('svg:svg')
.data([[20,20,20,20,20]])
.attr('width', w)
.attr('height', h)
arcs = vis.selectAll('g.arc')
.data(donut)
.enter().append('svg:g')
.attr('class', 'arc')
.attr('transform', "translate(#{r},#{r})")
arcs.append('svg:path')
.attr('fill', (d, i) -> 'rgb(255,0,0)')
.attr('d', (d) -> arc(d))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment