Sha256: 869f42fb077e1828b92e1d5cac6054e1052f358f234b790e5cbad2a24025a2c1

Contents?: true

Size: 1.99 KB

Versions: 25

Compression:

Stored size: 1.99 KB

Contents

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <title>Partition - Sunburst</title>
    <script type="text/javascript" src="../../d3.js"></script>
    <script type="text/javascript" src="../../d3.layout.js"></script>
    <style type="text/css">

path {
  stroke: #fff;
  fill-rule: evenodd;
}

    </style>
  </head>
  <body>
    <div id="chart"></div>
    <script type="text/javascript">

var w = 960,
    h = 700,
    r = Math.min(w, h) / 2,
    x = d3.scale.linear().range([0, 2 * Math.PI]),
    y = d3.scale.sqrt().range([0, r]),
    color = d3.scale.category20c();

var vis = d3.select("#chart").append("svg")
    .attr("width", w)
    .attr("height", h)
  .append("g")
    .attr("transform", "translate(" + w / 2 + "," + h / 2 + ")");

var partition = d3.layout.partition()
    .value(function(d) { return d.size; });

var arc = d3.svg.arc()
    .startAngle(function(d) { return Math.max(0, Math.min(2 * Math.PI, x(d.x))); })
    .endAngle(function(d) { return Math.max(0, Math.min(2 * Math.PI, x(d.x + d.dx))); })
    .innerRadius(function(d) { return Math.max(0, y(d.y)); })
    .outerRadius(function(d) { return Math.max(0, y(d.y + d.dy)); });

d3.json("../data/flare.json", function(json) {
  var path = vis.data([json]).selectAll("path")
      .data(partition.nodes)
    .enter().append("path")
      .attr("d", arc)
      .style("fill", function(d) { return color((d.children ? d : d.parent).name); })
      .on("click", click);

  function click(d) {
    path.transition()
      .duration(750)
      .attrTween("d", arcTween(d));
  }
});

// Interpolate the scales!
function arcTween(d) {
  var xd = d3.interpolate(x.domain(), [d.x, d.x + d.dx]),
      yd = d3.interpolate(y.domain(), [d.y, 1]),
      yr = d3.interpolate(y.range(), [d.y ? 20 : 0, r]);
  return function(d, i) {
    return i
        ? function(t) { return arc(d); }
        : function(t) { x.domain(xd(t)); y.domain(yd(t)).range(yr(t)); return arc(d); };
  };
}

    </script>
  </body>
</html>

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
picky-statistics-4.5.0 lib/picky-statistics/application/javascripts/d3/examples/partition/partition-sunburst-zoom.html
picky-statistics-4.4.2 lib/picky-statistics/application/javascripts/d3/examples/partition/partition-sunburst-zoom.html
picky-statistics-4.4.1 lib/picky-statistics/application/javascripts/d3/examples/partition/partition-sunburst-zoom.html
picky-statistics-4.4.0 lib/picky-statistics/application/javascripts/d3/examples/partition/partition-sunburst-zoom.html
picky-statistics-4.3.2 lib/picky-statistics/application/javascripts/d3/examples/partition/partition-sunburst-zoom.html
picky-statistics-4.3.1 lib/picky-statistics/application/javascripts/d3/examples/partition/partition-sunburst-zoom.html
picky-statistics-4.3.0 lib/picky-statistics/application/javascripts/d3/examples/partition/partition-sunburst-zoom.html
picky-statistics-4.2.4 lib/picky-statistics/application/javascripts/d3/examples/partition/partition-sunburst-zoom.html
picky-statistics-4.2.3 lib/picky-statistics/application/javascripts/d3/examples/partition/partition-sunburst-zoom.html
picky-statistics-4.2.2 lib/picky-statistics/application/javascripts/d3/examples/partition/partition-sunburst-zoom.html
picky-statistics-4.2.1 lib/picky-statistics/application/javascripts/d3/examples/partition/partition-sunburst-zoom.html
picky-statistics-4.2.0 lib/picky-statistics/application/javascripts/d3/examples/partition/partition-sunburst-zoom.html
picky-statistics-4.1.0 lib/picky-statistics/application/javascripts/d3/examples/partition/partition-sunburst-zoom.html
picky-statistics-4.0.9 lib/picky-statistics/application/javascripts/d3/examples/partition/partition-sunburst-zoom.html
picky-statistics-4.0.8 lib/picky-statistics/application/javascripts/d3/examples/partition/partition-sunburst-zoom.html
picky-statistics-4.0.7 lib/picky-statistics/application/javascripts/d3/examples/partition/partition-sunburst-zoom.html
picky-statistics-4.0.6 lib/picky-statistics/application/javascripts/d3/examples/partition/partition-sunburst-zoom.html
picky-statistics-4.0.5 lib/picky-statistics/application/javascripts/d3/examples/partition/partition-sunburst-zoom.html
picky-statistics-4.0.4 lib/picky-statistics/application/javascripts/d3/examples/partition/partition-sunburst-zoom.html
picky-statistics-4.0.3 lib/picky-statistics/application/javascripts/d3/examples/partition/partition-sunburst-zoom.html