Sha256: a5108155dd0d1de5c9ebcb9520d897e2cd3860c42c34487e9edebee3bfe96f81

Contents?: true

Size: 1.33 KB

Versions: 6

Compression:

Stored size: 1.33 KB

Contents

/* woo */

var r = 960 / 2;
 
var tree = d3.layout.tree()
    .size([360, r - 120])
    .separation(function(a, b) { return (a.parent == b.parent ? 1 : 2) / a.depth; });
 
var diagonal = d3.svg.diagonal.radial()
    .projection(function(d) { return [d.y, d.x / 180 * Math.PI]; });

var vis = d3.select("#graphs").append("svg:svg")
    .attr("width", r * 2)
    .attr("height", r * 2 - 150)
  .append("svg:g")
    .attr("transform", "translate(" + r + "," + r + ")");

d3.json("../data/flare.json", function(json) {
    var nodes = tree.nodes(json);
    
    var link = vis.selectAll("path.link")
        .data(tree.links(nodes))
        .enter().append("svg:path")
        .attr("class", "link")
        .attr("d", diagonal);
    
    var node = vis.selectAll("g.node")
        .data(nodes)
        .enter().append("svg:g")
        .attr("class", "node")
        .attr("transform", function(d) { return "rotate(" + (d.x - 90) + ")translate(" + d.y + ")"; })
    
    node.append("svg:circle")
        .attr("r", 4.5);
    
    node.append("svg:text")
        .attr("dx", function(d) { return d.x < 180 ? 8 : -8; })
        .attr("dy", ".31em")
        .attr("text-anchor", function(d) { return d.x < 180 ? "start" : "end"; })
        .attr("transform", function(d) { return d.x < 180 ? null : "rotate(180)"; })
        .text(function(d) { return d.name; });
});

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bum-0.0.17 public/graph.js
bum-0.0.16 public/graph.js
bum-0.0.15 public/graph.js
bum-0.0.14 public/graph.js
bum-0.0.13 public/graph.js
bum-0.0.12 public/graph.js