-
-
Save mbostock/1627378 to your computer and use it in GitHub Desktop.
Circle Packing with Zero Values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: gpl-3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<body> | |
<style> | |
circle { | |
stroke: #000; | |
fill-opacity: .1; | |
} | |
</style> | |
<script src="//d3js.org/d3.v3.min.js"></script> | |
<script> | |
var data = { | |
children: [ | |
{value: 1.94}, | |
{value: 0.42}, | |
{value: 0}, | |
{value: 3.95}, | |
{value: 0.06}, | |
{value: 0.91} | |
] | |
}; | |
var width = 960, | |
height = 500; | |
var pack = d3.layout.pack() | |
.size([width, height]); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
svg.data([data]).selectAll(".node") | |
.data(pack.nodes) | |
.enter().append("circle") | |
.attr("class", "node") | |
.attr("transform", function(d) { return "translate(" + d.x + "," + 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