4
var fill = d3.scale.ordinal()
5
.range(colorbrewer.Greys[9].slice(1, 4));
7
var stroke = d3.scale.linear()
9
.range(["brown", "steelblue"]);
11
var treemap = d3.layout.treemap()
12
.size([width, height])
13
.value(function(d) { return d.size; });
15
var bundle = d3.layout.bundle();
17
var div = d3.select("#chart").append("div")
18
.style("position", "relative")
19
.style("width", width + "px")
20
.style("height", height + "px");
22
var line = d3.svg.line()
23
.interpolate("bundle")
25
.x(function(d) { return d.x + d.dx / 2; })
26
.y(function(d) { return d.y + d.dy / 2; });
28
d3.json("../data/flare-imports.json", function(classes) {
29
var nodes = treemap.nodes(packages.root(classes)),
30
links = packages.imports(nodes);
34
.enter().append("div")
35
.attr("class", "cell")
36
.style("background", function(d) { return d.children ? fill(d.key) : null; })
38
.text(function(d) { return d.children ? null : d.key; });
42
.attr("height", height)
43
.style("position", "absolute")
44
.selectAll("path.link")
46
.enter().append("path")
47
.style("stroke", function(d) { return stroke(d[0].value); })
48
.attr("class", "link")
54
.style("left", function(d) { return d.x + "px"; })
55
.style("top", function(d) { return d.y + "px"; })
56
.style("width", function(d) { return d.dx - 1 + "px"; })
57
.style("height", function(d) { return d.dy - 1 + "px"; });