This is the simplest radial tree diagram I could create. Let me know if you think I can make it tighter.
Build notes:
- It pulls data from a csv file. It uses d3.stratify() to reform links into a hierarchy. (NOTE: I ran into a challenge with
d.size
when moving from json to csv. Whilesize
is a feature of my data, I had to now access it fromd.data.size
.) - To differentiate between local variables and framework objects, I prefix variables with lowercase 'v'.
Radial Tree notes: The size
method in d3.cluster().size([2 * Math.PI, Math.min(vWidth, vHeight)/2 - 10]);
is both important and odd.
- radius setting
Math.min(vWidth, vHeight)/2 - 10]);
: We choose smaller of height and width, then we divide in half to find (and set) the diagram's radius. We pull out a bit extra to ensure we have margin (so that the circles don't get clipped). I chose to subtract 10 since my cirle radius is 10 (which really translates to 10 / 2 * 2 since I'm only in danger of cutting off 1/2 my circle, but it could happen on both sides). - The first element of size sets the bredth of the diagram. While https://github.com/d3/d3-hierarchy#cluster_size mentions 360, my diagrams ended up wonky if I didn't raise this number to something much larger (maybe due to my low number of end nodes?).
From https://bl.ocks.org/denjn5/4cc1a43f41efdc0ae6b7a1bf6a7d5e4e