Sha256: 92771c59a3c9ec407468a9dede9942bd89be5903f5a3a39093b6991785d58636
Contents?: true
Size: 1.03 KB
Versions: 25
Compression:
Stored size: 1.03 KB
Contents
var w = 960, h = 500, color = d3.scale.category20c(); var treemap = d3.layout.treemap() .padding(4) .size([w, h]) .value(function(d) { return d.size; }); var svg = d3.select("body").append("svg") .attr("width", w) .attr("height", h) .append("g") .attr("transform", "translate(-.5,-.5)"); d3.json("../data/flare.json", function(json) { var cell = svg.data([json]).selectAll("g") .data(treemap) .enter().append("g") .attr("class", "cell") .attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; }); cell.append("rect") .attr("width", function(d) { return d.dx; }) .attr("height", function(d) { return d.dy; }) .style("fill", function(d) { return d.children ? color(d.data.name) : null; }); cell.append("text") .attr("x", function(d) { return d.dx / 2; }) .attr("y", function(d) { return d.dy / 2; }) .attr("dy", ".35em") .attr("text-anchor", "middle") .text(function(d) { return d.children ? null : d.data.name; }); });
Version data entries
25 entries across 25 versions & 1 rubygems