Sha256: 10615683576da4e938e34dc35e124778f695149d33f0bcbef04389b8c58fa98c

Contents?: true

Size: 1.18 KB

Versions: 6

Compression:

Stored size: 1.18 KB

Contents

var r = 960 / 2;

var cluster = d3.layout.cluster()
    .size([360, r - 120]);

var diagonal = d3.svg.diagonal.radial()
    .projection(function(d) { return [d.y, d.x / 180 * Math.PI]; });

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

d3.json("../data/flare.json", function(json) {
  var nodes = cluster.nodes(json);

  var link = vis.selectAll("path.link")
      .data(cluster.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/d3/examples/cluster/cluster-radial.js
bum-0.0.16 public/d3/examples/cluster/cluster-radial.js
bum-0.0.15 public/d3/examples/cluster/cluster-radial.js
bum-0.0.14 public/d3/examples/cluster/cluster-radial.js
bum-0.0.13 public/d3/examples/cluster/cluster-radial.js
bum-0.0.12 public/d3/examples/cluster/cluster-radial.js