sunburst partition layout

50 views
Skip to first unread message

Kasumi Kingfisher

unread,
Apr 18, 2014, 10:18:24 AM4/18/14
to d3...@googlegroups.com
Hi,
I'm really ashamed to ask, but I'm quite new to d3-js and I need to make an sunburst diagram for my data. I've read the explanation at https://github.com/mbostock/d3/wiki/Partition-Layout and tried to understand it by comparing with this http://bl.ocks.org/mbostock/4063423 , but I can't wrap my mind about it and still have several problems.
Namely:
a) In this part 
var partition = d3.layout.partition()
                   .sort(null)
                   .size([2*Math.PI, radius*radius]);
                   .value(function(d) {return 1;});

  What function has the "value" method in this?

b) I don't understand all that's happening while setting the wedges. What does the "d.depth" stand for?
 var arc = d3.svg.arc()
             .startAngle(function(d) {return d.x;})
             .endAngle(function(d) {return d.x + d.dx - .01/(d.depth + 0.5);})
             .innerRadius(function(d) {return Math.sqrt(d.y);})
             .outerRadius(function (d) {return Math.sqrt(d.y+d.dy);});


c) and this I don't understand at all...
var path =svg.datum(root)
             .selectAll("path")
             .data(partition.nodes)
             .enter()
             .append("path")
             .attr("display",function(d) {return d.depth ? null: "none";})
             .attr("d",arc)
             .attr("stroke","#fff")
             .attr("fill", funciton(d) {return color((d.chidlren ? d:d.parent).name);})
             .style("fill-rule","evenodd")
             .each(stash);

                           
Maybe if there was some example with data that I can see I think I would know what's going on (at least I could deduce it). I've made a simple pie using my .json data but here, I'm completely at loss. I know it's silly to ask these questions but I can't help it and I would really appreciate some help. Thanks.
Reply all
Reply to author
Forward
0 new messages