Skip to content

Instantly share code, notes, and snippets.

@kirankumaramruthaluri
Created October 14, 2013 08:44
Show Gist options
  • Save kirankumaramruthaluri/6972808 to your computer and use it in GitHub Desktop.
Save kirankumaramruthaluri/6972808 to your computer and use it in GitHub Desktop.
D3 Circle - Inner Graph
<!DOCTYPE html>
<html>
<head>
<title>D3 Circle - Inner Graph</title>
</head>
<body>
<div id="wrapper">
</div>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script>
var svg = d3.select('#wrapper')
.append('svg')
.attr({'width':900,'height':600});
var arc = d3.svg.arc()
.innerRadius(function(d,i){ return i*15; })
.outerRadius(function(d,i){ return i*30; })
.startAngle(0)
.endAngle(function(d){ return scale(d); });
var data = [2.5,2,3,4,5,6];
var scale = d3.scale.linear()
.domain([1,6])
.range([0,Math.PI*2]);
var colorscale = d3.scale.category20();
var group = svg.append('g')
.attr('transform','translate('+ 200 +','+ 200 +')');
var line = group.selectAll('path')
.data(data)
.enter()
.append('path')
.attr('d',arc)
.attr('fill',function(d){ return colorscale(d); })
.attr('stroke','#000')
.attr('stroke-width',1);
var line = group.selectAll('text')
.data(data)
.enter()
.append('text')
.attr({'x':function(d,i){ return i*20; },'y':function(d,i){ return i*20; }})
.text(function(d){ return d; });
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment