3
fill = d3.scale.ordinal().range(colorbrewer.Greys[9].slice(1, 4)),
4
stroke = d3.scale.linear().domain([0, 1e4]).range(["brown", "steelblue"]);
6
var treemap = d3.layout.treemap()
8
.value(function(d) { return d.size; });
10
var bundle = d3.layout.bundle();
12
var div = d3.select("#chart").append("div")
13
.style("position", "relative")
14
.style("width", w + "px")
15
.style("height", h + "px");
17
var line = d3.svg.line()
18
.interpolate("bundle")
20
.x(function(d) { return d.x + d.dx / 2; })
21
.y(function(d) { return d.y + d.dy / 2; });
23
d3.json("../data/flare-imports.json", function(classes) {
24
var nodes = treemap.nodes(packages.root(classes)),
25
links = packages.imports(nodes);
29
.enter().append("div")
30
.attr("class", "cell")
31
.style("background", function(d) { return d.children ? fill(d.key) : null; })
33
.text(function(d) { return d.children ? null : d.key; });
38
.style("position", "absolute")
39
.selectAll("path.link")
41
.enter().append("path")
42
.style("stroke", function(d) { return stroke(d[0].value); })
43
.attr("class", "link")
49
.style("left", function(d) { return d.x + "px"; })
50
.style("top", function(d) { return d.y + "px"; })
51
.style("width", function(d) { return d.dx - 1 + "px"; })
52
.style("height", function(d) { return d.dy - 1 + "px"; });