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

« back to all changes in this revision

Viewing changes to backend/stats/static/js/d3/examples/partition/partition-sunburst-zoom.html

  • 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
<!DOCTYPE html>
 
2
<html>
 
3
  <head>
 
4
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
 
5
    <title>Partition - Sunburst</title>
 
6
    <script type="text/javascript" src="../../d3.v2.js"></script>
 
7
    <style type="text/css">
 
8
 
 
9
path {
 
10
  stroke: #fff;
 
11
  fill-rule: evenodd;
 
12
}
 
13
 
 
14
    </style>
 
15
  </head>
 
16
  <body>
 
17
    <div id="chart"></div>
 
18
    <script type="text/javascript">
 
19
 
 
20
var w = 960,
 
21
    h = 700,
 
22
    r = Math.min(w, h) / 2,
 
23
    x = d3.scale.linear().range([0, 2 * Math.PI]),
 
24
    y = d3.scale.sqrt().range([0, r]),
 
25
    color = d3.scale.category20c();
 
26
 
 
27
var vis = d3.select("#chart").append("svg")
 
28
    .attr("width", w)
 
29
    .attr("height", h)
 
30
  .append("g")
 
31
    .attr("transform", "translate(" + w / 2 + "," + h / 2 + ")");
 
32
 
 
33
var partition = d3.layout.partition()
 
34
    .value(function(d) { return d.size; });
 
35
 
 
36
var arc = d3.svg.arc()
 
37
    .startAngle(function(d) { return Math.max(0, Math.min(2 * Math.PI, x(d.x))); })
 
38
    .endAngle(function(d) { return Math.max(0, Math.min(2 * Math.PI, x(d.x + d.dx))); })
 
39
    .innerRadius(function(d) { return Math.max(0, y(d.y)); })
 
40
    .outerRadius(function(d) { return Math.max(0, y(d.y + d.dy)); });
 
41
 
 
42
d3.json("../data/flare.json", function(json) {
 
43
  var path = vis.data([json]).selectAll("path")
 
44
      .data(partition.nodes)
 
45
    .enter().append("path")
 
46
      .attr("d", arc)
 
47
      .style("fill", function(d) { return color((d.children ? d : d.parent).name); })
 
48
      .on("click", click);
 
49
 
 
50
  function click(d) {
 
51
    path.transition()
 
52
      .duration(750)
 
53
      .attrTween("d", arcTween(d));
 
54
  }
 
55
});
 
56
 
 
57
// Interpolate the scales!
 
58
function arcTween(d) {
 
59
  var xd = d3.interpolate(x.domain(), [d.x, d.x + d.dx]),
 
60
      yd = d3.interpolate(y.domain(), [d.y, 1]),
 
61
      yr = d3.interpolate(y.range(), [d.y ? 20 : 0, r]);
 
62
  return function(d, i) {
 
63
    return i
 
64
        ? function(t) { return arc(d); }
 
65
        : function(t) { x.domain(xd(t)); y.domain(yd(t)).range(yr(t)); return arc(d); };
 
66
  };
 
67
}
 
68
 
 
69
    </script>
 
70
  </body>
 
71
</html>