Skip to content

Instantly share code, notes, and snippets.

@mbostock

mbostock/.block Secret

Last active February 9, 2016 01:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mbostock/3315291 to your computer and use it in GitHub Desktop.
Save mbostock/3315291 to your computer and use it in GitHub Desktop.
Pack Test
license: gpl-3.0
<!DOCTYPE html>
<meta charset="utf-8">
<style>
circle {
fill-opacity: .1;
stroke: #000;
}
</style>
<body>
<script src="//d3js.org/d3.v3.min.js"></script>
<script>
var root = {
children: [
{
children: [
{value: 42}
]
},
{value: 42}
]
};
var width = 960,
height = 500;
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height)
var pack = d3.layout.pack()
.size([width, height]);
svg.selectAll("circle")
.data(pack.nodes(root))
.enter().append("circle")
.attr("cx", function(d) { return d.x; })
.attr("cy", function(d) { return d.y; })
.attr("r", function(d) { return d.r; });
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment