~ubuntu-branches/ubuntu/precise/whoopsie-daisy/precise-proposed

« back to all changes in this revision

Viewing changes to backend/stats/static/js/d3/examples/tree/tree-radial.js

  • Committer: Package Import Robot
  • Author(s): Evan Dandrea
  • Date: 2012-04-10 14:28:58 UTC
  • Revision ID: package-import@ubuntu.com-20120410142858-nk453o1z7t7py3bs
Tags: 0.1.26
* Take ownership of the NetworkManager state variant on setup and
  unref it, plugging a memory leak.
* Log the reason the server rejected the submitted crash report.
* Send the Whoopsie version with each crash submission.
* Delete both .upload and .uploaded files after 14 days. Thanks
  Marc Deslauriers (LP: #973687).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
var r = 960 / 2;
 
2
 
 
3
var tree = d3.layout.tree()
 
4
    .size([360, r - 120])
 
5
    .separation(function(a, b) { return (a.parent == b.parent ? 1 : 2) / a.depth; });
 
6
 
 
7
var diagonal = d3.svg.diagonal.radial()
 
8
    .projection(function(d) { return [d.y, d.x / 180 * Math.PI]; });
 
9
 
 
10
var vis = d3.select("#chart").append("svg")
 
11
    .attr("width", r * 2)
 
12
    .attr("height", r * 2 - 150)
 
13
  .append("g")
 
14
    .attr("transform", "translate(" + r + "," + r + ")");
 
15
 
 
16
d3.json("../data/flare.json", function(json) {
 
17
  var nodes = tree.nodes(json);
 
18
 
 
19
  var link = vis.selectAll("path.link")
 
20
      .data(tree.links(nodes))
 
21
    .enter().append("path")
 
22
      .attr("class", "link")
 
23
      .attr("d", diagonal);
 
24
 
 
25
  var node = vis.selectAll("g.node")
 
26
      .data(nodes)
 
27
    .enter().append("g")
 
28
      .attr("class", "node")
 
29
      .attr("transform", function(d) { return "rotate(" + (d.x - 90) + ")translate(" + d.y + ")"; })
 
30
 
 
31
  node.append("circle")
 
32
      .attr("r", 4.5);
 
33
 
 
34
  node.append("text")
 
35
      .attr("dx", function(d) { return d.x < 180 ? 8 : -8; })
 
36
      .attr("dy", ".31em")
 
37
      .attr("text-anchor", function(d) { return d.x < 180 ? "start" : "end"; })
 
38
      .attr("transform", function(d) { return d.x < 180 ? null : "rotate(180)"; })
 
39
      .text(function(d) { return d.name; });
 
40
});