vararc=d3.arc()//create an arc generating function
.innerRadius(100)//to make this a donut graph, adjust this value
.outerRadius(radius);
.outerRadius(radius);//set the outer radius of the pie
varpie=d3.pie()
.value(function(d){returnd.count;})//use the 'count' property each value in the original array to determine how big the piece of pie should be
varpie=d3.pie()//create a pie generator which will adjust the data so that it can be used with arc
.value(function(d){returnd.count;})//use the 'count' property of each value in the original dataset array to determine how big the piece of pie should be
.sort(null);//don't sort the values
varpath=d3.select('g').selectAll('path')
.data(pie(dataset),function(datum){//attach datum.data.id to each element
varpath=d3.select('g').selectAll('path')//select all path elements in the <g> whether or not they exist
.data(pie(dataset),function(datum){//attach datum.data.id, which was created by pie(dataset), to each element
returndatum.data.id
})
.enter()
.append('path')
.attr('d',arc)//add this
.attr('fill',function(d){
.enter()//find all unmatched data elements
.append('path')//append a path for each unmatched data element
.attr('d',arc)//use arc to generate the d attribute of each path, now the pie(dataset) as adjusted the data to work with it
.attr('fill',function(d){//set the color based on converting the d.data.label string to a color