forked from mbostock's block: Circle-Packing II
Created
March 17, 2019 19:54
-
-
Save CBasis/7f7cd9835141c3e068a74d848fb59537 to your computer and use it in GitHub Desktop.
Circle-Packing II
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 | |
height: 960 | |
border: no |
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
id | value | |
---|---|---|
-Abdulbasit | 1 | |
-Ajay | 1 | |
-Alisdair | 1 | |
-Ankur | 1 | |
-Anne | 1 | |
-Athavan | 1 | |
-Bhanu | 1 | |
-Chris | 1 | |
-Chris | 1 | |
-Chris | 1 | |
-Christian | 1 | |
-Christian | 1 | |
-Christian | 1 | |
-Clint | 1 | |
-Dallas | 1 | |
-Daniel | 1 | |
-Danielle | 1 | |
-David | 1 | |
-Derek | 1 | |
-Diego | 1 | |
-Eng | 1 | |
-Eric | 1 | |
-Ethan | 1 | |
-Fabio | 1 | |
-Florian | 1 | |
-Frank | 1 | |
-Gareth | 1 | |
-Gary | 1 | |
-Graham | 1 | |
-Greg | 1 | |
-Gregor | 1 | |
-Heather | 1 | |
-Hendrik | 1 | |
-Henrik | 1 | |
-Jim | 1 | |
-Joyce | 1 | |
-Julien | 1 | |
-Jyoti | 1 | |
-Karin | 1 | |
-Kinga | 1 | |
-Klaus | 1 | |
-Krishna | 1 | |
-Lars | 1 | |
-Leonardo | 1 | |
-Maria | 1 | |
-Marina | 1 | |
-Mark | 1 | |
-Markus | 1 | |
-Marssel | 1 | |
-Martin | 1 | |
-Matt | 1 | |
-Matt | 1 | |
-Michael | 1 | |
-Michal | 1 | |
-Mike | 1 | |
-Morten | 1 | |
-Oliver | 1 | |
-Owen | 1 | |
-Paul | 1 | |
-Paul | 1 | |
-Paul | 1 | |
-Peter | 1 | |
-Raquel | 1 | |
-Raquel | 1 | |
-Ridvan | 1 | |
-Robert | 1 | |
-Robin | 1 | |
-Ronald | 1 | |
-Roy | 1 | |
-Seung | 1 | |
-Simha | 1 | |
-Simon | 1 | |
-Simon | 1 | |
-Steve | 1 | |
-Steve | 1 | |
-Susan | 1 | |
-Tamas | 1 | |
-Tammy | 1 | |
-Thorsten | 1 | |
-Tobias | 1 | |
-Tobias | 1 | |
-Tom | 1 | |
-Tomas | 1 | |
-Vasily | 1 | |
-Wence | 1 | |
-Wouter | 1 |
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"> | |
<style> | |
text { | |
font: 10px sans-serif; | |
text-anchor: middle; | |
} | |
.node circle { | |
fill: #ddd; | |
} | |
.node:hover circle { | |
stroke: #000; | |
stroke-width: 1.2px; | |
} | |
</style> | |
<svg width="960" height="960"><g transform="translate(1,1)"></g></svg> | |
<script src="https://d3js.org/d3.v4.0.0-alpha.35.min.js"></script> | |
<script> | |
var svg = d3.select("svg"), | |
width = +svg.attr("width"), | |
height = +svg.attr("height"); | |
var format = d3.format(",d"); | |
var pack = d3.pack() | |
.size([width - 2, height - 2]) | |
.padding(3); | |
d3.csv("flare.csv", type, function(error, data) { | |
if (error) throw error; | |
var root = d3.hierarchy({children: data}) | |
.sum(function(d) { return d.value; }) | |
.sort(function(a, b) { return b.value - a.value; }); | |
pack(root); | |
var node = svg.select("g") | |
.selectAll("g") | |
.data(root.children) | |
.enter().append("g") | |
.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; }) | |
.attr("class", "node"); | |
node.append("circle") | |
.attr("id", function(d) { return "node-" + d.data.id; }) | |
.attr("r", function(d) { return d.r; }); | |
node.append("clipPath") | |
.attr("id", function(d) { return "clip-" + d.data.id; }) | |
.append("use") | |
.attr("xlink:href", function(d) { return "#node-" + d.data.id + ""; }); | |
node.append("text") | |
.attr("clip-path", function(d) { return "url(#clip-" + d.data.id + ")"; }) | |
.selectAll("tspan") | |
.data(function(d) { return d.data.id.split(".").pop().split(/(?=[A-Z][^A-Z])/g); }) | |
.enter().append("tspan") | |
.attr("x", 0) | |
.attr("y", function(d, i, nodes) { return 13 + (i - nodes.length / 2 - 0.5) * 10; }) | |
.text(function(d) { return d; }); | |
node.append("title") | |
.text(function(d) { return d.data.id + "\n" + format(d.value); }); | |
}); | |
function type(d) { | |
return (d.value = +d.value) ? d : null; | |
} | |
</script> |
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
�PNG | |