The following example shows a donut chart in D3.js, is it possible to add more than one ring to the chart?
var dataset = {
apples: [53245, 28479, 19697, 24
Using the fiddle you posted, there is an "arc" defined in the fiddle here:
var arc = d3.svg.arc()
.innerRadius(radius - 100)
.outerRadius(radius - 50);
That arc is what's used to build the ring graph here:
var path = svg.selectAll("path")
.data(pie(dataset.apples))
.enter().append("path")
.attr("fill", function(d, i) { return color(i); })
.attr("d", arc);
So if you just made a different arc for each of your data sets with a variety of radii, you would have additional rings in your chart.
Yes, you can do this quite easily. The key is to use nested selections. That is, you pass in your top level list of lists and create a container element for each list. Then you do the nested selection and draw the actual elements. In this particular case, you also need to adjust the radii of the arcs so that they don't overlap.
var gs = svg.selectAll("g").data(d3.values(dataset)).enter().append("g");
var path = gs.selectAll("path")
.data(function(d) { return pie(d); })
.enter().append("path")
.attr("fill", function(d, i) { return color(i); })
.attr("d", function(d, i, j) {
return arc.innerRadius(10+cwidth*j).outerRadius(cwidth*(j+1))(d);
});
Updated jsfiddle here.