xxxxxxxxxx
<meta charset="utf-8">
<title>Partition - Icicle</title>
<style>
.node {
fill: #ddd;
stroke: #fff;
}
.label {
font: 10px sans-serif;
text-anchor: middle;
}
</style>
<body>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script>
var width = 960,
height = 900;
var color = d3.scale.category20();
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
var partition = d3.layout.partition()
.size([width, height])
.value(function(d) { return d.appropriation14; });
d3.json("/darrenjaworski/raw/5389708/budget.json", function(error, root) {
var nodes = partition.nodes(root);
svg.selectAll(".node")
.data(nodes)
.enter().append("rect")
.attr("class", "node")
.attr("x", function(d) { return d.x; })
.attr("y", function(d) { return d.y; })
.attr("width", function(d) { return d.dx; })
.attr("height", function(d) { return d.dy; })
.style("fill", function(d) { return color((d.children ? d : d.parent).name); });
svg.selectAll(".label")
.data(nodes.filter(function(d) { return d.dx > 6; }))
.enter().append("text")
.attr("class", "label")
.attr("dy", ".35em")
.attr("transform", function(d) { return "translate(" + (d.x + d.dx / 2) + "," + (d.y + d.dy / 2) + ")rotate(90)"; })
.text(function(d) { return d.name; });
});
</script>
Modified http://d3js.org/d3.v3.min.js to a secure url
https://d3js.org/d3.v3.min.js