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

« back to all changes in this revision

Viewing changes to backend/stats/static/js/d3/examples/pack/pack.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 w = 960,
 
2
    h = 960,
 
3
    format = d3.format(",d");
 
4
 
 
5
var pack = d3.layout.pack()
 
6
    .size([w - 4, h - 4])
 
7
    .value(function(d) { return d.size; });
 
8
 
 
9
var vis = d3.select("#chart").append("svg")
 
10
    .attr("width", w)
 
11
    .attr("height", h)
 
12
    .attr("class", "pack")
 
13
  .append("g")
 
14
    .attr("transform", "translate(2, 2)");
 
15
 
 
16
d3.json("../data/flare.json", function(json) {
 
17
  var node = vis.data([json]).selectAll("g.node")
 
18
      .data(pack.nodes)
 
19
    .enter().append("g")
 
20
      .attr("class", function(d) { return d.children ? "node" : "leaf node"; })
 
21
      .attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; });
 
22
 
 
23
  node.append("title")
 
24
      .text(function(d) { return d.name + (d.children ? "" : ": " + format(d.size)); });
 
25
 
 
26
  node.append("circle")
 
27
      .attr("r", function(d) { return d.r; });
 
28
 
 
29
  node.filter(function(d) { return !d.children; }).append("text")
 
30
      .attr("text-anchor", "middle")
 
31
      .attr("dy", ".3em")
 
32
      .text(function(d) { return d.name.substring(0, d.r / 3); });
 
33
});