Skip to content

Instantly share code, notes, and snippets.

@mbostock

mbostock/.block Secret

Forked from mbostock/.block
Last active February 9, 2016 01:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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: 10, dummy: 1}
]
},
{value: 42},
{value: 10, dummy: 1}
]
};
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).filter(function(d) { return !d.dummy; }))
.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