Skip to content

Instantly share code, notes, and snippets.

@vicapow
Created October 19, 2013 21:50
Show Gist options
  • Save vicapow/7061987 to your computer and use it in GitHub Desktop.
Save vicapow/7061987 to your computer and use it in GitHub Desktop.
the simplest pie chart example
<!DOCTYPE html>
<html>
<body>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script>
var vis = d3.select('body').append('svg').append('g')
.attr('transform', 'translate(200,200)')
, color = d3.scale.category10()
, arc = d3.svg.arc().outerRadius(100).innerRadius(0)
, pie = d3.layout.pie()
, arcs = vis.selectAll('path').data(pie([4,5,6]))
.enter().append('path').attr({
d: arc, fill: function(d, i){ return color(i) }, stroke: 'white' })
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment